]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: The l2vni list compare function does not sort
authorDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 15 Oct 2018 15:41:39 +0000 (11:41 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Mon, 15 Oct 2018 15:41:39 +0000 (11:41 -0400)
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 <sharpd@cumulusnetworks.com>
bgpd/bgp_evpn.c

index 9e71f1855c1a5941a46e52e6649474bc18a8ba64..743fc4baa2f399747acbe6604568da1702e857b3 100644 (file)
@@ -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;