From 28e9ec499a7517f35cc5093e9b545302094e55d4 Mon Sep 17 00:00:00 2001 From: Nikolay Martynov Date: Sat, 26 Mar 2016 01:26:36 -0400 Subject: [PATCH] device: renew dhcp leases on awake for software devices This makes sure that devices like bond get their dhcp renewed [thaller@redhat.com: original patch modified to rename now-public function update_dynamic_ip_setup()] https://bugzilla.gnome.org/show_bug.cgi?id=764398 --- src/devices/nm-device.c | 16 ++++++++++------ src/devices/nm-device.h | 1 + src/nm-manager.c | 7 ++++++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index e808bf07a..50858333a 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -1238,14 +1238,18 @@ set_unmanaged_external_down (NMDevice *self) NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED); } -static void -update_dynamic_ip_setup (NMDevice *self) +void +nm_device_update_dynamic_ip_setup (NMDevice *self) { - NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); + NMDevicePrivate *priv; GError *error; gconstpointer addr; size_t addr_length; + g_return_if_fail (NM_IS_DEVICE (self)); + + priv = NM_DEVICE_GET_PRIVATE (self); + g_hash_table_remove_all (priv->ip6_saved_properties); if (priv->dhcp4_client) { @@ -1335,7 +1339,7 @@ carrier_changed (NMDevice *self, gboolean carrier) * tagged for carrier ignore) ensure that when the carrier appears we * renew DHCP leases and such. */ - update_dynamic_ip_setup (self); + nm_device_update_dynamic_ip_setup (self); } } else { if (priv->state == NM_DEVICE_STATE_UNAVAILABLE) { @@ -1532,7 +1536,7 @@ device_link_changed (NMDevice *self) /* Update DHCP, etc, if needed */ if (ip_ifname_changed) - update_dynamic_ip_setup (self); + nm_device_update_dynamic_ip_setup (self); priv->up = NM_FLAGS_HAS (info.n_ifi_flags, IFF_UP); @@ -1587,7 +1591,7 @@ device_ip_link_changed (NMDevice *self) priv->ip_iface = g_strdup (pllink->name); _notify (self, PROP_IP_IFACE); - update_dynamic_ip_setup (self); + nm_device_update_dynamic_ip_setup (self); } return G_SOURCE_REMOVE; } diff --git a/src/devices/nm-device.h b/src/devices/nm-device.h index ce715e68d..f5983c727 100644 --- a/src/devices/nm-device.h +++ b/src/devices/nm-device.h @@ -564,6 +564,7 @@ void nm_device_reactivate_ip6_config (NMDevice *device, void nm_device_update_hw_address (NMDevice *self); void nm_device_update_initial_hw_address (NMDevice *self); +void nm_device_update_dynamic_ip_setup (NMDevice *self); G_END_DECLS diff --git a/src/nm-manager.c b/src/nm-manager.c index 1744632d8..1694b4324 100644 --- a/src/nm-manager.c +++ b/src/nm-manager.c @@ -3897,8 +3897,13 @@ do_sleep_wake (NMManager *self, gboolean sleeping_changed) NMDevice *device = NM_DEVICE (iter->data); guint i; - if (nm_device_is_software (device)) + if (nm_device_is_software (device)) { + /* We do not manage/unmanage software devices but + * their dhcp leases could have gone stale so we need + * to renew them */ + nm_device_update_dynamic_ip_setup (device); continue; + } /* enable/disable wireless devices since that we don't respond * to killswitch changes during sleep. -- 2.17.1