diff options
author | Felix Fietkau <nbd@openwrt.org> | 2011-04-05 03:52:39 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2011-04-05 03:52:39 +0200 |
commit | d3a4844047c7b3c62511a9836a81703b5ee70fc0 (patch) | |
tree | cd25491c58cbba0bebd5f0f17ce155d668528544 | |
parent | b18fb36bd3c7615733c351c99691e1139f386c0c (diff) |
add code for cleaning up unused devices mentioned in the config
-rw-r--r-- | config.c | 1 | ||||
-rw-r--r-- | config/network | 3 | ||||
-rw-r--r-- | device.c | 13 | ||||
-rw-r--r-- | device.h | 2 |
4 files changed, 19 insertions, 0 deletions
@@ -180,6 +180,7 @@ config_init_interfaces(const char *name) if (!strcmp(s->type, "interface")) config_parse_interface(s); } + cleanup_devices(); config_init = false; start_pending_interfaces(); diff --git a/config/network b/config/network index 00c5b51..0a02e89 100644 --- a/config/network +++ b/config/network @@ -12,6 +12,9 @@ config device option ifname "eth0.1 eth0.2" option mtu 1500 +config device + option name dummy + config interface lan option ifname 'br-lan' option proto static @@ -197,3 +197,16 @@ void remove_device_user(struct device_user *dep) dep->dev = NULL; } + +void +cleanup_devices(void) +{ + struct device *dev, *tmp; + + avl_for_each_element_safe(&devices, dev, avl, tmp) { + if (!list_empty(&dev->users)) + continue; + + free_device(dev); + } +} @@ -100,6 +100,8 @@ int claim_device(struct device *dev); void release_device(struct device *dev); int check_device_state(struct device *dev); +void cleanup_devices(void); + struct device *get_vlan_device_chain(const char *ifname, bool create); struct device *bridge_create(const char *name, struct uci_section *s); |