Fix prefix detection for hybrid mode
[project/odhcpd.git] / src / config.c
index 46137a4..d025bdf 100644 (file)
@@ -302,6 +302,9 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
        if (ifname)
                strncpy(iface->ifname, ifname, sizeof(iface->ifname) - 1);
 
        if (ifname)
                strncpy(iface->ifname, ifname, sizeof(iface->ifname) - 1);
 
+       if ((iface->ifindex = if_nametoindex(iface->ifname)) <= 0)
+               return -1;
+
        iface->inuse = true;
 
        if ((c = tb[IFACE_ATTR_DYNAMICDHCP]))
        iface->inuse = true;
 
        if ((c = tb[IFACE_ATTR_DYNAMICDHCP]))
@@ -494,7 +497,6 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr
                }
        }
 
                }
        }
 
-       iface->ignore = (iface->ifindex = if_nametoindex(iface->ifname)) <= 0;
        return 0;
 
 err:
        return 0;
 
 err:
@@ -558,7 +560,7 @@ void odhcpd_reload(void)
 
                enum odhcpd_mode hybrid_mode = RELAYD_DISABLED;
 #ifdef WITH_UBUS
 
                enum odhcpd_mode hybrid_mode = RELAYD_DISABLED;
 #ifdef WITH_UBUS
-               if (ubus_has_prefix(i->name, i->ifname))
+               if (!ubus_has_prefix(i->name, i->ifname))
                        hybrid_mode = RELAYD_RELAY;
 #endif
 
                        hybrid_mode = RELAYD_RELAY;
 #endif