#include <stdlib.h>
#include <unistd.h>
#include <stdbool.h>
+#include <arpa/inet.h>
#include <net/route.h>
#include "router.h"
static void trigger_router_advert(struct uloop_timeout *event);
static void sigusr1_refresh(int signal);
-static struct odhcpd_event router_event = {{.fd = -1}, handle_icmpv6, NULL};
+static struct odhcpd_event router_event = {.uloop = {.fd = -1}, .handle_dgram = handle_icmpv6, };
static FILE *fp_route = NULL;
#define RA_IOV_LEN 6
odhcpd_get_mac(iface, adv.lladdr.data);
// If not currently shutting down
- struct odhcpd_ipaddr addrs[8];
+ struct odhcpd_ipaddr addrs[RELAYD_MAX_ADDRS];
ssize_t ipcnt = 0;
int64_t minvalid = INT64_MAX;
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_INFO, "Initial RA router lifetime %d, %d address(es) available on %s",
+ ntohs(adv.h.nd_ra_router_lifetime), (int)ipcnt, iface->ifname);
}
// Construct Prefix Information options
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_INFO, "Address %s (prefix %d, valid %u) not suitable as RA prefix on %s",
+ namebuf, addr->prefix, addr->valid, iface->ifname);
+ continue;
+ }
struct nd_opt_prefix_info *p = NULL;
for (size_t i = 0; i < cnt; ++i) {
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_INFO, "Updating RA router lifetime to %d on %s", this_lifetime, iface->ifname);
+ }
+
odhcpd_bmemcpy(&p->nd_opt_pi_prefix, &addr->addr,
(iface->ra_advrouter) ? 128 : addr->prefix);
p->nd_opt_pi_type = ND_OPT_PREFIX_INFORMATION;