]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
edp: steal IP addresses from the received chassis instead of copying them
authorVincent Bernat <bernat@luffy.cx>
Thu, 15 Mar 2012 20:52:08 +0000 (21:52 +0100)
committerVincent Bernat <bernat@luffy.cx>
Thu, 15 Mar 2012 21:17:06 +0000 (22:17 +0100)
The received chassis information will be discarded, there is no need
to copy them. We behave like for VLAN.

src/edp.c

index a0d980dfac3ae7c78615f389ca2d5bff852dcdb6..4770e879b5718cfd8c1f11189bb99652862ec51f 100644 (file)
--- a/src/edp.c
+++ b/src/edp.c
@@ -230,7 +230,7 @@ edp_decode(struct lldpd *cfg, char *frame, int s,
 {
        struct lldpd_chassis *chassis;
        struct lldpd_port *port;
-       struct lldpd_mgmt *mgmt, *m;
+       struct lldpd_mgmt *mgmt, *mgmt_next;
 #ifdef ENABLE_DOT1
        struct lldpd_vlan *lvlan = NULL, *lvlan_next;
 #endif
@@ -463,15 +463,13 @@ edp_decode(struct lldpd *cfg, char *frame, int s,
                                            lvlan, v_entries);
                                }
                                /* And the IP address */
-                               TAILQ_FOREACH(mgmt, &chassis->c_mgmt, m_entries) {
-                                       m = lldpd_alloc_mgmt(mgmt->m_family,
-                                                       &mgmt->m_addr, mgmt->m_addrsize, mgmt->m_iface);
-                                       if (m == NULL) {
-                                               assert(errno == ENOMEM);
-                                               LLOG_WARN("Out of memory");
-                                               goto malformed;
-                                       }
-                                       TAILQ_INSERT_TAIL(&oport->p_chassis->c_mgmt, m, m_entries);
+                               for (mgmt = TAILQ_FIRST(&chassis->c_mgmt);
+                                    mgmt != NULL;
+                                    mgmt = mgmt_next) {
+                                       mgmt_next = TAILQ_NEXT(mgmt, m_entries);
+                                       TAILQ_REMOVE(&chassis->c_mgmt, mgmt, m_entries);
+                                       TAILQ_INSERT_TAIL(&oport->p_chassis->c_mgmt,
+                                           mgmt, m_entries);
                                }
                        }
                        /* We discard the remaining frame */