struct interface *iface, void *dest);
static void handle_rtnetlink(void *addr, void *data, size_t len,
struct interface *iface, void *dest);
+static void catch_rtnetlink(int error);
static uint32_t rtnl_seqid = 0;
static int ping_socket = -1;
-static struct odhcpd_event rtnl_event = {{.fd = -1}, handle_rtnetlink};
+static struct odhcpd_event rtnl_event = {{.fd = -1}, handle_rtnetlink, catch_rtnetlink};
// Filter ICMPv6 messages of type neighbor soliciation
// Initialize NDP-proxy
int init_ndp(void)
{
+ int val = 256 * 1024;
+
// Setup netlink socket
if ((rtnl_event.uloop.fd = odhcpd_open_rtnl()) < 0)
return -1;
+ if (setsockopt(rtnl_event.uloop.fd, SOL_SOCKET, SO_RCVBUF, &val, sizeof(val)))
+ setsockopt(rtnl_event.uloop.fd, SOL_SOCKET, SO_RCVBUFFORCE, &val, sizeof(val));
+
// Receive netlink neighbor and ip-address events
uint32_t group = RTNLGRP_IPV6_IFADDR;
setsockopt(rtnl_event.uloop.fd, SOL_NETLINK,
return -1;
}
- int val = 2;
+ val = 2;
setsockopt(ping_socket, IPPROTO_RAW, IPV6_CHECKSUM, &val, sizeof(val));
// This is required by RFC 4861
// Check address update
static void check_updates(struct interface *iface)
{
- struct odhcpd_ipaddr addr[8] = {{IN6ADDR_ANY_INIT, 0, 0, 0, 0}};
+ struct odhcpd_ipaddr addr[RELAYD_MAX_ADDRS] = {{IN6ADDR_ANY_INIT, 0, 0, 0, 0}};
time_t now = odhcpd_time();
- ssize_t len = odhcpd_get_interface_addresses(iface->ifindex, addr, 8);
+ ssize_t len = odhcpd_get_interface_addresses(iface->ifindex, addr, ARRAY_SIZE(addr));
if (len < 0)
return;
|| ndm->ndm_family != AF_INET6)
continue;
- // Inform about a change in default route
- if (is_route && rtm->rtm_dst_len == 0)
- raise(SIGUSR1);
- else if (is_route)
+ if (is_route) {
+ // Inform about a change in default route
+ if (rtm->rtm_dst_len == 0)
+ raise(SIGUSR1);
+
continue;
+ }
// Data to retrieve
size_t rta_offset = (is_addr) ? sizeof(struct ifaddrmsg) : sizeof(*ndm);
if (dump_neigh)
dump_neigh_table(false);
}
+
+static void catch_rtnetlink(int error)
+{
+ if (error == ENOBUFS) {
+ struct {
+ struct nlmsghdr nh;
+ struct ifaddrmsg ifa;
+ } req2 = {
+ {sizeof(req2), RTM_GETADDR, NLM_F_REQUEST | NLM_F_DUMP,
+ ++rtnl_seqid, 0},
+ {.ifa_family = AF_INET6}
+ };
+ send(rtnl_event.uloop.fd, &req2, sizeof(req2), MSG_DONTWAIT);
+ }
+}