]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
There are duplicate in the list of address we give to handler
authorVincent Bernat <bernat@luffy.cx>
Thu, 4 Jun 2009 21:16:36 +0000 (23:16 +0200)
committerVincent Bernat <bernat@luffy.cx>
Thu, 4 Jun 2009 21:16:36 +0000 (23:16 +0200)
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.

src/interfaces.c

index 0ee860b499823706823245726fe3ad9b63a72514..923b81261f5ae2ee29e78e2844aadb651c93d34d 100644 (file)
@@ -653,8 +653,10 @@ lldpd_ifh_eth(struct lldpd *cfg, struct ifaddrs *ifap)
                        }
                        hardware->h_ops = &eth_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;