An ISID is 24 bits, so it fits in a uint32_t. A VLAN is 12 bits, so it
fits in a uint16_t. Use these types consistently, instead of int64_t.
This removes a check in aa_mapping_unregister() that seems a little
mysterious to me: it previously checked for ISID and VLAN values >= 0. I
don't see a way that they could be < 0 in this situation though.
Signed-off-by: Ben Pfaff <blp@nicira.com>
struct aa_mapping_internal {
struct hmap_node hmap_node_isid;
struct hmap_node hmap_node_aux;
struct aa_mapping_internal {
struct hmap_node hmap_node_isid;
struct hmap_node hmap_node_aux;
- int64_t isid;
- int64_t vlan;
+ uint32_t isid;
+ uint16_t vlan;
void *aux;
enum aa_status status;
};
void *aux;
enum aa_status status;
};
/* Find an Auto Attach mapping keyed by I-SID.
*/
static struct aa_mapping_internal *
/* Find an Auto Attach mapping keyed by I-SID.
*/
static struct aa_mapping_internal *
-mapping_find_by_isid(struct lldp *lldp, const uint64_t isid)
+mapping_find_by_isid(struct lldp *lldp, uint32_t isid)
OVS_REQUIRES(mutex)
{
struct aa_mapping_internal *m;
OVS_REQUIRES(mutex)
{
struct aa_mapping_internal *m;
- HMAP_FOR_EACH_IN_BUCKET (m,
- hmap_node_isid,
- hash_bytes(&isid, sizeof isid, 0),
+ HMAP_FOR_EACH_IN_BUCKET (m, hmap_node_isid, hash_int(isid, 0),
&lldp->mappings_by_isid) {
if (isid == m->isid) {
return m;
&lldp->mappings_by_isid) {
if (isid == m->isid) {
return m;
ds_put_format(ds, "-------- ---- ----------- --------\n");
HMAP_FOR_EACH (m, hmap_node_isid, &lldp->mappings_by_isid) {
ds_put_format(ds, "-------- ---- ----------- --------\n");
HMAP_FOR_EACH (m, hmap_node_isid, &lldp->mappings_by_isid) {
- ds_put_format(ds, "%-8ld %-4ld %-11s %-11s\n",
- (long int) m->isid,
- (long int) m->vlan,
- "Switch",
- aa_status_to_str(m->status));
+ ds_put_format(ds, "%-8"PRIu32" %-4"PRIu16" %-11s %-11s\n",
+ m->isid, m->vlan, "Switch", aa_status_to_str(m->status));
struct aa_mapping_internal *bridge_m;
struct lldp *lldp;
struct aa_mapping_internal *bridge_m;
struct lldp *lldp;
- VLOG_INFO("Adding mapping ISID=%ld, VLAN=%ld, aux=%p", (long int) s->isid,
- (long int) s->vlan, aux);
+ VLOG_INFO("Adding mapping ISID=%"PRIu32", VLAN=%"PRIu16", aux=%p",
+ s->isid, s->vlan, aux);
bridge_m->vlan = s->vlan;
bridge_m->aux = aux;
bridge_m->status = AA_STATUS_PENDING;
bridge_m->vlan = s->vlan;
bridge_m->aux = aux;
bridge_m->status = AA_STATUS_PENDING;
- hmap_insert(all_mappings,
- &bridge_m->hmap_node_isid,
- hash_bytes((const void *) &bridge_m->isid,
- sizeof bridge_m->isid,
- 0));
+ hmap_insert(all_mappings, &bridge_m->hmap_node_isid,
+ hash_int(bridge_m->isid, 0));
+
/* Update mapping on the all the LLDP instances. */
HMAP_FOR_EACH (lldp, hmap_node, all_lldps) {
/* Update mapping on the all the LLDP instances. */
HMAP_FOR_EACH (lldp, hmap_node, all_lldps) {
m->vlan = s->vlan;
m->status = AA_STATUS_PENDING;
m->aux = aux;
m->vlan = s->vlan;
m->status = AA_STATUS_PENDING;
m->aux = aux;
- hmap_insert(&lldp->mappings_by_isid,
- &m->hmap_node_isid,
- hash_bytes((const void *) &m->isid,
- sizeof m->isid,
- 0));
+ hmap_insert(&lldp->mappings_by_isid, &m->hmap_node_isid,
+ hash_int(m->isid, 0));
hmap_insert(&lldp->mappings_by_aux,
&m->hmap_node_aux,
hash_pointer(m->aux, 0));
hmap_insert(&lldp->mappings_by_aux,
&m->hmap_node_aux,
hash_pointer(m->aux, 0));
&hw->h_lport.p_isid_vlan_maps) {
uint32_t isid = lm->isid_vlan_data.isid;
&hw->h_lport.p_isid_vlan_maps) {
uint32_t isid = lm->isid_vlan_data.isid;
- if (isid == (uint32_t) m->isid) {
VLOG_INFO("\t\t Removing lport, isid=%u, vlan=%u",
isid,
lm->isid_vlan_data.vlan);
VLOG_INFO("\t\t Removing lport, isid=%u, vlan=%u",
isid,
lm->isid_vlan_data.vlan);
HMAP_FOR_EACH (lldp, hmap_node, all_lldps) {
struct lldpd_hardware *hw;
struct aa_mapping_internal *m = mapping_find_by_aux(lldp, aux);
HMAP_FOR_EACH (lldp, hmap_node, all_lldps) {
struct lldpd_hardware *hw;
struct aa_mapping_internal *m = mapping_find_by_aux(lldp, aux);
- int64_t isid_tmp = -1, vlan_tmp = -1;
/* Remove from internal hash tables. */
if (m) {
/* Remove from internal hash tables. */
if (m) {
- struct aa_mapping_internal *p =
- mapping_find_by_isid(lldp, m->isid);
+ uint32_t isid = m->isid;
+ uint16_t vlan = m->vlan;
+ struct aa_mapping_internal *p = mapping_find_by_isid(lldp, isid);
- isid_tmp = m->isid;
- vlan_tmp = m->vlan;
- VLOG_INFO("\t Removing mapping ISID=%ld, VLAN=%ld (lldp->name=%s)",
- (long int) m->isid, (long int) m->vlan, lldp->name);
+ VLOG_INFO("\t Removing mapping ISID=%"PRIu32", VLAN=%"PRIu16
+ " (lldp->name=%s)", isid, vlan, lldp->name);
if (p) {
hmap_remove(&lldp->mappings_by_isid, &p->hmap_node_isid);
if (p) {
hmap_remove(&lldp->mappings_by_isid, &p->hmap_node_isid);
aa_mapping_unregister_mapping(lldp, hw, m);
}
aa_mapping_unregister_mapping(lldp, hw, m);
}
- if (isid_tmp >= 0 && vlan_tmp >= 0) {
- /* Remove from the all_mappings */
- HMAP_FOR_EACH (m, hmap_node_isid, all_mappings) {
- if (m && isid_tmp == m->isid && vlan_tmp == m->vlan) {
- hmap_remove(all_mappings, &m->hmap_node_isid);
- break;
- }
+ /* Remove from the all_mappings */
+ HMAP_FOR_EACH (m, hmap_node_isid, all_mappings) {
+ if (m && isid == m->isid && vlan == m->vlan) {
+ hmap_remove(all_mappings, &m->hmap_node_isid);
+ break;
}
p = xmemdup(m, sizeof *p);
}
p = xmemdup(m, sizeof *p);
- hmap_insert(&lldp->mappings_by_isid,
- &p->hmap_node_isid,
- hash_bytes((const void *) &p->isid,
- sizeof p->isid,
- 0));
+ hmap_insert(&lldp->mappings_by_isid, &p->hmap_node_isid,
+ hash_int(p->isid, 0));
hmap_insert(&lldp->mappings_by_aux,
&p->hmap_node_aux,
hash_pointer(p->aux, 0));
hmap_insert(&lldp->mappings_by_aux,
&p->hmap_node_aux,
hash_pointer(p->aux, 0));
+ * Copyright (c) 2015 Nicira, Inc.
* Copyright (c) 2014 Wind River Systems, Inc.
* Copyright (c) 2015 Avaya, Inc.
*
* Copyright (c) 2014 Wind River Systems, Inc.
* Copyright (c) 2015 Avaya, Inc.
*
/* Configuration of Auto Attach mappings.
*/
struct aa_mapping_settings {
/* Configuration of Auto Attach mappings.
*/
struct aa_mapping_settings {
- int64_t isid;
- int64_t vlan;
+ uint32_t isid;
+ uint16_t vlan;
};
enum bridge_aa_vlan_oper {
};
enum bridge_aa_vlan_oper {
struct bridge_aa_vlan {
struct ovs_list list_node;
char *port_name;
struct bridge_aa_vlan {
struct ovs_list list_node;
char *port_name;
enum bridge_aa_vlan_oper oper;
};
enum bridge_aa_vlan_oper oper;
};
struct aa_mapping {
struct hmap_node hmap_node; /* In struct bridge's "mappings" hmap. */
struct bridge *bridge;
struct aa_mapping {
struct hmap_node hmap_node; /* In struct bridge's "mappings" hmap. */
struct bridge *bridge;
- int64_t isid;
- int64_t vlan;
+ uint32_t isid;
+ uint16_t vlan;
atom.integer = m->isid;
if (ovsdb_datum_find_key(mc, &atom, OVSDB_TYPE_UUID) == UINT_MAX) {
atom.integer = m->isid;
if (ovsdb_datum_find_key(mc, &atom, OVSDB_TYPE_UUID) == UINT_MAX) {
- VLOG_INFO("Deleting isid=%"PRId64", vlan=%"PRId64,
- m->isid,
- m->vlan);
+ VLOG_INFO("Deleting isid=%"PRIu32", vlan=%"PRIu16,
+ m->isid, m->vlan);
bridge_aa_mapping_destroy(m);
}
}
bridge_aa_mapping_destroy(m);
}
}