config: Close interface when ifindex cannot be resolved
authorHans Dedecker <dedeckeh@gmail.com>
Fri, 27 Nov 2015 10:30:41 +0000 (11:30 +0100)
committerHans Dedecker <dedeckeh@gmail.com>
Fri, 27 Nov 2015 13:41:20 +0000 (14:41 +0100)
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
src/config.c
src/router.c

index 7d870f129b27047a8eb8bb57c805908aee3f842f..4fc8bc7e738ad54fb147f870ac0515c790c28449 100644 (file)
@@ -313,13 +313,13 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
        }
 
        if (!iface->ifname[0] && !ifname)
-               return -1;
+               goto err;
 
        if (ifname)
                strncpy(iface->ifname, ifname, sizeof(iface->ifname) - 1);
 
        if ((iface->ifindex = if_nametoindex(iface->ifname)) <= 0)
-               return -1;
+               goto err;
 
        iface->inuse = true;
 
index 990782426967271a985eec10e558d95d76cb57b4..971197530918776d1f185dae9cab8a255fac5474 100644 (file)
@@ -99,6 +99,9 @@ int setup_router_interface(struct interface *iface, bool enable)
        uloop_timeout_cancel(&iface->timer_rs);
        iface->timer_rs.cb = NULL;
 
+       if (iface->ifindex <= 0)
+               return -1;
+
        setsockopt(router_event.uloop.fd, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP,
                        &all_nodes, sizeof(all_nodes));
        setsockopt(router_event.uloop.fd, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP,