]> git.ipfire.org Git - network.git/commitdiff
link: Skip uevent when the device is renaming
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 11 Jun 2023 11:07:25 +0000 (11:07 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 11 Jun 2023 11:07:25 +0000 (11:07 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/networkd/link.c

index 8ba5da59521311de667508dcf0d5146074fe9638..cb79dd285c6823d415cab70d45164ee97377f08d 100644 (file)
@@ -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);