summaryrefslogtreecommitdiff
path: root/src/nm-ip4-config.h
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-10-04 15:21:21 +0200
committerThomas Haller <thaller@redhat.com>2017-10-10 08:46:47 +0200
commit5c299454b49b165f645c25fd3e083c0bb747ad91 (patch)
tree259470cd32be8d0c78e4f4f88bad2ef83e8574a8 /src/nm-ip4-config.h
parent2bdfc092d40daaf1af87a4cc2285caa63f35e9d3 (diff)
downloadNetworkManager-5c299454b49b165f645c25fd3e083c0bb747ad91.tar.gz
core: rework tracking of gateway/default-route in ip-config
Instead of having 3 properties @gateway, @never_default and @has_gateway on NMIP4Config/NMIP6Config that determine the default-route, track the default-route as a regular route. The gateway setting is the configuration knob for the default-route. Since an NMIP4Config/NMIP6Config instance only has one gateway property, it cannot track more then one default-routes (see related bug rh#1445417). Especially with policy routing, it might be interesting to configure a default-route in multiple tables. Also, later it might be interesting to allow adding default-routes as regular static routes in a connection, so that the user can configure additional route parameters for the default-route or add default-routes in multiple tables. With this patch, default-routes now have a rt_source property according to their origin. Also, the previous commits of this branch broke handling of the default-route :) . That should be working now again.
Diffstat (limited to 'src/nm-ip4-config.h')
-rw-r--r--src/nm-ip4-config.h50
1 files changed, 28 insertions, 22 deletions
diff --git a/src/nm-ip4-config.h b/src/nm-ip4-config.h
index 775869cd20..978471df29 100644
--- a/src/nm-ip4-config.h
+++ b/src/nm-ip4-config.h
@@ -80,12 +80,16 @@ nm_ip_config_best_default_route_is (const NMPObject *obj)
{
const NMPlatformIPRoute *r = NMP_OBJECT_CAST_IP_ROUTE (obj);
- /* return whether @obj is considered a default-route, that is, a route
- * as added by NetworkManager. E.g. if the route is not in the main-table,
- * it's considered just like a regular route. */
+ /* return whether @obj is considered a default-route.
+ *
+ * NMIP4Config/NMIP6Config tracks the (best) default-route explicitly, because
+ * at various places we act differently depending on whether there is a default-route
+ * configured.
+ *
+ * Note that this only considers the main routing table. */
return r
- && !r->table_coerced
- && NM_PLATFORM_IP_ROUTE_IS_DEFAULT (r);
+ && NM_PLATFORM_IP_ROUTE_IS_DEFAULT (r)
+ && nm_platform_route_table_is_main (r->table_coerced);
}
const NMPObject *_nm_ip_config_best_default_route_find_better (const NMPObject *obj_cur, const NMPObject *obj_cmp);
@@ -151,10 +155,10 @@ NMDedupMultiIndex *nm_ip4_config_get_multi_idx (const NMIP4Config *self);
NMIP4Config *nm_ip4_config_capture (NMDedupMultiIndex *multi_idx, NMPlatform *platform, int ifindex, gboolean capture_resolv_conf);
-void nm_ip4_config_add_device_routes (NMIP4Config *self,
- guint32 route_table,
- guint32 route_metric,
- GPtrArray **out_ip4_dev_route_blacklist);
+void nm_ip4_config_add_dependent_routes (NMIP4Config *self,
+ guint32 route_table,
+ guint32 route_metric,
+ GPtrArray **out_ip4_dev_route_blacklist);
gboolean nm_ip4_config_commit (const NMIP4Config *self,
NMPlatform *platform,
@@ -167,24 +171,24 @@ void nm_ip4_config_merge_setting (NMIP4Config *self,
NMSetting *nm_ip4_config_create_setting (const NMIP4Config *self);
-void nm_ip4_config_merge (NMIP4Config *dst, const NMIP4Config *src, NMIPConfigMergeFlags merge_flags);
-void nm_ip4_config_subtract (NMIP4Config *dst, const NMIP4Config *src);
-void nm_ip4_config_intersect (NMIP4Config *dst, const NMIP4Config *src);
+void nm_ip4_config_merge (NMIP4Config *dst,
+ const NMIP4Config *src,
+ NMIPConfigMergeFlags merge_flags,
+ guint32 default_route_metric_penalty);
+void nm_ip4_config_subtract (NMIP4Config *dst,
+ const NMIP4Config *src,
+ guint32 default_route_metric_penalty);
+void nm_ip4_config_intersect (NMIP4Config *dst,
+ const NMIP4Config *src,
+ guint32 default_route_metric_penalty);
gboolean nm_ip4_config_replace (NMIP4Config *dst, const NMIP4Config *src, gboolean *relevant_changes);
-gboolean nm_ip4_config_destination_is_direct (const NMIP4Config *self, guint32 dest, guint8 plen);
void nm_ip4_config_dump (const NMIP4Config *self, const char *detail);
-
-void nm_ip4_config_set_never_default (NMIP4Config *self, gboolean never_default);
-gboolean nm_ip4_config_get_never_default (const NMIP4Config *self);
-void nm_ip4_config_set_gateway (NMIP4Config *self, guint32 gateway);
-void nm_ip4_config_unset_gateway (NMIP4Config *self);
-gboolean nm_ip4_config_has_gateway (const NMIP4Config *self);
-guint32 nm_ip4_config_get_gateway (const NMIP4Config *self);
-
const NMPObject *nm_ip4_config_best_default_route_get (const NMIP4Config *self);
const NMPObject *_nm_ip4_config_best_default_route_find (const NMIP4Config *self);
+in_addr_t nmtst_ip4_config_get_gateway (NMIP4Config *config);
+
const NMDedupMultiHeadEntry *nm_ip4_config_lookup_addresses (const NMIP4Config *self);
void nm_ip4_config_reset_addresses (NMIP4Config *self);
void nm_ip4_config_add_address (NMIP4Config *self, const NMPlatformIP4Address *address);
@@ -203,7 +207,9 @@ void _nmtst_ip4_config_del_route (NMIP4Config *self, guint i);
guint nm_ip4_config_get_num_routes (const NMIP4Config *self);
const NMPlatformIP4Route *_nmtst_ip4_config_get_route (const NMIP4Config *self, guint i);
-const NMPlatformIP4Route *nm_ip4_config_get_direct_route_for_host (const NMIP4Config *self, guint32 host);
+const NMPlatformIP4Route *nm_ip4_config_get_direct_route_for_host (const NMIP4Config *self,
+ in_addr_t host,
+ guint32 route_table);
void nm_ip4_config_reset_nameservers (NMIP4Config *self);
void nm_ip4_config_add_nameserver (NMIP4Config *self, guint32 nameserver);