]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
Blacklist VMWare interfaces (as per ticket #40).
authorVincent Bernat <bernat@luffy.cx>
Sun, 25 Apr 2010 10:26:17 +0000 (12:26 +0200)
committerVincent Bernat <bernat@luffy.cx>
Sun, 25 Apr 2010 10:26:37 +0000 (12:26 +0200)
CHANGELOG
src/interfaces.c
src/lldpd.c
src/lldpd.h

index 702579fa2a5fb0bbe1189e358ac82919edadc2a0..9a120a5973dd28574af5c7a22f4ac9c1674b2b7e 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -10,8 +10,8 @@ lldpd (0.5.1)
     + 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.
+    + Ignore interface with no queue.
+    + Ignore VMWare interfaces.
 
 lldpd (0.5.0)
 
index 5dbf3671e3f155081a433661a65d6926be339817..5d01c9a7680f6854e64b892fd5094bbe159fe845 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/sockios.h>
 #include <linux/filter.h>
 #include <linux/if_packet.h>
+#include <regex.h>
 
 #define SYSFS_PATH_MAX 256
 #define MAX_PORTS 1024
@@ -617,6 +618,35 @@ iface_fds_close(struct lldpd *cfg, struct lldpd_hardware *hardware)
                }
 }
 
+void
+lldpd_ifh_blacklist(struct lldpd *cfg, struct ifaddrs *ifap)
+{
+       struct ifaddrs *ifa;
+       const char* blacklisted[] = {
+               "vnet[0-9][0-9]*",
+               NULL
+       };
+       const char **f;
+       regex_t preg;
+
+       for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
+               if (!ifa->ifa_flags)
+                       continue;
+
+               for (f=blacklisted; *f != NULL; f++) {
+                       if (regcomp(&preg, *f, REG_NOSUB) != 0)
+                               /* Should not happen */
+                               fatal("unable to compile a regex");
+                       if (regexec(&preg, ifa->ifa_name, 0, NULL, 0) == 0) {
+                               regfree(&preg);
+                               break;
+                       }
+                       regfree(&preg);
+               }
+               if (*f != NULL)
+                       ifa->ifa_flags = 0; /* Blacklisted */
+       }
+}
 
 static int
 iface_eth_init(struct lldpd *cfg, struct lldpd_hardware *hardware)
index f2a97d1a41ff1a27093f4317301380c6151e67cf..09ac080931f00c92a457de702b143266bcf4b772 100644 (file)
@@ -745,6 +745,7 @@ lldpd_update_localports(struct lldpd *cfg)
        struct ifaddrs *ifap;
        struct lldpd_hardware *hardware;
        lldpd_ifhandlers ifhs[] = {
+               lldpd_ifh_blacklist, /* Do not handle those interfaces */
                lldpd_ifh_bond, /* Handle bond */
                lldpd_ifh_eth,  /* Handle classic ethernet interfaces */
 #ifdef ENABLE_DOT1
index 7bead7962089390851937733a275c39b0467cf2c..376ef0432821dba80f8c677ea1d2eee8fe2940f3 100644 (file)
@@ -404,6 +404,7 @@ int  ctl_msg_pack_structure(char *, void *, unsigned int, struct hmsg *, void **
 int     ctl_msg_unpack_structure(char *, void *, unsigned int, struct hmsg *, void **);
 
 /* interfaces.c */
+void    lldpd_ifh_blacklist(struct lldpd *, struct ifaddrs *);
 void    lldpd_ifh_bond(struct lldpd *, struct ifaddrs *);
 void    lldpd_ifh_eth(struct lldpd *, struct ifaddrs *);
 #ifdef ENABLE_DOT1