{
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,
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)
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()
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.
*/
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;
}
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.
*/
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,