]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
Add a whitelist for some drivers (currently: dsa and veth)
authorVincent Bernat <bernat@luffy.cx>
Wed, 28 Dec 2011 09:55:08 +0000 (10:55 +0100)
committerVincent Bernat <bernat@luffy.cx>
Wed, 28 Dec 2011 09:55:08 +0000 (10:55 +0100)
CHANGELOG
src/interfaces.c

index 4e2dc0da500c36d31055fa042459f2b96e287374..991bf785b8ff43cf4821cc8d26ecfaaea08e3a73 100644 (file)
--- 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:
index 918bf3c32421a11f11fc231929142b15bca1b2a7..3c6d217597ee430356e3e3bc70304b901b6f89c0 100644 (file)
@@ -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) &ethc;
+       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));