diff options
author | Felix Fietkau <nbd@openwrt.org> | 2011-03-29 01:41:33 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2011-03-29 01:41:33 +0200 |
commit | 8865846b6bb679ef917d3546113790978eb9f1a0 (patch) | |
tree | 774081c0d48d9dd65d6442cef244e4f0773e036d /interface.c | |
parent | b6341342b67a7ccb89e909caf7e134a86ce6b701 (diff) |
fix handling duplicate IFS_DOWN events
Diffstat (limited to 'interface.c')
-rw-r--r-- | interface.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/interface.c b/interface.c index 78cfe12..e12d356 100644 --- a/interface.c +++ b/interface.c @@ -59,6 +59,13 @@ interface_event(struct interface *iface, enum interface_event ev) /* TODO */ } +static void +mark_interface_down(struct interface *iface) +{ + release_device(iface->main_dev.dev); + iface->state = IFS_DOWN; +} + static int __set_interface_up(struct interface *iface) { @@ -69,20 +76,17 @@ __set_interface_up(struct interface *iface) ret = claim_device(iface->main_dev.dev); if (ret) - goto out; + return ret; iface->state = IFS_SETUP; ret = iface->proto->handler(iface->proto, PROTO_CMD_SETUP, false); - if (ret) - goto release; + if (ret) { + mark_interface_down(iface); + return ret; + } return 0; -release: - release_device(iface->main_dev.dev); -out: - iface->state = IFS_DOWN; - return ret; } static void @@ -145,7 +149,10 @@ interface_proto_cb(struct interface_proto_state *state, enum interface_proto_eve interface_event(iface, IFEV_UP); break; case IFPEV_DOWN: - iface->state = IFS_DOWN; + if (iface->state == IFS_DOWN) + return; + + mark_interface_down(iface); break; } } |