summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2015-04-18 23:27:15 +0200
committerFelix Fietkau <nbd@openwrt.org>2015-04-18 23:27:15 +0200
commit9cb272f5b12cf23205f361244a9ceef1097d3cba (patch)
treeb75457d8828836c4a44a45408e104f961e02eed9
parentab369490f931712c21913902f8cb9a81fc2767a4 (diff)
downloadnetifd-9cb272f5b12cf23205f361244a9ceef1097d3cba.tar.gz
device: add support for removing interface config on reload
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
-rw-r--r--device.h1
-rw-r--r--interface.c20
2 files changed, 16 insertions, 5 deletions
diff --git a/device.h b/device.h
index 334a238..4b36641 100644
--- a/device.h
+++ b/device.h
@@ -161,6 +161,7 @@ struct device {
bool hidden;
bool current_config;
+ bool iface_config;
bool default_config;
bool wireless;
diff --git a/interface.c b/interface.c
index f72d967..a10cec9 100644
--- a/interface.c
+++ b/interface.c
@@ -520,6 +520,19 @@ interface_alias_cb(struct interface_user *dep, struct interface *iface, enum int
}
static void
+interface_set_device_config(struct interface *iface, struct device *dev)
+{
+ if (!dev || !dev->default_config)
+ return;
+
+ if (!iface->device_config && !dev->iface_config)
+ return;
+
+ dev->iface_config = iface->device_config;
+ device_apply_config(dev, dev->type, iface->config);
+}
+
+static void
interface_claim_device(struct interface *iface)
{
struct interface *parent;
@@ -535,8 +548,7 @@ interface_claim_device(struct interface *iface)
} else if (iface->ifname &&
!(iface->proto_handler->flags & PROTO_FLAG_NODEV)) {
dev = device_get(iface->ifname, true);
- if (dev && dev->default_config && iface->device_config)
- device_apply_config(dev, dev->type, iface->config);
+ interface_set_device_config(iface, dev);
} else {
dev = iface->ext_dev.dev;
}
@@ -943,9 +955,7 @@ interface_handle_link(struct interface *iface, const char *name, bool add, bool
}
if (add) {
- if (iface->device_config && dev->default_config)
- device_apply_config(dev, dev->type, iface->config);
-
+ interface_set_device_config(iface, dev);
device_set_present(dev, true);
ret = interface_add_link(iface, dev, link_ext);