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 4d9aa8a..4ad89f5 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;
        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);
        interface_proto_event(iface->proto, PROTO_CMD_TEARDOWN, force);
        if (force)
                interface_flush_state(iface);
index 2239b49..8238c0d 100644 (file)
@@ -79,6 +79,9 @@ proto_shell_handler(struct interface_proto_state *proto,
                if (state->sm == S_TEARDOWN)
                        return 0;
 
                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);
                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);
        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);
        netifd_kill_process(&state->script_task);
        netifd_kill_process(&state->proto_task);
        free(state->config);