From: Michael Tremer Date: Sun, 11 Jun 2023 11:07:25 +0000 (+0000) Subject: link: Skip uevent when the device is renaming X-Git-Url: http://git.ipfire.org/?p=network.git;a=commitdiff_plain;h=7d01b16d6ae3502e48bf99b572be627a2d8a2eac link: Skip uevent when the device is renaming Signed-off-by: Michael Tremer --- diff --git a/src/networkd/link.c b/src/networkd/link.c index 8ba5da59..cb79dd28 100644 --- a/src/networkd/link.c +++ b/src/networkd/link.c @@ -613,7 +613,42 @@ ERROR: // uevent +static int nw_link_uevent_device_is_renaming(sd_device* device) { + int r; + + r = sd_device_get_property_value(device, "ID_RENAMING", NULL); + switch (r) { + case -ENOENT: + return 0; + + case 0: + return 1; + + default: + return r; + } +} + int nw_link_handle_uevent(nw_link* link, sd_device* device, sd_device_action_t action) { + int r; + + // Check if the device is renaming + r = nw_link_uevent_device_is_renaming(device); + switch (r) { + // Not renaming - Fallthrough + case 0: + break; + + case 1: + DEBUG("Device is renaming, skipping initialization\n"); + return 0; + + default: + ERROR("Could not determine whether the device is being renamed: %s\n", + strerror(-r)); + return r; + } + // We need to remove or replace the stored device as it is now outdated if (link->device) { sd_device_unref(link->device);