device: renew dhcp leases on awake for software devices master
authorNikolay Martynov <mar.kolya@gmail.com>
Sat, 26 Mar 2016 05:26:36 +0000 (01:26 -0400)
committerThomas Haller <thaller@redhat.com>
Thu, 31 Mar 2016 14:31:34 +0000 (16:31 +0200)
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
src/devices/nm-device.h
src/nm-manager.c

index e808bf0..5085833 100644 (file)
@@ -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;
 }
index ce715e6..f5983c7 100644 (file)
@@ -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
 
index 1744632..1694b43 100644 (file)
@@ -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.