[LEDE-DEV] [PATCH netifd 2/3] device: Fix dotted vlan interface staying down

Hans Dedecker dedeckeh at gmail.com
Mon Jun 6 03:03:42 PDT 2016


Using the config below a dotted vlan interface stays down as get_vlan_device
does not find the device due to the aliased device stacked on top of the base
device.
As all devices; aliased devices being the exception; are in the device list
use device_find to find the device when setting the link state

config interface 'test'
    option proto 'static'
    option ipaddr '192.168.2.1'
    option netmask '255.255.255.0'

config interface 'test2'
    option ifname '@test.1'
    option proto 'dhcp'

Signed-off-by: Hans Dedecker <dedeckeh at gmail.com>
---
This fixes the issue reported in https://lists.openwrt.org/pipermail/openwrt-devel/2016-May/041323.html

 device.c       | 8 ++++++++
 device.h       | 3 ++-
 system-linux.c | 3 ++-
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/device.c b/device.c
index 7149d86..45a9d07 100644
--- a/device.c
+++ b/device.c
@@ -477,6 +477,14 @@ device_create_default(const char *name, bool external)
 }
 
 struct device *
+device_find(const char *name)
+{
+	struct device *dev;
+
+	return avl_find_element(&devices, name, dev, avl);
+}
+
+struct device *
 device_get(const char *name, int create)
 {
 	struct device *dev;
diff --git a/device.h b/device.h
index b069a2b..e13e435 100644
--- a/device.h
+++ b/device.h
@@ -241,7 +241,8 @@ void device_set_default_ps(bool state);
 
 void device_init_virtual(struct device *dev, const struct device_type *type, const char *name);
 int device_init(struct device *iface, const struct device_type *type, const char *ifname);
-void device_cleanup(struct device *iface);
+void device_cleanup(struct device *dev);
+struct device *device_find(const char *name);
 struct device *device_get(const char *name, int create);
 void device_add_user(struct device_user *dep, struct device *iface);
 void device_remove_user(struct device_user *dep);
diff --git a/system-linux.c b/system-linux.c
index 90b0775..98acb9d 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -495,10 +495,11 @@ static int cb_rtnl_event(struct nl_msg *msg, void *arg)
 	if (!nla[IFLA_IFNAME])
 		goto out;
 
-	struct device *dev = device_get(nla_data(nla[IFLA_IFNAME]), false);
+	struct device *dev = device_find(nla_data(nla[IFLA_IFNAME]));
 	if (!dev)
 		goto out;
 
+
 	if (!system_get_dev_sysctl("/sys/class/net/%s/carrier", dev->ifname, buf, sizeof(buf)))
 		link_state = strtoul(buf, NULL, 0);
 
-- 
1.9.1




More information about the Lede-dev mailing list