Skip to content

Commit

Permalink
Merge pull request openwrt#67 from dedeckeh/bugfixes
Browse files Browse the repository at this point in the history
Fix interface ifname overwrite in case UCI dhcp section contains ifname or networkid parameter
  • Loading branch information
sbyx committed Nov 29, 2015
2 parents 01d3f9d + 045a620 commit c5cb116
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,26 +300,26 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
}

const char *ifname = NULL;
#ifdef WITH_UBUS
if (overwrite || !iface->ifname[0])
ifname = ubus_get_ifname(name);
#endif

if (overwrite) {
if ((c = tb[IFACE_ATTR_IFNAME]))
ifname = blobmsg_get_string(c);
else if ((c = tb[IFACE_ATTR_NETWORKID]))
ifname = blobmsg_get_string(c);
}

#ifdef WITH_UBUS
if (overwrite || !iface->ifname[0])
ifname = ubus_get_ifname(name);
#endif

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;

Expand Down
3 changes: 3 additions & 0 deletions src/router.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit c5cb116

Please sign in to comment.