Fix cleanup of interfaces
authorSteven Barth <steven@midlink.org>
Wed, 23 Oct 2013 08:26:40 +0000 (10:26 +0200)
committerSteven Barth <steven@midlink.org>
Wed, 23 Oct 2013 08:26:40 +0000 (10:26 +0200)
src/config.c
src/odhcpd.h

index f008c1229b285b138893d0221b350fe4d67cd75d..6c0954101386b8d23d0620313815f5accc7b9f23 100644 (file)
@@ -273,8 +273,6 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
                iface = calloc(1, sizeof(*iface));
                strncpy(iface->name, name, sizeof(iface->name) - 1);
                list_add(&iface->head, &interfaces);
-       } else if (overwrite) {
-               clean_interface(iface);
        }
 
        const char *ifname = NULL;
@@ -298,9 +296,6 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
 
        iface->inuse = true;
 
-       if (overwrite)
-               clean_interface(iface);
-
        if ((c = tb[IFACE_ATTR_DYNAMICDHCP]))
                iface->no_dynamic_dhcp = !blobmsg_get_bool(c);
 
@@ -503,6 +498,10 @@ void odhcpd_reload(void)
                free(l);
        }
 
+       struct interface *master = NULL, *i, *n;
+       list_for_each_entry(i, &interfaces, head)
+               clean_interface(i);
+
        struct uci_package *dhcp = NULL;
        if (!uci_load(uci, "dhcp", &dhcp)) {
                struct uci_element *e;
@@ -521,12 +520,12 @@ void odhcpd_reload(void)
                }
        }
 
+
 #ifdef WITH_UBUS
        ubus_apply_network();
 #endif
 
        // Evaluate hybrid mode for master
-       struct interface *master = NULL, *i, *n;
        list_for_each_entry(i, &interfaces, head) {
                if (!i->master)
                        continue;
@@ -570,7 +569,6 @@ void odhcpd_reload(void)
                        setup_dhcpv6_interface(i, true);
                        setup_ndp_interface(i, true);
                        setup_dhcpv4_interface(i, true);
-                       i->inuse = false;
                } else {
                        close_interface(i);
                }
index 5ae6a390e5ddb1d6dd0c111dd6b4b13583ea4316..9949253ff7698cc8aca5e06010ad66e31f055f79 100644 (file)
@@ -104,7 +104,6 @@ struct interface {
        int ifindex;
        char ifname[IF_NAMESIZE];
        char name[IF_NAMESIZE];
-       bool inuse;
 
        // Runtime data
        struct uloop_timeout timer_rs;
@@ -124,6 +123,7 @@ struct interface {
        enum odhcpd_mode dhcpv4;
 
        // Config
+       bool inuse;
        bool external;
        bool master;
        bool ignore;