interface: fix regression on adding hotplug devices to interfaces
authorFelix Fietkau <nbd@nbd.name>
Sat, 21 Sep 2024 16:26:50 +0000 (18:26 +0200)
committerFelix Fietkau <nbd@nbd.name>
Sat, 21 Sep 2024 16:26:51 +0000 (18:26 +0200)
Adding the same device to an interface again led to a call chain that ended
up removing the device again through device callbacks.
Fix this by only toggling the interface available status when the device is
still the same.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
interface.c

index 69897dc2cd628c1fcf8fe213e9b2fbfe750c384b..923b5b3c9889043e5a3a49cd1626f944bb2dc671 100644 (file)
@@ -1083,8 +1083,14 @@ interface_add_link(struct interface *iface, struct device *dev,
 {
        struct device *mdev = iface->main_dev.dev;
 
-       if (mdev == dev && iface->state == IFS_UP)
+       if (mdev == dev) {
+               if (iface->state != IFS_UP) {
+                       interface_set_available(iface, false);
+                       if (dev->present)
+                               interface_set_available(iface, true);
+               }
                return 0;
+       }
 
        if (iface->main_dev.hotplug)
                interface_set_main_dev(iface, NULL);