[ovs-dev] [PATCH 16/32] lldp-structs: Fix use of list of struct lldpd_port.

Ben Pfaff blp at nicira.com
Mon Feb 23 05:20:08 UTC 2015


A list of some type should have type "struct ovs_list", not some other
type that encapsulates it.

Signed-off-by: Ben Pfaff <blp at nicira.com>
---
 lib/lldp/lldpd-structs.c |  4 ++--
 lib/lldp/lldpd-structs.h |  2 +-
 lib/lldp/lldpd.c         | 20 ++++++++++----------
 lib/ovs-lldp.c           |  4 ++--
 4 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/lib/lldp/lldpd-structs.c b/lib/lldp/lldpd-structs.c
index d440df9..fefc552 100644
--- a/lib/lldp/lldpd-structs.c
+++ b/lib/lldp/lldpd-structs.c
@@ -68,7 +68,7 @@ lldpd_remote_cleanup(struct lldpd_hardware *hw,
     time_t now = time_now();
 
     VLOG_DBG("cleanup remote port on %s", hw->h_ifname);
-    LIST_FOR_EACH_SAFE (port, port_next, p_entries, &hw->h_rports.p_entries) {
+    LIST_FOR_EACH_SAFE (port, port_next, p_entries, &hw->h_rports) {
         bool del = all;
         if (!all && expire &&
             (now >= port->p_lastupdate + port->p_chassis->c_ttl)) {
@@ -89,7 +89,7 @@ lldpd_remote_cleanup(struct lldpd_hardware *hw,
         }
     }
     if (all) {
-        list_init(&hw->h_rports.p_entries);
+        list_init(&hw->h_rports);
     }
 }
 
diff --git a/lib/lldp/lldpd-structs.h b/lib/lldp/lldpd-structs.h
index 1ea2225..64ca093 100644
--- a/lib/lldp/lldpd-structs.h
+++ b/lib/lldp/lldpd-structs.h
@@ -202,7 +202,7 @@ struct lldpd_hardware {
                                       * is a change
                                       */
     struct lldpd_port h_lport;  /* Port attached to this hardware port */
-    struct lldpd_port h_rports; /* Remote ports */
+    struct ovs_list h_rports;   /* Contains "struct lldp_port"s. */
 };
 
 struct lldpd_interface;
diff --git a/lib/lldp/lldpd.c b/lib/lldp/lldpd.c
index 03d58fd..eb32269 100644
--- a/lib/lldp/lldpd.c
+++ b/lib/lldp/lldpd.c
@@ -89,7 +89,7 @@ lldpd_alloc_hardware(struct lldpd *cfg, char *name, int index)
     hw->h_lport.p_chassis = (struct lldpd_chassis *)
     list_front(&cfg->g_chassis.list);
     hw->h_lport.p_chassis->c_refcount++;
-    list_init(&hw->h_rports.p_entries);
+    list_init(&hw->h_rports);
 
     return hw;
 }
@@ -258,7 +258,7 @@ lldpd_decode(struct lldpd *cfg, char *frame, int s,
         s -= 4;
     }
 
-    LIST_FOR_EACH (oport, p_entries, &hw->h_rports.p_entries) {
+    LIST_FOR_EACH (oport, p_entries, &hw->h_rports) {
         if ((oport->p_lastframe != NULL) &&
             (oport->p_lastframe->size == s) &&
             (memcmp(oport->p_lastframe->frame, frame, s) == 0)) {
@@ -300,7 +300,7 @@ lldpd_decode(struct lldpd *cfg, char *frame, int s,
     /* Do we already have the same MSAP somewhere? */
     VLOG_DBG("search for the same MSAP");
 
-    LIST_FOR_EACH (oport, p_entries, &hw->h_rports.p_entries) {
+    LIST_FOR_EACH (oport, p_entries, &hw->h_rports) {
         if (port->p_protocol == oport->p_protocol) {
             count++;
             if ((port->p_id_subtype == oport->p_id_subtype) &&
@@ -385,7 +385,7 @@ lldpd_decode(struct lldpd *cfg, char *frame, int s,
     port->p_lastframe = xmalloc(s + sizeof(struct lldpd_frame));
     port->p_lastframe->size = s;
     memcpy(port->p_lastframe->frame, frame, s);
-    list_insert(&hw->h_rports.p_entries, &port->p_entries);
+    list_insert(&hw->h_rports, &port->p_entries);
 
     port->p_chassis = chassis;
     port->p_chassis->c_refcount++;
@@ -403,7 +403,7 @@ lldpd_decode(struct lldpd *cfg, char *frame, int s,
      * of the chassis that was attached to it is decreased.
      */
     /* coverity[use_after_free] TAILQ_REMOVE does the right thing */
-    i = list_size((struct ovs_list *) &hw->h_rports);
+    i = list_size(&hw->h_rports);
     VLOG_DBG("%"PRIuSIZE " neighbors for %s", i, hw->h_ifname);
 
     if (!oport)  {
@@ -431,7 +431,7 @@ lldpd_hide_ports(struct lldpd *cfg,
         protocols[i] = 0;
     }
 
-    LIST_FOR_EACH (port, p_entries, &hw->h_rports.p_entries) {
+    LIST_FOR_EACH (port, p_entries, &hw->h_rports) {
         protocols[port->p_protocol]++;
     }
 
@@ -459,7 +459,7 @@ lldpd_hide_ports(struct lldpd *cfg,
     }
 
     /* We set the p_hidden flag to 1 if the protocol is disabled */
-    LIST_FOR_EACH (port, p_entries, &hw->h_rports.p_entries) {
+    LIST_FOR_EACH (port, p_entries, &hw->h_rports) {
         if (mask == SMART_OUTGOING) {
             port->p_hidden_out = protocols[port->p_protocol] ? false : true;
         } else {
@@ -472,7 +472,7 @@ lldpd_hide_ports(struct lldpd *cfg,
         (SMART_OUTGOING_ONE_NEIGH | SMART_INCOMING_ONE_NEIGH)) {
         found = false;
 
-        LIST_FOR_EACH (port, p_entries, &hw->h_rports.p_entries) {
+        LIST_FOR_EACH (port, p_entries, &hw->h_rports) {
             if (mask == SMART_OUTGOING) {
                 if (found) {
                     port->p_hidden_out = true;
@@ -498,7 +498,7 @@ lldpd_hide_ports(struct lldpd *cfg,
     }
 
     k = j = 0;
-    LIST_FOR_EACH (port, p_entries, &hw->h_rports.p_entries) {
+    LIST_FOR_EACH (port, p_entries, &hw->h_rports) {
         if (!(((mask == SMART_OUTGOING) && port->p_hidden_out) ||
               ((mask == SMART_INCOMING) && port->p_hidden_in))) {
             k++;
@@ -608,7 +608,7 @@ lldpd_send(struct lldpd_hardware *hw, struct ofpbuf *p)
             }
         }
 
-        LIST_FOR_EACH (port, p_entries, &hw->h_rports.p_entries) {
+        LIST_FOR_EACH (port, p_entries, &hw->h_rports) {
             /* If this remote port is disabled, we don't consider it */
             if (port->p_hidden_out) {
                 continue;
diff --git a/lib/ovs-lldp.c b/lib/ovs-lldp.c
index 23dd46e..0d0cedc 100644
--- a/lib/ovs-lldp.c
+++ b/lib/ovs-lldp.c
@@ -200,7 +200,7 @@ aa_print_element_status_port(struct ds *ds, struct lldpd_hardware *hw)
 {
     struct lldpd_port *port;
 
-    LIST_FOR_EACH (port, p_entries, &hw->h_rports.p_entries) {
+    LIST_FOR_EACH (port, p_entries, &hw->h_rports) {
         if (memcmp(&port->p_element.system_id,
                    &system_id_null,
                    sizeof port->p_element.system_id)) {
@@ -291,7 +291,7 @@ aa_print_isid_status_port(struct lldp *lldp, struct lldpd_hardware *hw)
 {
     struct lldpd_port *port;
 
-    LIST_FOR_EACH (port, p_entries, &hw->h_rports.p_entries) {
+    LIST_FOR_EACH (port, p_entries, &hw->h_rports) {
         aa_print_isid_status_port_isid(lldp, port);
     }
 }
-- 
2.1.3




More information about the dev mailing list