summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/sd-ndisc.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-05-23 15:56:01 +0200
committerLennart Poettering <lennart@poettering.net>2016-05-26 15:34:41 +0200
commit004845d18ed31fe5ffc153699f63e58dc8b24171 (patch)
tree71d747cd4ba0b3b923819c9358ef0ea67e49b69b /src/libsystemd-network/sd-ndisc.c
parente81f2539673b536c1b20fe2fd0650079d71125a2 (diff)
sd-network: unify packet processing logic a bit
Let's always check for errno being EAGAIN/EINTR the same way, and always log if we receive weirdly short packets.
Diffstat (limited to 'src/libsystemd-network/sd-ndisc.c')
-rw-r--r--src/libsystemd-network/sd-ndisc.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libsystemd-network/sd-ndisc.c b/src/libsystemd-network/sd-ndisc.c
index fb4ef55673..8d18707de1 100644
--- a/src/libsystemd-network/sd-ndisc.c
+++ b/src/libsystemd-network/sd-ndisc.c
@@ -517,9 +517,13 @@ static int ndisc_router_advertisment_recv(sd_event_source *s, int fd, uint32_t r
log_ndisc(nd, "Could not receive message from ICMPv6 socket: %m");
return -errno;
- } else if ((size_t)len < sizeof(struct nd_router_advert)) {
+ }
+ if ((size_t) len < sizeof(struct nd_router_advert)) {
+ log_ndisc(nd, "Too small to be a router advertisement: ignoring");
return 0;
- } else if (msg.msg_namelen == 0)
+ }
+
+ if (msg.msg_namelen == 0)
gw = NULL; /* only happens when running the test-suite over a socketpair */
else if (msg.msg_namelen != sizeof(sa.in6)) {
log_ndisc(nd, "Received invalid source address size from ICMPv6 socket: %zu bytes", (size_t)msg.msg_namelen);