netifd: Reload proto on topology change
[project/netifd.git] / proto-shell.c
index 6bbfe10..de1b084 100644 (file)
@@ -158,6 +158,11 @@ proto_shell_handler(struct interface_proto_state *proto,
                action = "setup";
                state->last_error = -1;
                proto_shell_clear_host_dep(state);
+               state->sm = S_SETUP;
+       } else if (cmd == PROTO_CMD_RENEW) {
+               if (!(handler->proto.flags & PROTO_FLAG_RENEW_AVAILABLE))
+                       return 0;
+               action = "renew";
        } else {
                if (state->sm == S_TEARDOWN)
                        return 0;
@@ -479,15 +484,15 @@ proto_shell_update_link(struct proto_shell_state *state, struct blob_attr *data,
        if ((cur = tb[NOTIFY_DNS_SEARCH]))
                interface_add_dns_search_list(&iface->proto_ip, cur);
 
+       if ((cur = tb[NOTIFY_DATA]))
+               proto_shell_parse_data(state->proto.iface, cur);
+
        interface_update_complete(state->proto.iface);
 
        if (!keep)
                state->proto.proto_event(&state->proto, IFPEV_UP);
        state->sm = S_IDLE;
 
-       if ((cur = tb[NOTIFY_DATA]))
-               proto_shell_parse_data(state->proto.iface, cur);
-
        return 0;
 }
 
@@ -760,6 +765,10 @@ proto_shell_add_handler(const char *script, const char *name, json_object *obj)
        if (tmp && json_object_get_boolean(tmp))
                handler->proto.flags |= PROTO_FLAG_INIT_AVAILABLE;
 
+       tmp = json_get_field(obj, "renew-handler", json_type_boolean);
+       if (tmp && json_object_get_boolean(tmp))
+               handler->proto.flags |= PROTO_FLAG_RENEW_AVAILABLE;
+
        config = json_get_field(obj, "config", json_type_array);
        if (config)
                handler->config_buf = netifd_handler_parse_config(&handler->config, config);
@@ -768,7 +777,7 @@ proto_shell_add_handler(const char *script, const char *name, json_object *obj)
        add_proto_handler(proto);
 }
 
-static void __init proto_shell_init(void)
+void proto_shell_init(void)
 {
        proto_fd = netifd_open_subdir("proto");
        if (proto_fd < 0)