From 4eead7ab8863e9a1f2f25516118ba6be47153da1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=8D=C3=B1igo=20Huguet?= Date: Wed, 11 Mar 2026 10:03:31 +0100 Subject: [PATCH] core: reevaluate ignore-carrier after UDEV's announcement When a new device is hot plugged, matching by MAC doesn't work yet because we haven't set the permanent MAC address in NMDevicePrivate. This seems to be intentional, per the following commit: 7b7c653c4f81 ('device: delay capturing permanent MAC address until UDEV is settled') Reevaluate ignore-carrier after UDEV's announcement (unsetting of the PLATFORM_INIT unmanaged flag) so it gets its correct value. The rest of configurations that can be set with a `match-device` condition are evaluated when the device has already moved at least to a managed state, so they don't have this problem. Closes https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1907 --- src/core/devices/nm-device.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/core/devices/nm-device.c b/src/core/devices/nm-device.c index 919ec82e12..f99bde616c 100644 --- a/src/core/devices/nm-device.c +++ b/src/core/devices/nm-device.c @@ -7883,6 +7883,12 @@ device_link_changed(gpointer user_data) NM_UNMANAGED_PLATFORM_INIT, NM_UNMAN_FLAG_OP_SET_MANAGED, nm_device_get_manage_reason_external(self)); + + /* Now that we got UDEV's announcement we need to check ignore-carrier again. + * This is because the permanent MAC might have been set or changed. If we don't + * recheck we would ignore rules matching by MAC address. */ + priv->ignore_carrier = + nm_config_data_get_ignore_carrier_by_device(nm_config_get_data(nm_config_get()), self); } _dev_unmanaged_check_external_down(self, FALSE, FALSE); @@ -8559,10 +8565,13 @@ realize_start_setup(NMDevice *self, nm_device_update_initial_hw_address(self); nm_device_update_permanent_hw_address(self, FALSE); - /* Note: initial hardware address must be read before calling get_ignore_carrier() */ + /* Note: initial hardware address must be read before calling get_ignore_carrier(). We'll + * need to recheck ignore_carrier again after UDEV's announcement, as the permanent MAC + * address may be set by UDEV. */ config = nm_config_get(); priv->ignore_carrier = nm_config_data_get_ignore_carrier_by_device(nm_config_get_data(config), self); + if (!priv->config_changed_id) { priv->config_changed_id = g_signal_connect(config, NM_CONFIG_SIGNAL_CONFIG_CHANGED,