diff options
author | Steven Barth <steven@midlink.org> | 2014-01-17 20:06:46 +0100 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2014-01-17 20:06:46 +0100 |
commit | 72fec39d4446d9bb9416763043c79d5135c84fbd (patch) | |
tree | abae7d4d3abb47c9fca4b1e24e1717fa96f2d444 /src/config.c | |
parent | 3e48070e686c10a6c01b5a8d706151d6ae0c932a (diff) |
Don't enable relay master if no slaves are present
Diffstat (limited to 'src/config.c')
-rw-r--r-- | src/config.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/config.c b/src/config.c index 195a9a4..05eb824 100644 --- a/src/config.c +++ b/src/config.c @@ -555,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) @@ -569,12 +586,21 @@ void odhcpd_reload(void) 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; } @@ -593,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); |