forked from Mirror/frr
*: Fixup to use proper list_cmp functions
We had a variety of issues with sorted list compare functions. This commit identifies and fixes these issues. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
440c39acfa
commit
27fa33984b
|
@ -59,7 +59,11 @@ int ospf6_neighbor_cmp(void *va, void *vb)
|
|||
{
|
||||
struct ospf6_neighbor *ona = (struct ospf6_neighbor *)va;
|
||||
struct ospf6_neighbor *onb = (struct ospf6_neighbor *)vb;
|
||||
return (ntohl(ona->router_id) < ntohl(onb->router_id) ? -1 : 1);
|
||||
|
||||
if (ona->router_id == onb->router_id)
|
||||
return 0;
|
||||
|
||||
return (ntohl(ona->router_id) < ntohl(onb->router_id)) ? -1 : 1;
|
||||
}
|
||||
|
||||
struct ospf6_neighbor *ospf6_neighbor_lookup(uint32_t router_id,
|
||||
|
|
|
@ -172,7 +172,10 @@ void rip_peer_display(struct vty *vty)
|
|||
|
||||
static int rip_peer_list_cmp(struct rip_peer *p1, struct rip_peer *p2)
|
||||
{
|
||||
return htonl(p1->addr.s_addr) > htonl(p2->addr.s_addr);
|
||||
if (p2->addr.s_addr == p1->addr.s_addr)
|
||||
return 0;
|
||||
|
||||
return (htonl(p2->addr.s_addr) < htonl(p1->addr.s_addr)) ? -1 : 1;
|
||||
}
|
||||
|
||||
void rip_peer_init(void)
|
||||
|
|
|
@ -180,7 +180,7 @@ void ripng_peer_display(struct vty *vty)
|
|||
|
||||
static int ripng_peer_list_cmp(struct ripng_peer *p1, struct ripng_peer *p2)
|
||||
{
|
||||
return addr6_cmp(&p1->addr, &p2->addr) > 0;
|
||||
return memcmp(&p1->addr, &p2->addr, sizeof(struct in6_addr));
|
||||
}
|
||||
|
||||
void ripng_peer_init()
|
||||
|
|
|
@ -1268,6 +1268,14 @@ static int neigh_cmp(const void *p1, const void *p2)
|
|||
return (memcmp(&n1->ip, &n2->ip, sizeof(struct ipaddr)) == 0);
|
||||
}
|
||||
|
||||
static int neigh_list_cmp(void *p1, void *p2)
|
||||
{
|
||||
const zebra_neigh_t *n1 = p1;
|
||||
const zebra_neigh_t *n2 = p2;
|
||||
|
||||
return memcmp(&n1->ip, &n2->ip, sizeof(struct ipaddr));
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback to allocate neighbor hash entry.
|
||||
*/
|
||||
|
@ -2275,7 +2283,7 @@ static zebra_mac_t *zvni_mac_add(zebra_vni_t *zvni, struct ethaddr *macaddr)
|
|||
assert(mac);
|
||||
|
||||
mac->neigh_list = list_new();
|
||||
mac->neigh_list->cmp = (int (*)(void *, void *))neigh_cmp;
|
||||
mac->neigh_list->cmp = neigh_list_cmp;
|
||||
|
||||
return mac;
|
||||
}
|
||||
|
@ -2761,6 +2769,16 @@ static int vni_hash_cmp(const void *p1, const void *p2)
|
|||
return (zvni1->vni == zvni2->vni);
|
||||
}
|
||||
|
||||
static int vni_list_cmp(void *p1, void *p2)
|
||||
{
|
||||
const zebra_vni_t *zvni1 = p1;
|
||||
const zebra_vni_t *zvni2 = p2;
|
||||
|
||||
if (zvni1->vni == zvni2->vni)
|
||||
return 0;
|
||||
return (zvni1->vni < zvni2->vni) ? -1 : 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback to allocate VNI hash entry.
|
||||
*/
|
||||
|
@ -3662,7 +3680,7 @@ static zebra_l3vni_t *zl3vni_add(vni_t vni, vrf_id_t vrf_id)
|
|||
zl3vni->svi_if = NULL;
|
||||
zl3vni->vxlan_if = NULL;
|
||||
zl3vni->l2vnis = list_new();
|
||||
zl3vni->l2vnis->cmp = (int (*)(void *, void *))vni_hash_cmp;
|
||||
zl3vni->l2vnis->cmp = vni_list_cmp;
|
||||
|
||||
/* Create hash table for remote RMAC */
|
||||
zl3vni->rmac_table = hash_create(mac_hash_keymake, mac_cmp,
|
||||
|
|
Loading…
Reference in a new issue