From ce1677906e9db258aebc74793d4c027c74e31ec5 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 15 Oct 2018 11:48:03 -0400 Subject: [PATCH] bgpd: Ensure that evpn_vtep_ip_cmp actually returns useful data The evpn_vtep_ip_cmp function must return positive and negative numbers for when we are doing sorted linked list inserts. Signed-off-by: Donald Sharp --- bgpd/bgp_evpn.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index 743fc4baa2..d6ed84ff56 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -70,16 +70,12 @@ static int delete_all_vni_routes(struct bgp *bgp, struct bgpevpn *vpn); */ /* compare two IPV4 VTEP IPs */ -static int evpn_vtep_ip_cmp(const void *p1, const void *p2) +static int evpn_vtep_ip_cmp(void *p1, void *p2) { const struct in_addr *ip1 = p1; const struct in_addr *ip2 = p2; - if (!ip1 && !ip2) - return 1; - if (!ip1 || !ip2) - return 0; - return (ip1->s_addr == ip2->s_addr); + return ip1->s_addr - ip2->s_addr; } /* @@ -5073,7 +5069,7 @@ struct evpnes *bgp_evpn_es_new(struct bgp *bgp, /* Initialise the VTEP list */ es->vtep_list = list_new(); - es->vtep_list->cmp = (int (*)(void *, void *))evpn_vtep_ip_cmp; + es->vtep_list->cmp = evpn_vtep_ip_cmp; /* auto derive RD for this es */ bf_assign_index(bm->rd_idspace, es->rd_id); -- 2.39.5