blobmsg_parse(iface_attrs, IFACE_ATTR_MAX, tb, blob_data(b), blob_len(b));
if (tb[IFACE_ATTR_INTERFACE])
- name = blobmsg_data(tb[IFACE_ATTR_INTERFACE]);
+ name = blobmsg_get_string(tb[IFACE_ATTR_INTERFACE]);
+
+ if (!name)
+ return -1;
struct interface *iface = get_interface(name);
if (!iface) {
else if ((c = tb[IFACE_ATTR_NETWORKID]))
ifname = blobmsg_get_string(c);
+ if (!ifname)
+ return -1;
+
strncpy(iface->ifname, ifname, sizeof(iface->ifname) - 1);
iface->inuse = true;
if ((c = tb[IFACE_ATTR_UPSTREAM])) {
struct blob_attr *cur;
- int rem;
+ unsigned rem;
blobmsg_for_each_attr(cur, c, rem) {
if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING || !blobmsg_check_attr(cur, NULL))
}
}
- if ((c = tb[IFACE_ATTR_RA]))
- if ((iface->ra = parse_mode(blobmsg_get_string(c))) < 0)
+ int mode;
+ if ((c = tb[IFACE_ATTR_RA])) {
+ if ((mode = parse_mode(blobmsg_get_string(c))) >= 0)
+ iface->ra = mode;
+ else
goto err;
+ }
- if ((c = tb[IFACE_ATTR_DHCPV4]))
- if ((iface->dhcpv4 = parse_mode(blobmsg_get_string(c))) < 0)
+ if ((c = tb[IFACE_ATTR_DHCPV4])) {
+ if ((mode = parse_mode(blobmsg_get_string(c))) >= 0)
+ iface->dhcpv4 = mode;
+ else
goto err;
+ }
- if ((c = tb[IFACE_ATTR_DHCPV6]))
- if ((iface->dhcpv6 = parse_mode(blobmsg_get_string(c))) < 0)
+ if ((c = tb[IFACE_ATTR_DHCPV6])) {
+ if ((mode = parse_mode(blobmsg_get_string(c))) >= 0)
+ iface->dhcpv6 = mode;
+ else
goto err;
+ }
- if ((c = tb[IFACE_ATTR_NDP]))
- if ((iface->ndp = parse_mode(blobmsg_get_string(c))) < 0)
+ if ((c = tb[IFACE_ATTR_NDP])) {
+ if ((mode = parse_mode(blobmsg_get_string(c))) >= 0)
+ iface->ndp = mode;
+ else
goto err;
+ }
if ((c = tb[IFACE_ATTR_DNS])) {
struct blob_attr *cur;
- int rem;
+ unsigned rem;
iface->always_rewrite_dns = true;
blobmsg_for_each_attr(cur, c, rem) {
if ((c = tb[IFACE_ATTR_DOMAIN])) {
struct blob_attr *cur;
- int rem;
+ unsigned rem;
blobmsg_for_each_attr(cur, c, rem) {
if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING || !blobmsg_check_attr(cur, NULL))
if ((c = tb[IFACE_ATTR_NDPROXY_STATIC])) {
struct blob_attr *cur;
- int rem;
+ unsigned rem;
blobmsg_for_each_attr(cur, c, rem) {
if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING || !blobmsg_check_attr(cur, NULL))
}
-static volatile bool do_reload = false;
+static volatile int do_reload = false;
static void set_stop(int signal)
{
uloop_end();
signal(SIGHUP, set_stop);
signal(SIGINT, set_stop);
+#ifdef WITH_UBUS
+ init_ubus();
+#endif
+
do {
- do_reload = false;
+ do_reload = uloop_cancelled = false;
struct lease *l;
list_for_each_entry(l, &leases, head) {
#endif
// Evaluate hybrid mode for master
- struct interface *master = NULL, *i;
+ struct interface *master = NULL, *i, *n;
list_for_each_entry(i, &interfaces, head) {
if (!i->master)
continue;
}
- list_for_each_entry(i, &interfaces, head) {
- if (i->inuse && !i->ignore) {
+ list_for_each_entry_safe(i, n, &interfaces, head) {
+ if (i->inuse) {
// Resolve hybrid mode
if (i->dhcpv6 == RELAYD_HYBRID)
i->dhcpv6 = (master && master->dhcpv6 == RELAYD_RELAY) ?