From: Vincent Bernat Date: Tue, 8 Jun 2010 15:49:33 +0000 (+0200) Subject: Remove "listen on VLAN" feature. X-Git-Tag: 0.5.1~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0dced9547193d217b1d94e4020c803dd3a86810d;p=thirdparty%2Flldpd.git Remove "listen on VLAN" feature. 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. --- diff --git a/configure.ac b/configure.ac index 97dd94e0..427569a8 100644 --- a/configure.ac +++ b/configure.ac @@ -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 <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 diff --git a/src/lldpd.c b/src/lldpd.c index f2a97d1a..d9a64228 100644 --- a/src/lldpd.c +++ b/src/lldpd.c @@ -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) diff --git a/src/lldpd.h b/src/lldpd.h index 7bead796..2f7eeded 100644 --- a/src/lldpd.h +++ b/src/lldpd.h @@ -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