core: fix flushing of routes and updating legacy IPv4 address property

We can't clear the ip_iface until after all the routes and addresses
are updated and flushed, because the addresses and routes are
identified by the ip_iface, and if we clear the ip_iface, we don't
know which things to flush anymore.

Example: 'hso' modems have an 'iface' of 'ttyHS4' (a serial port) and
an ip_iface of 'hso0' (an ethernet port).  If we clear the ip_iface too
soon, then ip_iface/ip_ifindex is invalid and thus NM has no idea what
to remove, and the default route pointing to 'hso0' sticks around.

This could also happen with other devices where the ip_iface is
different than the iface, like modems, ADSL/ATM devices, etc.
This commit is contained in:
Dan Williams
2013-06-24 22:43:33 -05:00
parent c70ffd6f9b
commit ab8ca2dbe2

View File

@@ -4080,8 +4080,6 @@ nm_device_deactivate (NMDevice *self, NMDeviceStateReason reason)
dnsmasq_cleanup (self);
aipd_cleanup (self);
nm_device_set_ip_iface (self, NULL);
/* Turn off router advertisements until they are needed */
if (priv->ip6_accept_ra_path)
nm_utils_do_sysctl (priv->ip6_accept_ra_path, "0");
@@ -4111,11 +4109,20 @@ nm_device_deactivate (NMDevice *self, NMDeviceStateReason reason)
nm_system_iface_flush_routes (ifindex, family);
nm_system_iface_flush_addresses (ifindex, family);
}
_update_ip4_address (self);
/* Clean up nameservers and addresses */
nm_device_set_ip4_config (self, NULL, FALSE, &ignored);
nm_device_set_ip6_config (self, NULL, FALSE, &ignored);
/* Clear legacy IPv4 address property */
priv->ip4_address = 0;
g_object_notify (G_OBJECT (self), NM_DEVICE_IP4_ADDRESS);
/* Only clear ip_iface after flushing all routes and addreses, since
* those are identified by ip_iface, not by iface (which might be a tty
* or ATM device).
*/
nm_device_set_ip_iface (self, NULL);
}
static void