Skip to content

Commit

Permalink
lldp-structs: Fix use of list of struct lldpd_mgmt.
Browse files Browse the repository at this point in the history
A list of some type should have type "struct ovs_list", not some other
type that encapsulates it.

Signed-off-by: Ben Pfaff <blp@nicira.com>
  • Loading branch information
blp committed Mar 4, 2015
1 parent 854560f commit 3259017
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 17 deletions.
6 changes: 3 additions & 3 deletions lib/lldp/lldp.c
Expand Up @@ -208,7 +208,7 @@ lldp_send(struct lldpd *global OVS_UNUSED,
lldp_tlv_put_u16(p, chassis->c_cap_enabled);
lldp_tlv_end(p, start);

LIST_FOR_EACH (mgmt, m_entries, &chassis->c_mgmt.m_entries) {
LIST_FOR_EACH (mgmt, m_entries, &chassis->c_mgmt) {
lldp_tlv_start(p, LLDP_TLV_MGMT_ADDR, &start);
lldp_tlv_put_u8(p, mgmt->m_addrsize + 1);
lldp_tlv_put_u8(p, lldpd_af_to_lldp_proto(mgmt->m_family));
Expand Down Expand Up @@ -355,7 +355,7 @@ lldp_decode(struct lldpd *cfg OVS_UNUSED, char *frame, int s,
VLOG_DBG("receive LLDP PDU on %s", hardware->h_ifname);

chassis = xzalloc(sizeof *chassis);
list_init(&chassis->c_mgmt.m_entries);
list_init(&chassis->c_mgmt);

port = xzalloc(sizeof *port);
list_init(&port->p_isid_vlan_maps);
Expand Down Expand Up @@ -483,7 +483,7 @@ lldp_decode(struct lldpd *cfg OVS_UNUSED, char *frame, int s,
VLOG_WARN("unable to allocate memory for management address");
goto malformed;
}
list_push_back(&chassis->c_mgmt.m_entries, &mgmt->m_entries);
list_push_back(&chassis->c_mgmt, &mgmt->m_entries);
break;

case LLDP_TLV_ORG:
Expand Down
7 changes: 2 additions & 5 deletions lib/lldp/lldpd-structs.c
Expand Up @@ -33,15 +33,12 @@ lldpd_chassis_mgmt_cleanup(struct lldpd_chassis *chassis)
VLOG_DBG("cleanup management addresses for chassis %s",
chassis->c_name ? chassis->c_name : "(unknown)");

LIST_FOR_EACH_SAFE (mgmt,
mgmt_next,
m_entries,
&chassis->c_mgmt.m_entries) {
LIST_FOR_EACH_SAFE (mgmt, mgmt_next, m_entries, &chassis->c_mgmt) {
list_remove(&mgmt->m_entries);
free(mgmt);
}

list_init(&chassis->c_mgmt.m_entries);
list_init(&chassis->c_mgmt);
}

void
Expand Down
2 changes: 1 addition & 1 deletion lib/lldp/lldpd-structs.h
Expand Up @@ -77,7 +77,7 @@ struct lldpd_chassis {

u_int16_t c_ttl;

struct lldpd_mgmt c_mgmt;
struct ovs_list c_mgmt; /* Contains "struct lldp_mgmt"s. */
};
/* WARNING: any change to this structure should also be reflected into
`lldpd_copy_chassis()` which is not using marshaling. */
Expand Down
9 changes: 3 additions & 6 deletions lib/lldp/lldpd.c
Expand Up @@ -181,15 +181,12 @@ lldpd_move_chassis(struct lldpd_chassis *ochassis,
* marshaling.
*/
memcpy(ochassis, chassis, sizeof *ochassis);
list_init(&ochassis->c_mgmt.m_entries);
list_init(&ochassis->c_mgmt);

/* Copy of management addresses */
LIST_FOR_EACH_SAFE (mgmt,
mgmt_next,
m_entries,
&chassis->c_mgmt.m_entries) {
LIST_FOR_EACH_SAFE (mgmt, mgmt_next, m_entries, &chassis->c_mgmt) {
list_remove(&mgmt->m_entries);
list_insert(&ochassis->c_mgmt.m_entries, &mgmt->m_entries);
list_insert(&ochassis->c_mgmt, &mgmt->m_entries);
}

/* Restore saved values */
Expand Down
4 changes: 2 additions & 2 deletions lib/ovs-lldp.c
Expand Up @@ -824,7 +824,7 @@ lldp_create(const struct netdev *netdev,
lchassis->c_id = xmalloc(ETH_ADDR_LEN);
netdev_get_etheraddr(netdev, (uint8_t *) lchassis->c_id);

list_init(&lchassis->c_mgmt.m_entries);
list_init(&lchassis->c_mgmt);
lchassis->c_ttl = lldp->lldpd->g_config.c_tx_interval *
lldp->lldpd->g_config.c_tx_hold;
lchassis->c_ttl = LLDP_CHASSIS_TTL;
Expand Down Expand Up @@ -921,7 +921,7 @@ lldp_create_dummy(void)
lchassis->c_id_len = ETH_ADDR_LEN;
lchassis->c_id = xmalloc(ETH_ADDR_LEN);

list_init(&lchassis->c_mgmt.m_entries);
list_init(&lchassis->c_mgmt);
lchassis->c_ttl = LLDP_CHASSIS_TTL;
lldpd_assign_cfg_to_protocols(lldp->lldpd);
list_init(&lldp->lldpd->g_chassis.list);
Expand Down

0 comments on commit 3259017

Please sign in to comment.