diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2015-01-20 18:50:20 +0100 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2015-01-21 15:00:26 +0100 |
commit | 33a6042cb6fda9c95119b17b9880eba6010237db (patch) | |
tree | 64f0ab8453a5bdaacfec7c1a4b326981afa42e1c | |
parent | 70605d05d981457f64beefebec87b80cb739a813 (diff) | |
download | NetworkManager-33a6042cb6fda9c95119b17b9880eba6010237db.tar.gz |
ip6-config: keep track of ifindex
No functional change, a cosmetic thing for now.
We want it set before any routes are added and ensure routes have a valid
ifindex before we pass it to the platform.
In a future NMRouteManager will need to look up the route for a device in
its cache thus we'll need to make sure routes passed to the it have an
appropriate ifindex set.
-rw-r--r-- | src/devices/nm-device.c | 7 | ||||
-rw-r--r-- | src/devices/wwan/nm-device-modem.c | 4 | ||||
-rw-r--r-- | src/dhcp-manager/nm-dhcp-client.c | 3 | ||||
-rw-r--r-- | src/dhcp-manager/nm-dhcp-utils.c | 4 | ||||
-rw-r--r-- | src/dhcp-manager/nm-dhcp-utils.h | 3 | ||||
-rw-r--r-- | src/nm-iface-helper.c | 2 | ||||
-rw-r--r-- | src/nm-ip6-config.c | 21 | ||||
-rw-r--r-- | src/nm-ip6-config.h | 2 | ||||
-rw-r--r-- | src/ppp-manager/nm-ppp-manager.c | 2 | ||||
-rw-r--r-- | src/tests/test-ip6-config.c | 5 | ||||
-rw-r--r-- | src/vpn-manager/nm-vpn-connection.c | 5 |
11 files changed, 52 insertions, 6 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index e9c56ac130..ac699461a5 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -3436,6 +3436,7 @@ ip6_config_merge_and_apply (NMDevice *self, /* If no config was passed in, create a new one */ composite = nm_ip6_config_new (); g_assert (composite); + nm_ip6_config_set_ifindex (composite, nm_device_get_ifindex (self)); /* Merge all the IP configs into the composite config */ if (priv->ac_ip6_config) @@ -4007,8 +4008,10 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, NMDevice *self) g_return_if_fail (priv->act_request); - if (!priv->ac_ip6_config) + if (!priv->ac_ip6_config) { priv->ac_ip6_config = nm_ip6_config_new (); + nm_ip6_config_set_ifindex (priv->ac_ip6_config, nm_device_get_ifindex (self)); + } if (changed & NM_RDISC_CONFIG_GATEWAYS) { /* Use the first gateway as ordered in router discovery cache. */ @@ -4510,6 +4513,7 @@ act_stage3_ip6_config_start (NMDevice *self, if (ret == NM_ACT_STAGE_RETURN_SUCCESS) { /* New blank config; LL address is already in priv->ext_ip6_config */ *out_config = nm_ip6_config_new (); + nm_ip6_config_set_ifindex (*out_config, nm_device_get_ifindex (self)); g_assert (*out_config); } } else if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) == 0) { @@ -4522,6 +4526,7 @@ act_stage3_ip6_config_start (NMDevice *self, } else if (strcmp (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL) == 0) { /* New blank config */ *out_config = nm_ip6_config_new (); + nm_ip6_config_set_ifindex (*out_config, nm_device_get_ifindex (self)); g_assert (*out_config); ret = NM_ACT_STAGE_RETURN_SUCCESS; diff --git a/src/devices/wwan/nm-device-modem.c b/src/devices/wwan/nm-device-modem.c index 8169c8894c..36c1323cfd 100644 --- a/src/devices/wwan/nm-device-modem.c +++ b/src/devices/wwan/nm-device-modem.c @@ -198,8 +198,10 @@ modem_ip6_config_result (NMModem *modem, /* Re-enable IPv6 on the interface */ nm_device_ipv6_sysctl_set (device, "disable_ipv6", "0"); - if (config) + if (config) { + nm_ip6_config_set_ifindex (config, nm_device_get_ifindex (device)); nm_device_set_wwan_ip6_config (device, config); + } if (do_slaac == FALSE) { if (got_config) diff --git a/src/dhcp-manager/nm-dhcp-client.c b/src/dhcp-manager/nm-dhcp-client.c index 21578e8ade..8a451a7c93 100644 --- a/src/dhcp-manager/nm-dhcp-client.c +++ b/src/dhcp-manager/nm-dhcp-client.c @@ -758,7 +758,8 @@ nm_dhcp_client_handle_event (gpointer unused, g_warn_if_fail (g_hash_table_size (str_options)); if (g_hash_table_size (str_options)) { if (priv->ipv6) { - ip_config = (GObject *) nm_dhcp_utils_ip6_config_from_options (priv->iface, + ip_config = (GObject *) nm_dhcp_utils_ip6_config_from_options (priv->ifindex, + priv->iface, str_options, priv->priority, priv->info_only); diff --git a/src/dhcp-manager/nm-dhcp-utils.c b/src/dhcp-manager/nm-dhcp-utils.c index e6b8cba499..15635fb5b1 100644 --- a/src/dhcp-manager/nm-dhcp-utils.c +++ b/src/dhcp-manager/nm-dhcp-utils.c @@ -592,7 +592,8 @@ ip6_add_domain_search (gpointer data, gpointer user_data) } NMIP6Config * -nm_dhcp_utils_ip6_config_from_options (const char *iface, +nm_dhcp_utils_ip6_config_from_options (int ifindex, + const char *iface, GHashTable *options, guint32 priority, gboolean info_only) @@ -617,6 +618,7 @@ nm_dhcp_utils_ip6_config_from_options (const char *iface, } ip6_config = nm_ip6_config_new (); + nm_ip6_config_set_ifindex (ip6_config, ifindex); str = g_hash_table_lookup (options, "max_life"); if (str) { diff --git a/src/dhcp-manager/nm-dhcp-utils.h b/src/dhcp-manager/nm-dhcp-utils.h index d9af46a58a..42cf900f2a 100644 --- a/src/dhcp-manager/nm-dhcp-utils.h +++ b/src/dhcp-manager/nm-dhcp-utils.h @@ -29,7 +29,8 @@ NMIP4Config *nm_dhcp_utils_ip4_config_from_options (int ifindex, GHashTable *options, guint priority); -NMIP6Config *nm_dhcp_utils_ip6_config_from_options (const char *iface, +NMIP6Config *nm_dhcp_utils_ip6_config_from_options (int ifindex, + const char *iface, GHashTable *options, guint priority, gboolean info_only); diff --git a/src/nm-iface-helper.c b/src/nm-iface-helper.c index 7aad9bb5f8..8475e17c2c 100644 --- a/src/nm-iface-helper.c +++ b/src/nm-iface-helper.c @@ -137,6 +137,7 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, gpointer user_da } ip6_config = nm_ip6_config_new (); + nm_ip6_config_set_ifindex (ip6_config, ifindex); if (changed & NM_RDISC_CONFIG_GATEWAYS) { /* Use the first gateway as ordered in router discovery cache. */ @@ -232,6 +233,7 @@ rdisc_config_changed (NMRDisc *rdisc, NMRDiscConfigMap changed, gpointer user_da if (last_config) { g_object_unref (last_config); last_config = nm_ip6_config_new (); + nm_ip6_config_set_ifindex (last_config, ifindex); nm_ip6_config_replace (last_config, ip6_config, NULL); } } diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c index 0907a0f3df..03b3fca319 100644 --- a/src/nm-ip6-config.c +++ b/src/nm-ip6-config.c @@ -50,6 +50,7 @@ typedef struct { GPtrArray *domains; GPtrArray *searches; guint32 mss; + int ifindex; } NMIP6ConfigPrivate; @@ -98,6 +99,17 @@ nm_ip6_config_get_dbus_path (const NMIP6Config *config) /******************************************************************/ +void +nm_ip6_config_set_ifindex (NMIP6Config *config, int ifindex) +{ + NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config); + + g_return_if_fail (priv->ifindex == 0); + g_assert (priv->routes->len == 0); + + priv->ifindex = ifindex; +} + static gboolean same_prefix (const struct in6_addr *address1, const struct in6_addr *address2, int plen) { @@ -304,6 +316,7 @@ nm_ip6_config_capture (int ifindex, gboolean capture_resolv_conf, NMSettingIP6Co config = nm_ip6_config_new (); priv = NM_IP6_CONFIG_GET_PRIVATE (config); + nm_ip6_config_set_ifindex (config, ifindex); g_array_unref (priv->addresses); g_array_unref (priv->routes); @@ -796,6 +809,12 @@ nm_ip6_config_replace (NMIP6Config *dst, const NMIP6Config *src, gboolean *relev g_object_freeze_notify (G_OBJECT (dst)); + /* ifindex */ + if (src_priv->ifindex != dst_priv->ifindex) { + nm_ip6_config_set_ifindex (dst, src_priv->ifindex); + has_minor_changes = TRUE; + } + /* never_default */ if (src_priv->never_default != dst_priv->never_default) { dst_priv->never_default = src_priv->never_default; @@ -1167,6 +1186,7 @@ nm_ip6_config_add_route (NMIP6Config *config, const NMPlatformIP6Route *new) g_return_if_fail (new != NULL); g_return_if_fail (new->plen > 0); + g_assert (priv->ifindex); for (i = 0; i < priv->routes->len; i++ ) { NMPlatformIP6Route *item = &g_array_index (priv->routes, NMPlatformIP6Route, i); @@ -1183,6 +1203,7 @@ nm_ip6_config_add_route (NMIP6Config *config, const NMPlatformIP6Route *new) } g_array_append_val (priv->routes, *new); + g_array_index (priv->routes, NMPlatformIP6Route, priv->routes->len - 1).ifindex = priv->ifindex; NOTIFY: _NOTIFY (config, PROP_ROUTE_DATA); _NOTIFY (config, PROP_ROUTES); diff --git a/src/nm-ip6-config.h b/src/nm-ip6-config.h index f1d2dc8dd9..263a3b9e47 100644 --- a/src/nm-ip6-config.h +++ b/src/nm-ip6-config.h @@ -58,6 +58,8 @@ GType nm_ip6_config_get_type (void); NMIP6Config * nm_ip6_config_new (void); +void nm_ip6_config_set_ifindex (NMIP6Config *config, int ifindex); + /* D-Bus integration */ void nm_ip6_config_export (NMIP6Config *config); const char * nm_ip6_config_get_dbus_path (const NMIP6Config *config); diff --git a/src/ppp-manager/nm-ppp-manager.c b/src/ppp-manager/nm-ppp-manager.c index 93f5cfaa0a..3f0cc0b9c2 100644 --- a/src/ppp-manager/nm-ppp-manager.c +++ b/src/ppp-manager/nm-ppp-manager.c @@ -546,6 +546,7 @@ impl_ppp_manager_set_ip4_config (NMPPPManager *manager, config = nm_ip4_config_new (); nm_ip4_config_set_ifindex (config, nm_platform_link_get_ifindex (priv->ip_iface)); + memset (&address, 0, sizeof (address)); address.plen = 32; @@ -650,6 +651,7 @@ impl_ppp_manager_set_ip6_config (NMPPPManager *manager, remove_timeout_handler (manager); config = nm_ip6_config_new (); + nm_ip6_config_set_ifindex (config, nm_platform_link_get_ifindex (priv->ip_iface)); memset (&addr, 0, sizeof (addr)); addr.plen = 64; diff --git a/src/tests/test-ip6-config.c b/src/tests/test-ip6-config.c index 9e1d5651d3..bb707e7fdd 100644 --- a/src/tests/test-ip6-config.c +++ b/src/tests/test-ip6-config.c @@ -37,6 +37,7 @@ build_test_config (void) /* Build up the config to subtract */ config = nm_ip6_config_new (); + nm_ip6_config_set_ifindex (config, 1); nm_ip6_config_add_address (config, nmtst_platform_ip6_address ("abcd:1234:4321::cdde", "1:2:3:4::5", 64)); nm_ip6_config_add_route (config, nmtst_platform_ip6_route ("abcd:1234:4321::", 24, "abcd:1234:4321:cdde::2")); @@ -130,7 +131,9 @@ test_compare_with_source (void) NMPlatformIP6Route route; a = nm_ip6_config_new (); + nm_ip6_config_set_ifindex (a, 1); b = nm_ip6_config_new (); + nm_ip6_config_set_ifindex (b, 2); /* Address */ addr = *nmtst_platform_ip6_address ("1122:3344:5566::7788", NULL, 64); @@ -163,6 +166,7 @@ test_add_address_with_source (void) const NMPlatformIP6Address *test_addr; a = nm_ip6_config_new (); + nm_ip6_config_set_ifindex (a, 1); /* Test that a higher priority source is not overwritten */ addr = *nmtst_platform_ip6_address ("1122:3344:5566::7788", NULL, 64); @@ -203,6 +207,7 @@ test_add_route_with_source (void) const NMPlatformIP6Route *test_route; a = nm_ip6_config_new (); + nm_ip6_config_set_ifindex (a, 1); /* Test that a higher priority source is not overwritten */ route = *nmtst_platform_ip6_route ("abcd:1234:4321::", 24, "abcd:1234:4321:cdde::2"); diff --git a/src/vpn-manager/nm-vpn-connection.c b/src/vpn-manager/nm-vpn-connection.c index fc2738ad90..073527122d 100644 --- a/src/vpn-manager/nm-vpn-connection.c +++ b/src/vpn-manager/nm-vpn-connection.c @@ -897,8 +897,10 @@ apply_parent_device_config (NMVpnConnection *connection) vpn4_parent_config = nm_ip4_config_new (); nm_ip4_config_set_ifindex (vpn4_parent_config, priv->ip_ifindex); } - if (priv->ip6_config) + if (priv->ip6_config) { vpn6_parent_config = nm_ip6_config_new (); + nm_ip6_config_set_ifindex (vpn6_parent_config, priv->ip_ifindex); + } if (priv->ip_ifindex <= 0) { /* If the VPN didn't return a network interface, it is a route-based @@ -1339,6 +1341,7 @@ nm_vpn_connection_ip6_config_get (DBusGProxy *proxy, } config = nm_ip6_config_new (); + nm_ip6_config_set_ifindex (config, priv->ip_ifindex); memset (&address, 0, sizeof (address)); address.plen = 128; |