vlan devices can be switched up more than once, in which case this error will
be traced:
  system_vlandev_add(1608): Error adding vlandev 'vlan_wan' over 'ptm0': -6
and interface that use this device will fail to start with error code
DEVICE_CLAIM_FAILED.

This change will prevent calling system_vlandev_add() when vlan device
was already created, thus solving the root cause of the issue.

Signed-off-by: Alin Nastac <alin.nas...@gmail.com>
---
 vlandev.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/vlandev.c b/vlandev.c
index 31b82b1..4780ca3 100644
--- a/vlandev.c
+++ b/vlandev.c
@@ -163,9 +163,14 @@ vlandev_set_up(struct vlandev_device *mvdev)
        if (ret < 0)
                return ret;
 
-       ret = system_vlandev_add(&mvdev->dev, mvdev->parent.dev, 
&mvdev->config);
-       if (ret < 0)
-               goto release;
+       if (mvdev->dev.ifindex && mvdev->dev.ifindex != 
system_if_resolve(&mvdev->dev))
+               mvdev->dev.ifindex = 0; /* previous instance of this vlan 
device was destroyed */
+
+       if (!mvdev->dev.ifindex) {
+               ret = system_vlandev_add(&mvdev->dev, mvdev->parent.dev, 
&mvdev->config);
+               if (ret < 0)
+                       goto release;
+       }
 
        ret = mvdev->set_state(&mvdev->dev, true);
        if (ret)
-- 
2.34.1


_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to