diff options
author | Hans Dedecker <dedeckeh@gmail.com> | 2017-01-31 22:11:20 +0100 |
---|---|---|
committer | Hans Dedecker <dedeckeh@gmail.com> | 2017-01-31 22:11:20 +0100 |
commit | df5042974622d72ce2424de8ef532941ac4f7fc9 (patch) | |
tree | 3581d664e1bce8d63dbaaaa2434ef52899130825 /src/ndp.c | |
parent | 83d72cf224956eb08453051744649df89b217203 (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.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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))) |