summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/sd-ndisc.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-11-24 18:25:52 +0100
committerTom Gundersen <teg@jklm.no>2015-11-25 18:30:31 +0100
commit0d43d2fcb7ac5264c739dc2f67f93ed0985a418a (patch)
tree399e2e94af1d94fec01aea7848b27db8bca27775 /src/libsystemd-network/sd-ndisc.c
parentaf143e3b692fbba2e68efd2c834711ba518f547a (diff)
libsystemd-network: clean up recv functions
Diffstat (limited to 'src/libsystemd-network/sd-ndisc.c')
-rw-r--r--src/libsystemd-network/sd-ndisc.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/libsystemd-network/sd-ndisc.c b/src/libsystemd-network/sd-ndisc.c
index 713438f212..5591bc7841 100644
--- a/src/libsystemd-network/sd-ndisc.c
+++ b/src/libsystemd-network/sd-ndisc.c
@@ -494,8 +494,11 @@ static int ndisc_router_advertisment_recv(sd_event_source *s, int fd, uint32_t r
assert(nd->event);
r = ioctl(fd, FIONREAD, &buflen);
- if (r < 0 || buflen <= 0)
- buflen = ICMP6_RECV_SIZE;
+ if (r < 0)
+ return -errno;
+ else if (buflen < 0)
+ /* This really should not happen */
+ return -EIO;
ra = malloc(buflen);
if (!ra)
@@ -503,8 +506,11 @@ static int ndisc_router_advertisment_recv(sd_event_source *s, int fd, uint32_t r
len = recvfrom(fd, ra, buflen, 0, &router.sa, &router_len);
if (len < 0) {
+ if (errno == EAGAIN || errno == EINTR)
+ return 0;
+
log_ndisc(nd, "Could not receive message from ICMPv6 socket: %m");
- return 0;
+ return -errno;
} else if (router_len == 0)
gw = NULL; /* only happens when running the test-suite over a socketpair */
else if (router_len != sizeof(router.in6)) {