]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
Remove "listen on VLAN" feature.
authorVincent Bernat <bernat@luffy.cx>
Tue, 8 Jun 2010 15:49:33 +0000 (17:49 +0200)
committerVincent Bernat <bernat@luffy.cx>
Tue, 8 Jun 2010 15:49:33 +0000 (17:49 +0200)
This feature was intrusive and not very well tested. We will replace
it with less code using the fact that a recent kernel is able to
listen on all VLAN is asked to.

configure.ac
man/lldpd.8
src/interfaces.c
src/lldpd.c
src/lldpd.h

index 97dd94e0549cdc8eb0c943aab4989a8a0055fe71..427569a8456d07e2946dfc3b0c0f3e8c707075ae 100644 (file)
@@ -227,9 +227,6 @@ lldp_ARG_ENABLE([lldpmed], [LLDP-MED extension], [yes])
 lldp_ARG_ENABLE([dot1], [Dot1 extension (VLAN stuff)], [yes])
 lldp_ARG_ENABLE([dot3], [Dot3 extension (PHY stuff)], [yes])
 
-#Listen on vlan
-lldp_ARG_ENABLE([listenvlan], [listen on any VLAN], [no])
-
 #######################
 # Output results
 AM_CONDITIONAL([HAVE_CHECK], [test x"$have_check" = x"yes"])
@@ -253,7 +250,6 @@ cat <<EOF
   LLDPMED........: $enable_lldpmed
   DOT1...........: $enable_dot1
   DOT3...........: $enable_dot3
-  Listen on VLAN.: $enable_listenvlan
   XML output.....: ${with_xml-no}
 ---------------------------------------------
 
index 71ca806b4f29cbbe2a75578ba568ce03a1d5ed19..e3e656a5300fd13666d2fe07cf5e0265d8f54dc5 100644 (file)
@@ -21,7 +21,7 @@
 .Nd LLDP daemon
 .Sh SYNOPSIS
 .Nm
-.Op Fl dvxcseikl
+.Op Fl dxcseikl
 .Op Fl S Ar description
 .Op Fl X Ar socket
 .Op Fl m Ar management
@@ -56,12 +56,6 @@ If this option is specified,
 will run in the foreground and log to
 .Em stderr .
 This option can be specified many times to increase verbosity.
-.It Fl v
-Listen on VLAN as well. This option might be needed if your equipment
-send frames on VLAN instead of physical interface. This option enables
-.Nm
-to receive frames on VLAN interfaces as well. If you don't need this
-option, do not set it.
 .It Fl k
 Disable advertising of kernel release, version and machine. Kernel name
 (ie: Linux) will still be shared, and Inventory software version will be set
index 46bb531847a28a0561ac66c7bc616da4f85a5e53..3ec2646f7b651fffeb97bbbff09bdb1c9a8d8f14 100644 (file)
@@ -95,11 +95,6 @@ static int    iface_eth_init(struct lldpd *, struct lldpd_hardware *);
 static int      iface_bond_init(struct lldpd *, struct lldpd_hardware *);
 static void     iface_fds_close(struct lldpd *, struct lldpd_hardware *);
 #ifdef ENABLE_DOT1
-#ifdef ENABLE_LISTENVLAN
-static void     iface_vlan_close(struct lldpd *, struct lldpd_hardware *);
-static void     iface_listen_vlan(struct lldpd *,
-    struct lldpd_hardware *, struct ifaddrs *);
-#endif
 static void     iface_append_vlan(struct lldpd *,
     struct lldpd_hardware *, struct ifaddrs *);
 #endif
