diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-05-23 15:56:01 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2016-05-26 15:34:41 +0200 |
commit | 004845d18ed31fe5ffc153699f63e58dc8b24171 (patch) | |
tree | 71d747cd4ba0b3b923819c9358ef0ea67e49b69b /src/libsystemd-network/sd-dhcp6-client.c | |
parent | e81f2539673b536c1b20fe2fd0650079d71125a2 (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-dhcp6-client.c')
-rw-r--r-- | src/libsystemd-network/sd-dhcp6-client.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c index 05972e01c9..7dead24836 100644 --- a/src/libsystemd-network/sd-dhcp6-client.c +++ b/src/libsystemd-network/sd-dhcp6-client.c @@ -898,7 +898,12 @@ static int client_receive_advertise(sd_dhcp6_client *client, DHCP6Message *adver return r; } -static int client_receive_message(sd_event_source *s, int fd, uint32_t revents, void *userdata) { +static int client_receive_message( + sd_event_source *s, + int fd, uint32_t + revents, + void *userdata) { + sd_dhcp6_client *client = userdata; DHCP6_CLIENT_DONT_DESTROY(client); _cleanup_free_ DHCP6Message *message = NULL; @@ -924,8 +929,11 @@ static int client_receive_message(sd_event_source *s, int fd, uint32_t revents, return log_dhcp6_client_errno(client, errno, "Could not receive message from UDP socket: %m"); - } else if ((size_t)len < sizeof(DHCP6Message)) + } + if ((size_t) len < sizeof(DHCP6Message)) { + log_dhcp6_client(client, "Too small to be DHCP6 message: ignoring"); return 0; + } switch(message->type) { case DHCP6_SOLICIT: |