|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
From 66a35872a2429a095f8cdfd5b00f94d0b28daa0f Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
From: Lennart Poettering <lennart@poettering.net>
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
Date: Mon, 15 Feb 2016 22:50:01 +0100
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
Subject: [PATCH] networkd: FIONREAD is not reliable on some sockets
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
Fixes: #2457
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
(cherry picked from commit 4edc2c9b6b5b921873eb82e58719ed4d9e0d69bf)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
src/basic/socket-util.c | 34 ++++++++++++++++++++++++++++++++
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
src/basic/socket-util.h | 2 ++
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
src/libsystemd-network/sd-dhcp-client.c | 23 +++++++++------------
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
src/libsystemd-network/sd-dhcp-server.c | 9 ++++-----
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
src/libsystemd-network/sd-dhcp6-client.c | 13 ++++++------
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
src/libsystemd-network/sd-ndisc.c | 13 +++++-------
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
src/resolve/resolved-manager.c | 10 ++++------
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
7 files changed, 64 insertions(+), 40 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
index 49e5f5b125..58512686e3 100644
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
--- a/src/basic/socket-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+++ b/src/basic/socket-util.c
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
@@ -936,3 +936,37 @@ int receive_one_fd(int transport_fd, int flags) {
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
return *(int*) CMSG_DATA(found);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
}
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ssize_t next_datagram_size_fd(int fd) {
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ ssize_t l;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ int k;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ /* This is a bit like FIONREAD/SIOCINQ, however a bit more powerful. The difference being: recv(MSG_PEEK) will
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ * actually cause the next datagram in the queue to be validated regarding checksums, which FIONREAD dosn't
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ * do. This difference is actually of major importance as we need to be sure that the size returned here
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ * actually matches what we will read with recvmsg() next, as otherwise we might end up allocating a buffer of
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ * the wrong size. */
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ l = recv(fd, NULL, 0, MSG_PEEK|MSG_TRUNC);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ if (l < 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ if (errno == EOPNOTSUPP)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ goto fallback;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ return -errno;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ }
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ if (l == 0)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ goto fallback;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ return l;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+fallback:
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ k = 0;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ /* Some sockets (AF_PACKET) do not support null-sized recv() with MSG_TRUNC set, let's fall back to FIONREAD
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ * for them. Checksums don't matter for raw sockets anyway, hence this should be fine. */
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ if (ioctl(fd, FIONREAD, &k) < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ return -errno;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ return (ssize_t) k;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+}
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
diff --git a/src/basic/socket-util.h b/src/basic/socket-util.h
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
index 92edc1dc22..d17a2f35f8 100644
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
--- a/src/basic/socket-util.h
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+++ b/src/basic/socket-util.h
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
@@ -133,5 +133,7 @@ int send_one_fd_sa(int transport_fd,
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
#define send_one_fd(transport_fd, fd, flags) send_one_fd_sa(transport_fd, fd, NULL, 0, flags)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
int receive_one_fd(int transport_fd, int flags);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ssize_t next_datagram_size_fd(int fd);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
#define CMSG_FOREACH(cmsg, mh) \
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
for ((cmsg) = CMSG_FIRSTHDR(mh); (cmsg); (cmsg) = CMSG_NXTHDR((mh), (cmsg)))
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
index cad1a52c09..729ef880ce 100644
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
--- a/src/libsystemd-network/sd-dhcp-client.c
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+++ b/src/libsystemd-network/sd-dhcp-client.c
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
@@ -1525,20 +1525,17 @@ static int client_receive_message_udp(sd_event_source *s, int fd,
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
uint32_t revents, void *userdata) {
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
sd_dhcp_client *client = userdata;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
_cleanup_free_ DHCPMessage *message = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- int buflen = 0, len, r;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
const struct ether_addr zero_mac = { { 0, 0, 0, 0, 0, 0 } };
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
const struct ether_addr *expected_chaddr = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
uint8_t expected_hlen = 0;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ ssize_t len, buflen;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
assert(s);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
assert(client);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- r = ioctl(fd, FIONREAD, &buflen);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- return -errno;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- else if (buflen < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- /* this can't be right */
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- return -EIO;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ buflen = next_datagram_size_fd(fd);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ if (buflen < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ return buflen;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
message = malloc0(buflen);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
if (!message)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
@@ -1616,17 +1613,15 @@ static int client_receive_message_raw(sd_event_source *s, int fd,
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
};
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
struct cmsghdr *cmsg;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
bool checksum = true;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- int buflen = 0, len, r;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ ssize_t buflen, len;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ int r;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
assert(s);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
assert(client);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- r = ioctl(fd, FIONREAD, &buflen);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- return -errno;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- else if (buflen < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- /* this can't be right */
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- return -EIO;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ buflen = next_datagram_size_fd(fd);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ if (buflen < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ return buflen;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
packet = malloc0(buflen);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
if (!packet)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
index ad3a37b722..54ff1a3f28 100644
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
--- a/src/libsystemd-network/sd-dhcp-server.c
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+++ b/src/libsystemd-network/sd-dhcp-server.c
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
@@ -955,14 +955,13 @@ static int server_receive_message(sd_event_source *s, int fd,
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
.msg_controllen = sizeof(cmsgbuf),
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
};
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
struct cmsghdr *cmsg;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- int buflen = 0, len;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ ssize_t buflen, len;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
assert(server);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- if (ioctl(fd, FIONREAD, &buflen) < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- return -errno;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- else if (buflen < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- return -EIO;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ buflen = next_datagram_size_fd(fd);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ if (buflen < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ return buflen;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
message = malloc(buflen);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
if (!message)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
index 5b6b9cbcac..7d56d4cc60 100644
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
--- a/src/libsystemd-network/sd-dhcp6-client.c
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+++ b/src/libsystemd-network/sd-dhcp6-client.c
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
@@ -33,6 +33,7 @@
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
#include "in-addr-util.h"
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
#include "network-internal.h"
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
#include "random-util.h"
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+#include "socket-util.h"
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
#include "string-table.h"
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
#include "util.h"
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
@@ -891,18 +892,16 @@ static int client_receive_message(sd_event_source *s, int fd, uint32_t revents,
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
sd_dhcp6_client *client = userdata;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
DHCP6_CLIENT_DONT_DESTROY(client);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
_cleanup_free_ DHCP6Message *message = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- int r, buflen, len;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ ssize_t buflen, len;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ int r = 0;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
assert(s);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
assert(client);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
assert(client->event);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- r = ioctl(fd, FIONREAD, &buflen);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- return -errno;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- else if (buflen < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- /* This really should not happen */
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- return -EIO;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ buflen = next_datagram_size_fd(fd);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ if (buflen < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ return buflen;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
message = malloc(buflen);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
if (!message)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
diff --git a/src/libsystemd-network/sd-ndisc.c b/src/libsystemd-network/sd-ndisc.c
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
index 519d2aa36b..bae6a49fe6 100644
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
--- a/src/libsystemd-network/sd-ndisc.c
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+++ b/src/libsystemd-network/sd-ndisc.c
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
@@ -491,19 +491,16 @@ static int ndisc_router_advertisment_recv(sd_event_source *s, int fd, uint32_t r
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
struct cmsghdr *cmsg;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
struct in6_addr *gw;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
unsigned lifetime;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- ssize_t len;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- int r, pref, stateful, buflen = 0;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ ssize_t len, buflen;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ int r, pref, stateful;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
assert(s);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
assert(nd);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
assert(nd->event);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- r = ioctl(fd, FIONREAD, &buflen);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- return -errno;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- else if (buflen < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- /* This really should not happen */
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- return -EIO;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ buflen = next_datagram_size_fd(fd);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ if (buflen < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ return buflen;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
iov.iov_len = buflen;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
index bf5efe4cfa..7f9073448a 100644
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
--- a/src/resolve/resolved-manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+++ b/src/resolve/resolved-manager.c
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
@@ -617,18 +617,16 @@ int manager_recv(Manager *m, int fd, DnsProtocol protocol, DnsPacket **ret) {
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
struct msghdr mh = {};
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
struct cmsghdr *cmsg;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
struct iovec iov;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- int ms = 0, r;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- ssize_t l;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ ssize_t ms, l;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ int r;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
assert(m);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
assert(fd >= 0);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
assert(ret);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- r = ioctl(fd, FIONREAD, &ms);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- return -errno;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ ms = next_datagram_size_fd(fd);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
if (ms < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
- return -EIO;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
+ return ms;
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
r = dns_packet_new(&p, protocol, ms);
|
|
Zbigniew Jędrzejewski-Szmek |
2b6823 |
if (r < 0)
|