@@ -679,9 +674,6 @@ iface_eth_recv(struct lldpd *cfg, struct lldpd_hardware *hardware,
 static int
 iface_eth_close(struct lldpd *cfg, struct lldpd_hardware *hardware)
 {
-#if defined(ENABLE_DOT1) && defined(ENABLE_LISTENVLAN)
-       iface_vlan_close(cfg, hardware);
-#endif
        close(hardware->h_sendfd);
        iface_multicast(cfg, hardware->h_ifname, 1);
        return 0;
@@ -856,9 +848,6 @@ iface_bond_recv(struct lldpd *cfg, struct lldpd_hardware *hardware,
 static int
 iface_bond_close(struct lldpd *cfg, struct lldpd_hardware *hardware)
 {
-#if defined(ENABLE_DOT1) && defined(ENABLE_LISTENVLAN)
-       iface_vlan_close(cfg, hardware);
-#endif
        iface_fds_close(cfg, hardware); /* h_sendfd is here too */
        iface_multicast(cfg, hardware->h_ifname, 1);
        iface_multicast(cfg, (char*)hardware->h_data, 1);
@@ -927,88 +916,6 @@ lldpd_ifh_bond(struct lldpd *cfg, struct ifaddrs *ifap)
 }
 
 #ifdef ENABLE_DOT1
-#ifdef ENABLE_LISTENVLAN
-/* We keep here the list of VLAN we listen to. */
-struct iface_vlans {
-       TAILQ_ENTRY(iface_vlans) next;
-       struct lldpd_hardware *hardware;
-       char vlan[IFNAMSIZ];
-       int fd;
-       int refreshed;
-};
-TAILQ_HEAD(, iface_vlans) ifvls;
-
-static void
-_iface_vlan_setup()
-{
-       static int done = 0;
-       if (done) return;
-       TAILQ_INIT(&ifvls);
-       done = 1;
-}
-
-/* Close the list of VLAN associated to the given hardware port if we have
-   requested the "listen on vlan" feature. If hardware is NULL, then use
-   `refreshed' to clean up. */
-static void
-iface_vlan_close(struct lldpd *cfg, struct lldpd_hardware *hardware)
-{
-       struct iface_vlans *ifvl, *ifvl_next;
-       if (!cfg->g_listen_vlans) return;
-       _iface_vlan_setup();
-       for (ifvl = TAILQ_FIRST(&ifvls); ifvl; ifvl = ifvl_next) {
-               ifvl_next = TAILQ_NEXT(ifvl, next);
-               if (hardware && (ifvl->hardware != hardware)) continue;
-               if (!hardware && (ifvl->refreshed)) continue;
-               close(ifvl->fd);
-               iface_multicast(cfg, ifvl->vlan, 1);
-               FD_CLR(ifvl->fd, &hardware->h_recvfds);
-               TAILQ_REMOVE(&ifvls, ifvl, next);
-               free(ifvl);
-       }
-}
-
-/* Listen on the given vlan on behalf of the given interface */
-static void
-iface_listen_vlan(struct lldpd *cfg,
-    struct lldpd_hardware *hardware, struct ifaddrs *ifa)
-{
-       struct iface_vlans *ifvl;
-       int fd;
-
-       if (!cfg->g_listen_vlans) return;
-       _iface_vlan_setup();
-       if (!(ifa->ifa_flags & IFF_RUNNING)) return;
-       TAILQ_FOREACH(ifvl, &ifvls, next)
-               if ((ifvl->hardware == hardware) &&
-                   (strncmp(ifvl->vlan, ifa->ifa_name, IFNAMSIZ) == 0)) break;
-       if (ifvl) {
-               ifvl->refreshed = 1;
-               return; /* We are already listening to it */
-       }
-       if ((ifvl = (struct iface_vlans *)
-               malloc(sizeof(struct iface_vlans))) == NULL)
-               return;         /* Just give up */
-
-       if ((fd = priv_iface_init(ifa->ifa_name)) == -1) {
-               free(ifvl);
-               return;
-       }
-       if (iface_set_filter(ifa->ifa_name, fd) != 0) {
-               free(ifvl);
-               close(fd);
-               return;
-       }
-       FD_SET(fd, &hardware->h_recvfds);
-       ifvl->fd = fd;
-       iface_multicast(cfg, ifa->ifa_name, 0);
-       ifvl->refreshed = 1;
-       strlcpy(ifvl->vlan, ifa->ifa_name, IFNAMSIZ);
-       ifvl->hardware = hardware;
-       TAILQ_INSERT_TAIL(&ifvls, ifvl, next);
-}
-#endif /* ENABLE_LISTENVLAN */
-
 static void
 iface_append_vlan(struct lldpd *cfg,
     struct lldpd_hardware *hardware, struct ifaddrs *ifa)
@@ -1039,10 +946,6 @@ iface_append_vlan(struct lldpd *cfg,
        }
        vlan->v_vid = ifv.u.VID;
        TAILQ_INSERT_TAIL(&port->p_vlans, vlan, v_entries);
-
-#ifdef ENABLE_LISTENVLAN
-       iface_listen_vlan(cfg, hardware, ifa);
-#endif
 }
 
 void
@@ -1052,15 +955,6 @@ lldpd_ifh_vlan(struct lldpd *cfg, struct ifaddrs *ifap)
        struct vlan_ioctl_args ifv;
        struct lldpd_hardware *hardware;
        
-#ifdef ENABLE_LISTENVLAN
-       struct iface_vlans *ifvl;
-       if (cfg->g_listen_vlans) {
-               _iface_vlan_setup();
-               TAILQ_FOREACH(ifvl, &ifvls, next)
-                   ifvl->refreshed = 0;
-       }
-#endif
-
        for (ifa = ifap; ifa != NULL; ifa = ifa->ifa_next) {
                if (!ifa->ifa_flags)
                        continue;
@@ -1103,9 +997,6 @@ lldpd_ifh_vlan(struct lldpd *cfg, struct ifaddrs *ifap)
                            hardware, ifa);
                }
        }
