From 81aaf0ff93c002dafd5198d677b802c1b161f757 Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Tue, 25 Sep 2018 09:51:06 +0200 Subject: [PATCH] device: fix updating device information after link change device_link_changed() can't use nm_device_update_from_platform_link() to update the device private fields because the latter overwrites priv->iface and priv->up, and so the checks below as: if (info.name[0] && strcmp (priv->iface, info.name) != 0) { and: was_up = priv->up; priv->up = NM_FLAGS_HAS (info.n_ifi_flags, IFF_UP); ... if (priv->up && !was_up) { never succeed. Fixes: d7f7725ae8c965756902bd492bf2cf0834319548 (cherry picked from commit 46ed756112f38f30f996bb7425514bc59b6f5360) --- src/devices/nm-device.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index b6ff6b5d96..cd9600ef73 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -3578,6 +3578,7 @@ device_link_changed (NMDevice *self) gboolean ip_ifname_changed = FALSE; nm_auto_nmpobj const NMPObject *pllink_keep_alive = NULL; const NMPlatformLink *pllink; + const char *str; int ifindex; gboolean was_up; gboolean update_unmanaged_specs = FALSE; @@ -3592,7 +3593,23 @@ device_link_changed (NMDevice *self) pllink_keep_alive = nmp_object_ref (NMP_OBJECT_UP_CAST (pllink)); - nm_device_update_from_platform_link (self, pllink); + str = nm_platform_link_get_udi (nm_device_get_platform (self), pllink->ifindex); + if (!nm_streq0 (str, priv->udi)) { + g_free (priv->udi); + priv->udi = g_strdup (str); + _notify (self, PROP_UDI); + } + + if (!nm_streq0 (pllink->driver, priv->driver)) { + g_free (priv->driver); + priv->driver = g_strdup (pllink->driver); + _notify (self, PROP_DRIVER); + } + + _set_mtu (self, pllink->mtu); + + if (ifindex == nm_device_get_ip_ifindex (self)) + _stats_update_counters_from_pllink (self, pllink); had_hw_addr = (priv->hw_addr != NULL); nm_device_update_hw_address (self);