From 58fe6128171593b501513ff76a063ae13e52a056 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Sun, 11 Apr 2010 14:53:32 +0200 Subject: [PATCH] Ignore interfaces with no queue. This filters out vnet* interfaces and some others. It seems that physical (real or virtual) interfaces always have a queue. We might also check qdisc. If "noop", this means that the interface is a blackhole and should be ignored. However, we wait for an actual interface to exhibit a behaviour where such a detection is needed. --- CHANGELOG | 4 ++++ src/interfaces.c | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 2755ce75..702579fa 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,10 @@ lldpd (0.5.1) thanks to a patch from Jorge Boncompte. + Add a new output (keyvalue) for lldpctl. + * Fixes: + + Ignore interface with no queue. It should filter out interfaces + like "vnet0" that would fail if we try to send something on them. + lldpd (0.5.0) * Features: diff --git a/src/interfaces.c b/src/interfaces.c index 5192ee1f..5dbf3671 100644 --- a/src/interfaces.c +++ b/src/interfaces.c @@ -397,6 +397,7 @@ static int iface_minimal_checks(struct lldpd *cfg, struct ifaddrs *ifa) { struct sockaddr_ll *sdl; + struct ifreq ifr; int is_bridge = iface_is_bridge(cfg, ifa->ifa_name); if (!(LOCAL_CHASSIS(cfg)->c_cap_enabled & LLDP_CAP_BRIDGE) && @@ -426,6 +427,13 @@ iface_minimal_checks(struct lldpd *cfg, struct ifaddrs *ifa) if (!(ifa->ifa_flags & (IFF_MULTICAST|IFF_BROADCAST))) return 0; + /* Check queue len. If no queue, this usually means that this + is not a "real" interface. */ + memset(&ifr, 0, sizeof(ifr)); + strcpy(ifr.ifr_name, ifa->ifa_name); + if ((ioctl(cfg->g_sock, SIOCGIFTXQLEN, &ifr) < 0) || !ifr.ifr_qlen) + return 0; + /* Don't handle bond and VLAN, nor bridge */ if ((iface_is_vlan(cfg, ifa->ifa_name)) || (iface_is_bond(cfg, ifa->ifa_name)) || -- 2.39.5