-#ifdef ENABLE_LISTENVLAN
-       iface_vlan_close(cfg, NULL);
-#endif
 }
 #endif
 
index f2a97d1a41ff1a27093f4317301380c6151e67cf..d9a64228d01c55bce0bcf7fb75b99d33c154de10 100644 (file)
@@ -117,9 +117,6 @@ usage(void)
 #endif
 #ifdef USE_SNMP
        fprintf(stderr, "-x       Enable SNMP subagent.\n");
-#endif
-#ifdef ENABLE_LISTENVLAN
-       fprintf(stderr, "-v       Listen on VLAN as well.\n");
 #endif
        fprintf(stderr, "\n");
 
@@ -836,14 +833,8 @@ lldpd_main(int argc, char *argv[])
 #endif
        char *mgmtp = NULL;
        char *popt, opts[] = 
-#ifdef ENABLE_LISTENVLAN
-               "v"
-#endif
                "hkdxX:m:p:M:S:i@                    ";
        int i, found, advertise_version = 1;
-#ifdef ENABLE_LISTENVLAN
-       int vlan = 0;
-#endif
 #ifdef ENABLE_LLDPMED
        int lldpmed = 0, noinventory = 0;
 #endif
@@ -863,11 +854,6 @@ lldpd_main(int argc, char *argv[])
                case 'h':
                        usage();
                        break;
-#ifdef ENABLE_LISTENVLAN
-               case 'v':
-                       vlan = 1;
-                       break;
-#endif
                case 'd':
                        debug++;
                        break;
@@ -959,9 +945,6 @@ lldpd_main(int argc, char *argv[])
 
        cfg->g_mgmt_pattern = mgmtp;
        cfg->g_advertise_version = advertise_version;
-#ifdef ENABLE_LISTENVLAN
-       cfg->g_listen_vlans = vlan;
-#endif
 
        /* Get ioctl socket */
        if ((cfg->g_sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
index 7bead7962089390851937733a275c39b0467cf2c..2f7eededf62c3197efa5628bad9bc5834a86f523 100644 (file)
@@ -288,9 +288,6 @@ struct lldpd {
        int                      g_delay;
 
        struct protocol         *g_protocols;
-#ifdef ENABLE_LISTENVLAN
-       int                      g_listen_vlans;
-#endif
 #ifdef ENABLE_LLDPMED
        int                      g_noinventory;
 #endif