From df5042974622d72ce2424de8ef532941ac4f7fc9 Mon Sep 17 00:00:00 2001 From: Hans Dedecker Date: Tue, 31 Jan 2017 22:11:20 +0100 Subject: odhcpd: properly handle netlink messages (FS#388) Use libnl-tiny to construct and process netlink messages when manipulating IPv6 routes and fetching IPv6 addresses. This fixes lingering netlink error messages on the netlink socket in case route deletion failed causing fetching of IPv6 addresses to be aborted and odhcpd faultly assuming no IPv6 addresses being present on the interface. --- src/ndp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/ndp.c') diff --git a/src/ndp.c b/src/ndp.c index 10acc3b..f2bf19c 100644 --- a/src/ndp.c +++ b/src/ndp.c @@ -64,7 +64,11 @@ int init_ndp(void) int val = 256 * 1024; // Setup netlink socket - if ((rtnl_event.uloop.fd = odhcpd_open_rtnl()) < 0) + if ((rtnl_event.uloop.fd = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE)) < 0) + return -1; + + struct sockaddr_nl nl = {.nl_family = AF_NETLINK}; + if (connect(rtnl_event.uloop.fd, (struct sockaddr*)&nl, sizeof(nl)) < 0) return -1; if (setsockopt(rtnl_event.uloop.fd, SOL_SOCKET, SO_RCVBUF, &val, sizeof(val))) -- cgit v1.2.3