diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-02-15 22:50:01 +0100 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-25 11:56:39 -0400 |
commit | 2eb25bc571d6b5babe50ab116c2619e17de39ec9 (patch) | |
tree | 3df98494a97998a379936551a08456ea86241e2e /src/libsystemd-network/sd-dhcp6-client.c | |
parent | 95adafc428b5b4be0ddd4d43a7b96658390388bc (diff) |
networkd: FIONREAD is not reliable on some sockets
Fixes: #2457
Diffstat (limited to 'src/libsystemd-network/sd-dhcp6-client.c')
-rw-r--r-- | src/libsystemd-network/sd-dhcp6-client.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c index 5b6b9cbcac..7d56d4cc60 100644 --- a/src/libsystemd-network/sd-dhcp6-client.c +++ b/src/libsystemd-network/sd-dhcp6-client.c @@ -33,6 +33,7 @@ #include "in-addr-util.h" #include "network-internal.h" #include "random-util.h" +#include "socket-util.h" #include "string-table.h" #include "util.h" @@ -891,18 +892,16 @@ static int client_receive_message(sd_event_source *s, int fd, uint32_t revents, sd_dhcp6_client *client = userdata; DHCP6_CLIENT_DONT_DESTROY(client); _cleanup_free_ DHCP6Message *message = NULL; - int r, buflen, len; + ssize_t buflen, len; + int r = 0; assert(s); assert(client); assert(client->event); - r = ioctl(fd, FIONREAD, &buflen); - if (r < 0) - return -errno; - else if (buflen < 0) - /* This really should not happen */ - return -EIO; + buflen = next_datagram_size_fd(fd); + if (buflen < 0) + return buflen; message = malloc(buflen); if (!message) |