summaryrefslogtreecommitdiffhomepage
path: root/src/ndp.c
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2017-01-31 22:11:20 +0100
committerHans Dedecker <dedeckeh@gmail.com>2017-01-31 22:11:20 +0100
commitdf5042974622d72ce2424de8ef532941ac4f7fc9 (patch)
tree3581d664e1bce8d63dbaaaa2434ef52899130825 /src/ndp.c
parent83d72cf224956eb08453051744649df89b217203 (diff)
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.
Diffstat (limited to 'src/ndp.c')
-rw-r--r--src/ndp.c6
1 files changed, 5 insertions, 1 deletions
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)))