]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
interfaces: don't block when sending LLDP frames branch-0.5 49/head
authorVincent Bernat <bernat@luffy.cx>
Wed, 26 Sep 2012 22:21:45 +0000 (00:21 +0200)
committerVincent Bernat <bernat@luffy.cx>
Wed, 26 Sep 2012 22:21:45 +0000 (00:21 +0200)
It seems that in some situations, sending on a network interface (a
virtual one for example) could block. We circumvent this by making the
interface non blocking before sending.

CHANGELOG
src/interfaces.c

index 6b40e2677216a7d198abf18417758b55ea557455..efee53e264d7a417faaf5d0f2d9675bd8c38f14d 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+lldpd (0.5.8)
+ * Fixes:
+    + Don't block when sending LLDP frames.
+
 lldpd (0.5.7)
  * Fixes:
     + Configure issue with NetSNMP and some linkers
index c35bc8405dda5f7e42b861135a431550939f402d..57d25298eb0d1328944a999965bb72afd9525f0b 100644 (file)
@@ -132,6 +132,14 @@ struct lldpd_ops bond_ops = {
        .cleanup = iface_bond_close,
 };
 
+static void
+make_nonblock(int fd)
+{
+       int flags;
+       if ((flags = fcntl(fd, F_GETFL, NULL)) < 0) return;
+       fcntl(fd, F_SETFL, flags | O_NONBLOCK);
+}
+
 static int
 old_iface_is_bridge(struct lldpd *cfg, const char *name)
 {
@@ -683,6 +691,7 @@ static int
 iface_eth_send(struct lldpd *cfg, struct lldpd_hardware *hardware,
     char *buffer, size_t size)
 {
+       make_nonblock(hardware->h_sendfd);
        return write(hardware->h_sendfd,
            buffer, size);
 }
@@ -888,6 +897,7 @@ iface_bond_send(struct lldpd *cfg, struct lldpd_hardware *hardware,
                }
                memset(buffer + ETH_ALEN, 0, ETH_ALEN);
        }
+       make_nonblock(hardware->h_sendfd);
        return write(hardware->h_sendfd,
            buffer, size);
 }