diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index dd8c6d96fb..3161560ee9 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -2624,6 +2624,15 @@ set_interface_flags_full(NMDevice * self, return TRUE; } +static gboolean +set_interface_flags(NMDevice *self, NMDeviceInterfaceFlags interface_flags, gboolean set) +{ + return set_interface_flags_full(self, + interface_flags, + set ? interface_flags : NM_DEVICE_INTERFACE_FLAG_NONE, + TRUE); +} + void nm_device_assume_state_get(NMDevice * self, gboolean * out_assume_state_guess_assume, @@ -4936,7 +4945,9 @@ nm_device_update_dynamic_ip_setup(NMDevice *self) priv->lldp_listener, error->message); g_clear_error(&error); - } + set_interface_flags(self, NM_DEVICE_INTERFACE_FLAG_LLDP_CLIENT_ENABLED, FALSE); + } else + set_interface_flags(self, NM_DEVICE_INTERFACE_FLAG_LLDP_CLIENT_ENABLED, TRUE); } } @@ -8250,8 +8261,10 @@ lldp_init(NMDevice *self, gboolean restart) gs_free_error GError *error = NULL; if (priv->lldp_listener) { - if (restart && nm_lldp_listener_is_running(priv->lldp_listener)) + if (restart && nm_lldp_listener_is_running(priv->lldp_listener)) { nm_lldp_listener_stop(priv->lldp_listener); + set_interface_flags(self, NM_DEVICE_INTERFACE_FLAG_LLDP_CLIENT_ENABLED, FALSE); + } } else { priv->lldp_listener = nm_lldp_listener_new(); g_signal_connect(priv->lldp_listener, @@ -8261,9 +8274,10 @@ lldp_init(NMDevice *self, gboolean restart) } if (!nm_lldp_listener_is_running(priv->lldp_listener)) { - if (nm_lldp_listener_start(priv->lldp_listener, nm_device_get_ifindex(self), &error)) + if (nm_lldp_listener_start(priv->lldp_listener, nm_device_get_ifindex(self), &error)) { _LOGD(LOGD_DEVICE, "LLDP listener %p started", priv->lldp_listener); - else { + set_interface_flags(self, NM_DEVICE_INTERFACE_FLAG_LLDP_CLIENT_ENABLED, TRUE); + } else { _LOGD(LOGD_DEVICE, "LLDP listener %p could not be started: %s", priv->lldp_listener, @@ -8271,8 +8285,10 @@ lldp_init(NMDevice *self, gboolean restart) } } } else { - if (priv->lldp_listener) + if (priv->lldp_listener) { nm_lldp_listener_stop(priv->lldp_listener); + set_interface_flags(self, NM_DEVICE_INTERFACE_FLAG_LLDP_CLIENT_ENABLED, FALSE); + } } } @@ -15958,8 +15974,10 @@ nm_device_cleanup(NMDevice *self, NMDeviceStateReason reason, CleanupType cleanu FALSE, NM_DEVICE_STATE_REASON_CONNECTION_ASSUMED); - if (priv->lldp_listener) + if (priv->lldp_listener) { nm_lldp_listener_stop(priv->lldp_listener); + set_interface_flags(self, NM_DEVICE_INTERFACE_FLAG_LLDP_CLIENT_ENABLED, FALSE); + } nm_device_update_metered(self); @@ -18400,6 +18418,7 @@ dispose(GObject *object) G_CALLBACK(lldp_neighbors_changed), self); nm_lldp_listener_stop(priv->lldp_listener); + set_interface_flags(self, NM_DEVICE_INTERFACE_FLAG_LLDP_CLIENT_ENABLED, FALSE); g_clear_object(&priv->lldp_listener); } diff --git a/src/libnm-core-aux-intern/nm-libnm-core-utils.h b/src/libnm-core-aux-intern/nm-libnm-core-utils.h index 346398fd6d..d32af46fce 100644 --- a/src/libnm-core-aux-intern/nm-libnm-core-utils.h +++ b/src/libnm-core-aux-intern/nm-libnm-core-utils.h @@ -100,7 +100,8 @@ gboolean nm_utils_vlan_priority_map_parse_str(NMVlanPriorityMap map_type, #define _NM_DEVICE_INTERFACE_FLAG_ALL \ ((NMDeviceInterfaceFlags)(NM_DEVICE_INTERFACE_FLAG_UP | NM_DEVICE_INTERFACE_FLAG_LOWER_UP \ - | NM_DEVICE_INTERFACE_FLAG_CARRIER)) + | NM_DEVICE_INTERFACE_FLAG_CARRIER \ + | NM_DEVICE_INTERFACE_FLAG_LLDP_CLIENT_ENABLED)) /*****************************************************************************/ diff --git a/src/libnm-core-public/nm-dbus-interface.h b/src/libnm-core-public/nm-dbus-interface.h index 295a22a177..0cc41190d2 100644 --- a/src/libnm-core-public/nm-dbus-interface.h +++ b/src/libnm-core-public/nm-dbus-interface.h @@ -1186,6 +1186,8 @@ typedef enum { /*< flags >*/ * @NM_DEVICE_INTERFACE_FLAG_CARRIER: the interface has carrier. In most * cases this is equal to the value of @NM_DEVICE_INTERFACE_FLAG_LOWER_UP. * However some devices have a non-standard carrier detection mechanism. + * @NM_DEVICE_INTERFACE_FLAG_LLDP_CLIENT_ENABLED: the flag to indicate device + * LLDP status. Since: 1.32. * * Flags for a network interface. * @@ -1197,7 +1199,8 @@ typedef enum { /*< flags >*/ NM_DEVICE_INTERFACE_FLAG_UP = 0x1, NM_DEVICE_INTERFACE_FLAG_LOWER_UP = 0x2, /* NM-specific flags */ - NM_DEVICE_INTERFACE_FLAG_CARRIER = 0x10000, + NM_DEVICE_INTERFACE_FLAG_CARRIER = 0x10000, + NM_DEVICE_INTERFACE_FLAG_LLDP_CLIENT_ENABLED = 0x20000, } NMDeviceInterfaceFlags; /**