diff options
author | Felix Fietkau <nbd@openwrt.org> | 2011-10-19 03:20:09 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2011-10-19 03:20:09 +0200 |
commit | d16871c7a55370174eb672edee24feade74cd37e (patch) | |
tree | 39995e27e86f9efbf101a8b9f5a23e7d9821bae8 /interface.c | |
parent | ccca61c97d460d73f29750abdf38cea20ac440f3 (diff) |
rework device hotplug handling some more, add device_lock/device_unlock to prevent use-after-free bugs
Diffstat (limited to 'interface.c')
-rw-r--r-- | interface.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/interface.c b/interface.c index 8e42f21..befb194 100644 --- a/interface.c +++ b/interface.c @@ -88,13 +88,19 @@ interface_event(struct interface *iface, enum interface_event ev) } static void -mark_interface_down(struct interface *iface) +interface_flush_state(struct interface *iface) { interface_clear_dns(iface); vlist_flush_all(&iface->proto_addr); vlist_flush_all(&iface->proto_route); if (iface->main_dev.dev) device_release(&iface->main_dev); +} + +static void +mark_interface_down(struct interface *iface) +{ + interface_flush_state(iface); iface->state = IFS_DOWN; } @@ -134,6 +140,8 @@ __interface_set_down(struct interface *iface, bool force) iface->state = IFS_TEARDOWN; interface_event(iface, IFEV_DOWN); interface_proto_event(iface->proto, PROTO_CMD_TEARDOWN, force); + if (force) + interface_flush_state(iface); } static void @@ -208,7 +216,6 @@ interface_cleanup(struct interface *iface) { struct interface_user *dep, *tmp; - iface->hotplug_dev = false; list_for_each_entry_safe(dep, tmp, &iface->users, list) interface_remove_user(dep); |