From ab8ca2dbe269952fcecef05c17b43b6bf038dc55 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Mon, 24 Jun 2013 22:43:33 -0500 Subject: [PATCH] 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. --- src/devices/nm-device.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index 5ffb8ea5f..db0fecb64 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -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