[OpenWrt-Devel] [PATCH] netifd:Make sure interface device config is also cached

Hans Dedecker dedeckeh at gmail.com
Wed Mar 18 11:54:48 EDT 2015


Fixes issue interface device config is not applied in some cases. 
As the interface device config was applied but not always cached;
an interface device config diff was not always detected.

Simplify device config setting by exposing as api only device_apply_config

Signed-off-by: Hans Dedecker <dedeckeh at gmail.com>
---
 config.c    | 2 +-
 device.c    | 2 +-
 device.h    | 3 ---
 interface.c | 6 +++---
 tunnel.c    | 2 +-
 5 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/config.c b/config.c
index b0607dd..132ec43 100644
--- a/config.c
+++ b/config.c
@@ -137,7 +137,7 @@ config_parse_interface(struct uci_section *s, bool alias)
 		return;
 
 	if (iface->device_config || dev->settings.flags)
-		device_set_config(dev, dev->type, b.head);
+		device_apply_config(dev, dev->type, b.head);
 	return;
 error_free_config:
 	free(config);
diff --git a/device.c b/device.c
index 556d9fc..2706473 100644
--- a/device.c
+++ b/device.c
@@ -596,7 +596,7 @@ device_init_pending(void)
 	}
 }
 
-enum dev_change_type
+static enum dev_change_type
 device_set_config(struct device *dev, const struct device_type *type,
 		  struct blob_attr *attr)
 {
diff --git a/device.h b/device.h
index 6418f16..cddb340 100644
--- a/device.h
+++ b/device.h
@@ -194,9 +194,6 @@ void device_init_settings(struct device *dev, struct blob_attr **tb);
 void device_init_pending(void);
 
 enum dev_change_type
-device_set_config(struct device *dev, const struct device_type *type,
-		  struct blob_attr *attr);
-enum dev_change_type
 device_apply_config(struct device *dev, const struct device_type *type,
 		    struct blob_attr *config);
 
diff --git a/interface.c b/interface.c
index 72599e6..444f3ac 100644
--- a/interface.c
+++ b/interface.c
@@ -918,11 +918,11 @@ interface_handle_link(struct interface *iface, const char *name, bool add, bool
 	}
 
 	if (add) {
-		device_set_present(dev, true);
 		if (iface->device_config && dev->default_config)
-			device_set_config(dev, dev->type, iface->config);
+			device_apply_config(dev, dev->type, iface->config);
+
+		device_set_present(dev, true);
 
-		system_if_apply_settings(dev, &dev->settings, dev->settings.flags);
 		ret = interface_add_link(iface, dev, link_ext);
 	} else {
 		ret = interface_remove_link(iface, dev);
diff --git a/tunnel.c b/tunnel.c
index cdb83f0..aa670a3 100644
--- a/tunnel.c
+++ b/tunnel.c
@@ -72,7 +72,7 @@ tunnel_create(const char *name, struct blob_attr *attr)
 	device_init(dev, &tunnel_device_type, name);
 	tun->set_state = dev->set_state;
 	dev->set_state = tunnel_set_state;
-	device_set_config(dev, &tunnel_device_type, attr);
+	device_apply_config(dev, &tunnel_device_type, attr);
 	device_set_present(dev, true);
 
 	return dev;
-- 
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