From: Vincent Bernat Date: Thu, 4 Jun 2009 21:26:25 +0000 (+0200) Subject: Make "listen on vlan" feature optional at compile-time. X-Git-Tag: 0.5.0~63 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=993a6e50892da6b758ecd380079ce1514451e89c;p=thirdparty%2Flldpd.git Make "listen on vlan" feature optional at compile-time. The code to handle this feature is a bit kludgy and it seems safer to compile out this feature by default. --- diff --git a/configure.ac b/configure.ac index 947400e1..6242de6b 100644 --- a/configure.ac +++ b/configure.ac @@ -174,4 +174,16 @@ else AC_MSG_RESULT(no) fi +#Listen on vlan +AC_ARG_ENABLE(listenvlan, AC_HELP_STRING([--enable-listenvlan], + [Allow to listen on VLAN]), + [enable_listenvlan=$enableval],[enable_listenvlan=no]) +AC_MSG_CHECKING(whether to allow to listen on VLAN) +if test x$enable_listenvlan = xyes; then + AC_MSG_RESULT(yes) + AC_DEFINE([ENABLE_LISTENVLAN],, [Allow to listen on VLAN]) +else + AC_MSG_RESULT(no) +fi + AC_OUTPUT diff --git a/src/interfaces.c b/src/interfaces.c index 923b8126..d5a37687 100644 --- a/src/interfaces.c +++ b/src/interfaces.c @@ -94,9 +94,11 @@ 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 @@ -619,7 +621,7 @@ iface_eth_recv(struct lldpd *cfg, struct lldpd_hardware *hardware, static int iface_eth_close(struct lldpd *cfg, struct lldpd_hardware *hardware) { -#ifdef ENABLE_DOT1 +#if defined(ENABLE_DOT1) && defined(ENABLE_LISTENVLAN) iface_vlan_close(cfg, hardware); #endif close(hardware->h_sendfd); @@ -794,7 +796,7 @@ iface_bond_recv(struct lldpd *cfg, struct lldpd_hardware *hardware, static int iface_bond_close(struct lldpd *cfg, struct lldpd_hardware *hardware) { -#ifdef ENABLE_DOT1 +#if defined(ENABLE_DOT1) && defined(ENABLE_LISTENVLAN) iface_vlan_close(cfg, hardware); #endif iface_fds_close(cfg, hardware); /* h_sendfd is here too */ @@ -862,6 +864,7 @@ 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; @@ -940,6 +943,7 @@ iface_listen_vlan(struct lldpd *cfg, ifvl->hardware = hardware; TAILQ_INSERT_TAIL(&ifvls, ifvl, next); } +#endif /* ENABLE_LISTENVLAN */ static void iface_append_vlan(struct lldpd *cfg, @@ -972,7 +976,9 @@ 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 @@ -981,13 +987,15 @@ lldpd_ifh_vlan(struct lldpd *cfg, struct ifaddrs *ifap) struct ifaddrs *ifa; struct vlan_ioctl_args ifv; struct lldpd_hardware *hardware; - struct iface_vlans *ifvl; +#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) @@ -1029,7 +1037,9 @@ 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 85ec04fa..dfd19d0d 100644 --- a/src/lldpd.c +++ b/src/lldpd.c @@ -725,8 +725,15 @@ main(int argc, char *argv[]) int snmp = 0; #endif char *mgmtp = NULL; - char *popt, opts[] = "vdxm:p:M:i@ "; - int i, found, vlan = 0; + char *popt, opts[] = +#ifdef ENABLE_LISTENVLAN + "v" +#endif + "dxm:p:M:i@ "; + int i, found; +#ifdef ENABLE_LISTENVLAN + int vlan = 0; +#endif #ifdef ENABLE_LLDPMED int lldpmed = 0, noinventory = 0; #endif @@ -744,9 +751,11 @@ main(int argc, char *argv[]) *popt = '\0'; while ((ch = getopt(argc, argv, opts)) != -1) { switch (ch) { +#ifdef ENABLE_LISTENVLAN case 'v': vlan = 1; break; +#endif case 'd': debug++; break; @@ -819,7 +828,9 @@ main(int argc, char *argv[]) fatal(NULL); cfg->g_mgmt_pattern = mgmtp; +#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 5e772f16..24620e7e 100644 --- a/src/lldpd.h +++ b/src/lldpd.h @@ -272,7 +272,9 @@ struct lldpd { int g_delay; struct protocol *g_protocols; +#ifdef ENABLE_LISTENVLAN int g_listen_vlans; +#endif #ifdef ENABLE_LLDPMED int g_noinventory; #endif