]> git.ipfire.org Git - thirdparty/lldpd.git/blobdiff - src/daemon/interfaces-linux.c
netlink: handle blocking read from netlink socket
[thirdparty/lldpd.git] / src / daemon / interfaces-linux.c
index 32aceb0e3525624a2d6f18cea7afa0a505df65b6..a8280c851ea9200e58cda2d3e93655192ca76c9c 100644 (file)
@@ -71,29 +71,6 @@ iflinux_eth_send(struct lldpd *cfg, struct lldpd_hardware *hardware,
            buffer, size);
 }
 
-static void
-iflinux_error_recv(struct lldpd_hardware *hardware, int fd)
-{
-       do {
-               ssize_t n;
-               char buf[1024] = {};
-               struct msghdr msg = {
-                       .msg_control = buf,
-                       .msg_controllen = sizeof(buf)
-               };
-               if ((n = recvmsg(fd, &msg, MSG_ERRQUEUE)) <= 0) {
-                       return;
-               }
-               struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msg);
-               if (cmsg == NULL)
-                       log_warnx("interfaces", "received unknown error on %s",
-                           hardware->h_ifname);
-               else
-                       log_warnx("interfaces", "received error (level=%d/type=%d) on %s",
-                           cmsg->cmsg_level, cmsg->cmsg_type, hardware->h_ifname);
-       } while (1);
-}
-
 static int
 iflinux_generic_recv(struct lldpd_hardware *hardware,
     int fd, char *buffer, size_t size,
@@ -110,7 +87,7 @@ retry:
                    &fromlen)) == -1) {
                if (errno == EAGAIN && retry == 0) {
                        /* There may be an error queued in the socket. Clear it and retry. */
-                       iflinux_error_recv(hardware, fd);
+                       levent_recv_error(fd, hardware->h_ifname);
                        retry++;
                        goto retry;
                }
@@ -446,21 +423,21 @@ struct ethtool_link_usettings {
        } link_modes;
 };
 
-static inline int
+static int
 iflinux_ethtool_link_mode_test_bit(unsigned int nr, const uint32_t *mask)
 {
        if (nr >= 32 * ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32)
                return 0;
        return !!(mask[nr / 32] & (1 << (nr % 32)));
 }
-static inline void
+static void
 iflinux_ethtool_link_mode_unset_bit(unsigned int nr, uint32_t *mask)
 {
        if (nr >= 32 * ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32)
                return;
        mask[nr / 32] &= ~(1 << (nr % 32));
 }
-static inline int
+static int
 iflinux_ethtool_link_mode_is_empty(const uint32_t *mask)
 {
        for (unsigned int i = 0;
@@ -671,6 +648,7 @@ iflinux_macphy(struct lldpd *cfg, struct lldpd_hardware *hardware)
 #endif /* ENABLE_DOT3 */
 
 
+#ifdef ENABLE_OLDIES
 struct bond_master {
        char name[IFNAMSIZ];
        int  index;
@@ -847,6 +825,7 @@ iflinux_handle_bond(struct lldpd *cfg, struct interfaces_device_list *interfaces
                hardware->h_mtu = iface->mtu ? iface->mtu : 1500;
        }
 }
+#endif
 
 /* Query each interface to get the appropriate driver */
 static void
@@ -992,7 +971,7 @@ iflinux_add_physical(struct lldpd *cfg,
                }
 
                /* If the interface is linked to another one, skip it too. */
-               if (iface->lower && (!iface->driver || strcmp(iface->driver, "veth"))) {
+               if (iface->lower && (!iface->driver || (strcmp(iface->driver, "veth") && strcmp(iface->driver, "dsa")))) {
                        log_debug("interfaces", "skip %s: there is a lower interface (%s)",
                            iface->name, iface->lower->name);
                        continue;
@@ -1032,7 +1011,9 @@ interfaces_update(struct lldpd *cfg)
        iflinux_add_physical(cfg, interfaces);
 
        interfaces_helper_whitelist(cfg, interfaces);
+#ifdef ENABLE_OLDIES
        iflinux_handle_bond(cfg, interfaces);
+#endif
        interfaces_helper_physical(cfg, interfaces,
            &eth_ops,
            iflinux_eth_init);