diff options
author | Renato Westphal <renato@openbsd.org> | 2018-10-16 03:51:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-16 03:51:03 +0200 |
commit | d725199ad91716d54360d2e628383a2615cd5165 (patch) | |
tree | 18663f1b4f851b544621c69e1014b772d41fdc2d /bgpd | |
parent | Merge pull request #3181 from qlyoung/frr-sss-indent (diff) | |
parent | bgpd: Ensure that evpn_vtep_ip_cmp actually returns useful data (diff) | |
download | frr-d725199ad91716d54360d2e628383a2615cd5165.tar.xz frr-d725199ad91716d54360d2e628383a2615cd5165.zip |
Merge pull request #3179 from donaldsharp/vni_cmp
bgpd: The l2vni list compare function does not sort
Diffstat (limited to 'bgpd')
-rw-r--r-- | bgpd/bgp_evpn.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index 9e71f1855..d6ed84ff5 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; } /* @@ -134,6 +130,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. */ @@ -5065,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); @@ -5722,7 +5726,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; |