]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
lldp: deal properly with recv() returning EAGAIN/EINTR
authorLennart Poettering <lennart@poettering.net>
Thu, 2 Jun 2016 15:50:40 +0000 (17:50 +0200)
committerLennart Poettering <lennart@poettering.net>
Mon, 6 Jun 2016 17:59:08 +0000 (19:59 +0200)
It might very well return EAGAIN in case of packet checksum problems and
suchlike, hence let's better handle this nicely, the same way as we do it in
the other sd-network libraries for incoming datagrams.

src/libsystemd-network/sd-lldp.c

index c74deccd0c238021812e74c1044d70b4583b9fd9..66d5dbf2036868a27c754ee4a9ce4c4ceedd63fe 100644 (file)
@@ -216,8 +216,12 @@ static int lldp_receive_datagram(sd_event_source *s, int fd, uint32_t revents, v
                 return -ENOMEM;
 
         length = recv(fd, LLDP_NEIGHBOR_RAW(n), n->raw_size, MSG_DONTWAIT);
-        if (length < 0)
+        if (length < 0) {
+                if (errno == EAGAIN || errno == EINTR)
+                        return 0;
+
                 return log_lldp_errno(errno, "Failed to read LLDP datagram: %m");
+        }
 
         if ((size_t) length != n->raw_size) {
                 log_lldp("Packet size mismatch.");