[OpenWrt-Devel] [PATCH 2/2] netifd: Don't call set_state for external device in device_claim

Hans Dedecker dedeckeh at gmail.com
Tue Sep 1 08:43:58 EDT 2015


The function set_state disable is not called for external devices in device_release
which means for external vlan/macvlan devices they won't be deleted.
As a result of this the set_state enable call for external devices by device_claim fails
as vlan/macvlan devices cannot be created since the device already exists in the kernel.
Therefore move the external device check from device_set_state to device_claim so
external vlan/macvlan devices are not created again and can also be external.

Signed-off-by: Hans Dedecker <dedeckeh at gmail.com>
---
 device.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/device.c b/device.c
index 0d73138..21b436f 100644
--- a/device.c
+++ b/device.c
@@ -81,9 +81,6 @@ static int set_device_state(struct device *dev, bool state)
 			return -1;
 	}
 
-	if (dev->external)
-		return 0;
-
 	if (state)
 		system_if_up(dev);
 	else
@@ -324,7 +321,7 @@ void device_broadcast_event(struct device *dev, enum device_event ev)
 int device_claim(struct device_user *dep)
 {
 	struct device *dev = dep->dev;
-	int ret;
+	int ret = 0;
 
 	if (dep->claimed)
 		return 0;
@@ -335,7 +332,9 @@ int device_claim(struct device_user *dep)
 		return 0;
 
 	device_broadcast_event(dev, DEV_EVENT_SETUP);
-	ret = dev->set_state(dev, true);
+	if (!dev->external)
+		ret = dev->set_state(dev, true);
+
 	if (ret == 0)
 		device_broadcast_event(dev, DEV_EVENT_UP);
 	else {
-- 
1.9.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list