summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2014-01-17 20:06:46 +0100
committerSteven Barth <steven@midlink.org>2014-01-17 20:06:46 +0100
commit72fec39d4446d9bb9416763043c79d5135c84fbd (patch)
treeabae7d4d3abb47c9fca4b1e24e1717fa96f2d444
parent3e48070e686c10a6c01b5a8d706151d6ae0c932a (diff)
Don't enable relay master if no slaves are present
-rw-r--r--src/config.c28
-rw-r--r--src/ndp.c4
-rw-r--r--src/odhcpd.c2
3 files changed, 30 insertions, 4 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);
diff --git a/src/ndp.c b/src/ndp.c
index 150d360..02c2dbd 100644
--- a/src/ndp.c
+++ b/src/ndp.c
@@ -234,7 +234,7 @@ static void handle_solicit(void *addr, void *data, size_t len,
char ipbuf[INET6_ADDRSTRLEN];
inet_ntop(AF_INET6, &req->nd_ns_target, ipbuf, sizeof(ipbuf));
- syslog(LOG_NOTICE, "Got a NS for %s", ipbuf);
+ syslog(LOG_DEBUG, "Got a NS for %s", ipbuf);
uint8_t mac[6];
odhcpd_get_mac(iface, mac);
@@ -246,7 +246,7 @@ static void handle_solicit(void *addr, void *data, size_t len,
struct ndp_neighbor *n = find_neighbor(&req->nd_ns_target, false);
if (n && (n->iface || abs(n->timeout - now) < 5)) {
- syslog(LOG_NOTICE, "%s is on %s", ipbuf,
+ syslog(LOG_DEBUG, "%s is on %s", ipbuf,
(n->iface) ? n->iface->ifname : "<pending>");
if (!n->iface || n->iface == iface)
return;
diff --git a/src/odhcpd.c b/src/odhcpd.c
index 6512e61..f40cea0 100644
--- a/src/odhcpd.c
+++ b/src/odhcpd.c
@@ -52,7 +52,7 @@ static int urandom_fd = -1;
int main()
{
openlog("odhcpd", LOG_PERROR | LOG_PID, LOG_DAEMON);
- setlogmask(LOG_UPTO(LOG_INFO));
+ setlogmask(LOG_UPTO(LOG_WARNING));
uloop_init();
if (getuid() != 0) {