X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fodhcpd.git;a=blobdiff_plain;f=src%2Fconfig.c;h=8e42ffa5ce75fccca09d36ad98ea0564717ee8f8;hp=b6b3708acba852a7d41ff3d76f1138726f871cbf;hb=9d050fcefd335f4cc0d8ddbabebb99954abe8904;hpb=4d5d803c929092eb07db5717650224afbde59d55 diff --git a/src/config.c b/src/config.c index b6b3708..8e42ffa 100644 --- a/src/config.c +++ b/src/config.c @@ -454,6 +454,8 @@ int config_parse_interface(void *data, size_t len, const char *name, bool overwr if ((c = tb[IFACE_ATTR_RA_MANAGEMENT])) iface->managed = blobmsg_get_u32(c); + else + iface->managed = 1; if ((c = tb[IFACE_ATTR_RA_OFFLINK])) iface->ra_not_onlink = blobmsg_get_bool(c); @@ -515,8 +517,8 @@ static int set_interface(struct uci_section *s) void odhcpd_reload(void) { struct uci_context *uci = uci_alloc_context(); - struct lease *l; - list_for_each_entry(l, &leases, head) { + while (!list_empty(&leases)) { + struct lease *l = list_first_entry(&leases, struct lease, head); list_del(&l->head); free(l->duid); free(l); @@ -553,6 +555,23 @@ void odhcpd_reload(void) ubus_apply_network(); #endif + bool any_dhcpv6_slave = false, any_ra_slave = false, any_ndp_slave = false; + + // Test for + list_for_each_entry(i, &interfaces, head) { + if (i->master) + continue; + + if (i->dhcpv6 == RELAYD_HYBRID || i->dhcpv6 == RELAYD_RELAY) + any_dhcpv6_slave = true; + + if (i->ra == RELAYD_HYBRID || i->ra == RELAYD_RELAY) + any_ra_slave = true; + + if (i->ndp == RELAYD_HYBRID || i->ndp == RELAYD_RELAY) + any_ndp_slave = true; + } + // Evaluate hybrid mode for master list_for_each_entry(i, &interfaces, head) { if (!i->master) @@ -560,19 +579,28 @@ void odhcpd_reload(void) 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 if (i->dhcpv6 == RELAYD_HYBRID) i->dhcpv6 = hybrid_mode; + if (i->dhcpv6 == RELAYD_RELAY && !any_dhcpv6_slave) + i->dhcpv6 = RELAYD_DISABLED; + if (i->ra == RELAYD_HYBRID) i->ra = hybrid_mode; + if (i->ra == RELAYD_RELAY && !any_ra_slave) + i->ra = RELAYD_DISABLED; + if (i->ndp == RELAYD_HYBRID) i->ndp = hybrid_mode; + if (i->ndp == RELAYD_RELAY && !any_ndp_slave) + i->ndp = RELAYD_DISABLED; + if (i->dhcpv6 == RELAYD_RELAY || i->ra == RELAYD_RELAY || i->ndp == RELAYD_RELAY) master = i; } @@ -591,7 +619,7 @@ void odhcpd_reload(void) if (i->ndp == RELAYD_HYBRID) i->ndp = (master && master->ndp == RELAYD_RELAY) ? - RELAYD_RELAY : RELAYD_SERVER; + RELAYD_RELAY : RELAYD_DISABLED; setup_router_interface(i, true); setup_dhcpv6_interface(i, true);