From: Donald Sharp Date: Mon, 15 Oct 2018 15:41:39 +0000 (-0400) Subject: bgpd: The l2vni list compare function does not sort X-Git-Tag: frr-7.1-dev~269^2~1 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=644657850ac5315478fbd14fb706c1c85fa8eae1;p=mirror%2Ffrr.git bgpd: The l2vni list compare function does not sort The purpose of adding a l2vni as an sorted list is shot in the foot when the l2vni compare function only returns 0 or 1. This will cause subtle crashes when we add sorted and we end up with multiple list node pointing to the same thing. Signed-off-by: Donald Sharp --- diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index 9e71f1855c..743fc4baa2 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -134,6 +134,14 @@ static int vni_hash_cmp(const void *p1, const void *p2) return (vpn1->vni == vpn2->vni); } +static int vni_list_cmp(void *p1, void *p2) +{ + const struct bgpevpn *vpn1 = p1; + const struct bgpevpn *vpn2 = p2; + + return vpn1->vni - vpn2->vni; +} + /* * Make vrf import route target hash key. */ @@ -5722,7 +5730,7 @@ void bgp_evpn_init(struct bgp *bgp) (int (*)(void *, void *))evpn_route_target_cmp; bgp->vrf_export_rtl->del = evpn_xxport_delete_ecomm; bgp->l2vnis = list_new(); - bgp->l2vnis->cmp = (int (*)(void *, void *))vni_hash_cmp; + bgp->l2vnis->cmp = vni_list_cmp; /* Default BUM handling is to do head-end replication. */ bgp->vxlan_flood_ctrl = VXLAN_FLOOD_HEAD_END_REPL;