summaryrefslogtreecommitdiffstats
path: root/src/ipv6nd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2021-02-02 14:41:54 +0000
committerRoy Marples <roy@marples.name>2021-02-02 14:41:54 +0000
commit5d619328bf07da0b6b209ce12f22381a4fe435e0 (patch)
tree5ace2bdf2c31a21315447462ee10b4e1f9f12e64 /src/ipv6nd.c
parentb042338612f18c9be8576c258006f94395db6297 (diff)
downloaddhcpcd-5d619328bf07da0b6b209ce12f22381a4fe435e0.tar.xz
eloop: Make the API more like native poll/kqueue/epoll
Just have the one callback, but return an abstracted event mask to work out if we can read/write have something else. Log diagnostics if the event mask is unexpected. While here add more logging if we fail to register an event to monitor.
Diffstat (limited to 'src/ipv6nd.c')
-rw-r--r--src/ipv6nd.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/ipv6nd.c b/src/ipv6nd.c
index b0174a77..4b9c735d 100644
--- a/src/ipv6nd.c
+++ b/src/ipv6nd.c
@@ -78,7 +78,7 @@ struct nd_opt_rdnss { /* RDNSS option RFC 6106 */
uint8_t nd_opt_rdnss_len;
uint16_t nd_opt_rdnss_reserved;
uint32_t nd_opt_rdnss_lifetime;
- /* followed by list of IP prefixes */
+ /* followed by list of IP prefixes */
};
__CTASSERT(sizeof(struct nd_opt_rdnss) == 8);
#endif
@@ -131,7 +131,7 @@ __CTASSERT(sizeof(struct nd_opt_rdnss) == 8);
//#define DEBUG_NS
//
-static void ipv6nd_handledata(void *);
+static void ipv6nd_handledata(void *, unsigned short);
/*
* Android ships buggy ICMP6 filter headers.
@@ -281,8 +281,14 @@ ipv6nd_openif(struct interface *ifp)
return -1;
}
+ if (eloop_event_add(ifp->ctx->eloop, fd, ELE_READ,
+ ipv6nd_handledata, ifp) == -1)
+ {
+ close(fd);
+ return -1;
+ }
+
state->nd_fd = fd;
- eloop_event_add(ifp->ctx->eloop, fd, ipv6nd_handledata, ifp);
return fd;
}
#endif
@@ -388,7 +394,9 @@ ipv6nd_sendrsprobe(void *arg)
logerr(__func__);
return;
}
- eloop_event_add(ctx->eloop, ctx->nd_fd, ipv6nd_handledata, ctx);
+ if (eloop_event_add(ctx->eloop, ctx->nd_fd, ELE_READ,
+ ipv6nd_handledata, ctx) == -1)
+ logerr("%s: eloop_event_add", __func__);
}
s = ifp->ctx->nd_fd;
#endif
@@ -1977,7 +1985,7 @@ ipv6nd_recvmsg(struct dhcpcd_ctx *ctx, struct msghdr *msg)
}
static void
-ipv6nd_handledata(void *arg)
+ipv6nd_handledata(void *arg, unsigned short events)
{
struct dhcpcd_ctx *ctx;
int fd;
@@ -2013,6 +2021,10 @@ ipv6nd_handledata(void *arg)
ctx = arg;
fd = ctx->nd_fd;
#endif
+
+ if (events != ELE_READ)
+ logerrx("%s: unexpected event 0x%04x", __func__, events);
+
len = recvmsg(fd, &msg, 0);
if (len == -1) {
logerr(__func__);