From: Vincent Bernat Date: Thu, 4 Jun 2009 21:16:36 +0000 (+0200) Subject: There are duplicate in the list of address we give to handler X-Git-Tag: 0.5.0~64 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cfe00f7f1a5b65e4586acfdf58d49769d9ee48d8;p=thirdparty%2Flldpd.git There are duplicate in the list of address we give to handler functions. We need to acknowledge this correctly. For bonds and regular interfaces, just check that h_flags is 0 before trying to get information one more time. For VLAN, check if the VLAN is already present in the list. --- diff --git a/src/interfaces.c b/src/interfaces.c index 0ee860b4..923b8126 100644 --- a/src/interfaces.c +++ b/src/interfaces.c @@ -653,8 +653,10 @@ lldpd_ifh_eth(struct lldpd *cfg, struct ifaddrs *ifap) } hardware->h_ops = ð_ops; TAILQ_INSERT_TAIL(&cfg->g_hardware, hardware, h_entries); - } else + } else { + if (hardware->h_flags) continue; /* Already seen this time */ lldpd_port_cleanup(&hardware->h_lport, 0); + } port = &hardware->h_lport; hardware->h_flags = ifa->ifa_flags; /* Should be non-zero */ @@ -833,6 +835,7 @@ lldpd_ifh_bond(struct lldpd *cfg, struct ifaddrs *ifap) hardware->h_ops = &bond_ops; TAILQ_INSERT_TAIL(&cfg->g_hardware, hardware, h_entries); } else { + if (hardware->h_flags) continue; /* Already seen this time */ memset(hardware->h_data, 0, IFNAMSIZ); if_indextoname(master, hardware->h_data); lldpd_port_cleanup(&hardware->h_lport, 0); @@ -946,6 +949,10 @@ iface_append_vlan(struct lldpd *cfg, struct lldpd_vlan *vlan; struct vlan_ioctl_args ifv; + /* Check if the VLAN is already here. */ + TAILQ_FOREACH(vlan, &port->p_vlans, v_entries) + if (strncmp(ifa->ifa_name, vlan->v_name, IFNAMSIZ) == 0) + return; if ((vlan = (struct lldpd_vlan *) calloc(1, sizeof(struct lldpd_vlan))) == NULL) return;