From 10935633f43aabeeb8ce5abe865f484a0166b021 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Wed, 28 Dec 2011 10:55:08 +0100 Subject: [PATCH] Add a whitelist for some drivers (currently: dsa and veth) --- CHANGELOG | 1 + src/interfaces.c | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 4e2dc0da..991bf785 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ lldpd (0.5.6) * Features: + Send and receive native VLAN TLV with CDP + + Add a whitelist for some drivers (currently: dsa and veth) lldpd (0.5.5) * Features: diff --git a/src/interfaces.c b/src/interfaces.c index 918bf3c3..3c6d2175 100644 --- a/src/interfaces.c +++ b/src/interfaces.c @@ -396,6 +396,16 @@ iface_minimal_checks(struct lldpd *cfg, struct ifaddrs *ifa) { struct sockaddr_ll sdl; struct ifreq ifr; + struct ethtool_drvinfo ethc; + const char * const *rif; + + /* White-list some drivers */ + const char * const regular_interfaces[] = { + "dsa", + "veth", + NULL + }; + int is_bridge = iface_is_bridge(cfg, ifa->ifa_name); if (!(LOCAL_CHASSIS(cfg)->c_cap_enabled & LLDP_CAP_BRIDGE) && @@ -425,6 +435,22 @@ iface_minimal_checks(struct lldpd *cfg, struct ifaddrs *ifa) if (!(ifa->ifa_flags & (IFF_MULTICAST|IFF_BROADCAST))) return 0; + /* Check if the driver is whitelisted */ + memset(&ifr, 0, sizeof(ifr)); + strcpy(ifr.ifr_name, ifa->ifa_name); + ifr.ifr_data = (caddr_t) ðc; + ethc.cmd = ETHTOOL_GDRVINFO; + if (ioctl(cfg->g_sock, SIOCETHTOOL, &ifr) == 0) { + for (rif = regular_interfaces; *rif; rif++) { + if (strcmp(ethc.driver, *rif) == 0) { + /* White listed! */ + LLOG_DEBUG("%s is using %s: whitelisted", + ifa->ifa_name, ethc.driver); + return 1; + } + } + } + /* Check queue len. If no queue, this usually means that this is not a "real" interface. */ memset(&ifr, 0, sizeof(ifr)); -- 2.39.5