properly flush routes and l3 devices when tearing down interfaces
authorFelix Fietkau <nbd@openwrt.org>
Mon, 19 Mar 2012 21:04:03 +0000 (22:04 +0100)
committerFelix Fietkau <nbd@openwrt.org>
Mon, 19 Mar 2012 21:04:03 +0000 (22:04 +0100)
interface.c
proto-shell.c

index 4d9aa8a372fd0f42f02163c6ed34b635a79b2f95..4ad89f538a41328f006d49c49c3576f1348463da 100644 (file)
@@ -120,6 +120,8 @@ __interface_set_down(struct interface *iface, bool force)
        if (iface->state == IFS_UP)
                interface_event(iface, IFEV_DOWN);
        iface->state = IFS_TEARDOWN;
+       interface_ip_flush(&iface->config_ip);
+       interface_ip_flush(&iface->proto_ip);
        interface_proto_event(iface->proto, PROTO_CMD_TEARDOWN, force);
        if (force)
                interface_flush_state(iface);
index 2239b496e2216baec10c498e80eddb4ae7909d19..8238c0d188f7154c11f978bf502975e2307154ec 100644 (file)
@@ -79,6 +79,9 @@ proto_shell_handler(struct interface_proto_state *proto,
                if (state->sm == S_TEARDOWN)
                        return 0;
 
+               if (state->l3_dev.dev)
+                       device_remove_user(&state->l3_dev);
+
                if (state->script_task.uloop.pending) {
                        if (state->sm != S_SETUP_ABORT) {
                                uloop_timeout_set(&state->teardown_timeout, 1000);
@@ -201,6 +204,8 @@ proto_shell_free(struct interface_proto_state *proto)
        struct proto_shell_state *state;
 
        state = container_of(proto, struct proto_shell_state, proto);
+       if (state->l3_dev.dev)
+               device_remove_user(&state->l3_dev);
        netifd_kill_process(&state->script_task);
        netifd_kill_process(&state->proto_task);
        free(state->config);