summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2017-01-21 17:07:54 +0100
committerHans Dedecker <dedeckeh@gmail.com>2017-01-21 17:25:47 +0100
commitc5040fea540479b731b040986a9c3a62e34afc37 (patch)
treef0e5d9b2364f640e9817322faf7e268e7df52e7f /src
parentdf023adafeee1bf48fa1e0cce31e7130f8043dae (diff)
router: add syslog debug tracing for trouble shooting
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/dhcpv6.c1
-rw-r--r--src/ndp.c8
-rw-r--r--src/router.c20
3 files changed, 24 insertions, 5 deletions
diff --git a/src/dhcpv6.c b/src/dhcpv6.c
index 9f91162..81eae06 100644
--- a/src/dhcpv6.c
+++ b/src/dhcpv6.c
@@ -18,6 +18,7 @@
#include <stddef.h>
#include <resolv.h>
#include <sys/timerfd.h>
+#include <arpa/inet.h>
#include "odhcpd.h"
#include "dhcpv6.h"
diff --git a/src/ndp.c b/src/ndp.c
index 7cabc5e..d2fbe07 100644
--- a/src/ndp.c
+++ b/src/ndp.c
@@ -327,8 +327,10 @@ static void check_updates(struct interface *iface)
if (change)
dhcpv6_ia_postupdate(iface, now);
- if (change)
+ if (change) {
+ syslog(LOG_DEBUG, "Raising SIGUSR1 due to address change");
raise(SIGUSR1);
+ }
}
@@ -360,8 +362,10 @@ static void handle_rtnetlink(_unused void *addr, void *data, size_t len,
if (is_route) {
// Inform about a change in default route
- if (rtm->rtm_dst_len == 0)
+ if (rtm->rtm_dst_len == 0) {
+ syslog(LOG_DEBUG, "Raising SIGUSR1 due to default route change");
raise(SIGUSR1);
+ }
continue;
}
diff --git a/src/router.c b/src/router.c
index bc22829..5d254fd 100644
--- a/src/router.c
+++ b/src/router.c
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <stdbool.h>
+#include <arpa/inet.h>
#include <net/route.h>
#include "router.h"
@@ -261,6 +262,9 @@ static uint64_t send_router_advert(struct interface *iface, const struct in6_add
adv.h.nd_ra_router_lifetime = htons(iface->default_router);
else if (parse_routes(addrs, ipcnt))
adv.h.nd_ra_router_lifetime = htons(1);
+
+ syslog(LOG_DEBUG, "Initial router lifetime %d, %d address(es) available",
+ ntohs(adv.h.nd_ra_router_lifetime), ipcnt);
}
// Construct Prefix Information options
@@ -273,8 +277,15 @@ static uint64_t send_router_advert(struct interface *iface, const struct in6_add
for (ssize_t i = 0; i < ipcnt; ++i) {
struct odhcpd_ipaddr *addr = &addrs[i];
- if (addr->prefix > 96 || addr->valid <= (uint32_t)now)
- continue; // Address not suitable
+
+ if (addr->prefix > 96 || addr->valid <= (uint32_t)now) {
+ char namebuf[INET6_ADDRSTRLEN];
+
+ inet_ntop(AF_INET6, addr, namebuf, sizeof(namebuf));
+ syslog(LOG_DEBUG, "Address %s (prefix %d, valid %u) not suitable",
+ namebuf, addr->prefix, addr->valid);
+ continue;
+ }
struct nd_opt_prefix_info *p = NULL;
for (size_t i = 0; i < cnt; ++i) {
@@ -300,9 +311,12 @@ static uint64_t send_router_advert(struct interface *iface, const struct in6_add
this_lifetime = UINT16_MAX;
if (((addr->addr.s6_addr[0] & 0xfe) != 0xfc || iface->default_router)
&& adv.h.nd_ra_router_lifetime
- && ntohs(adv.h.nd_ra_router_lifetime) < this_lifetime)
+ && ntohs(adv.h.nd_ra_router_lifetime) < this_lifetime) {
adv.h.nd_ra_router_lifetime = htons(this_lifetime);
+ syslog(LOG_DEBUG, "Updating router lifetime to %d", this_lifetime);
+ }
+
odhcpd_bmemcpy(&p->nd_opt_pi_prefix, &addr->addr,
(iface->ra_advrouter) ? 128 : addr->prefix);
p->nd_opt_pi_type = ND_OPT_PREFIX_INFORMATION;