summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/config.c34
-rw-r--r--src/dhcpv6-ia.c1
-rw-r--r--src/ndp.c4
-rw-r--r--src/odhcpd.c8
4 files changed, 38 insertions, 9 deletions
diff --git a/src/config.c b/src/config.c
index d025bdf..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)
@@ -567,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;
}
@@ -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);
diff --git a/src/dhcpv6-ia.c b/src/dhcpv6-ia.c
index 88840a4..4d68258 100644
--- a/src/dhcpv6-ia.c
+++ b/src/dhcpv6-ia.c
@@ -101,6 +101,7 @@ int setup_dhcpv6_ia_interface(struct interface *iface, bool enable)
list_for_each_entry(c, &iface->ia_assignments, head) {
if (c->length != 128 || c->assigned > a->assigned) {
list_add_tail(&a->head, &c->head);
+ break;
} else if (c->assigned == a->assigned) {
// Already an assignment with that number
break;
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 39ce98e..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) {
@@ -175,7 +175,7 @@ ssize_t odhcpd_send(int socket, struct sockaddr_in6 *dest,
syslog(LOG_WARNING, "Failed to send to %s%%%s (%s)",
ipbuf, iface->ifname, strerror(errno));
else
- syslog(LOG_NOTICE, "Sent %li bytes to %s%%%s",
+ syslog(LOG_DEBUG, "Sent %li bytes to %s%%%s",
(long)sent, ipbuf, iface->ifname);
return sent;
}
@@ -359,8 +359,8 @@ static void odhcpd_receive_packets(struct uloop_fd *u, _unused unsigned int even
else if (addr.in.sin_family == AF_INET)
inet_ntop(AF_INET, &addr.in.sin_addr, ipbuf, sizeof(ipbuf));
- syslog(LOG_NOTICE, "--");
- syslog(LOG_NOTICE, "Received %li Bytes from %s%%%s", (long)len,
+ syslog(LOG_DEBUG, "--");
+ syslog(LOG_DEBUG, "Received %li Bytes from %s%%%s", (long)len,
ipbuf, (iface) ? iface->ifname : "netlink");
e->handle_dgram(&addr, data_buf, len, iface);