From 655b04d1c2fdcc056ff3c431468462a9b8a051c3 Mon Sep 17 00:00:00 2001 From: Mitesh Kanjariya Date: Mon, 13 Nov 2017 23:12:15 -0800 Subject: [PATCH] zebra/bgpd: cleanup l3vni on no advertise-all-vni EVPN is only enabled when user configures advertise-all-vni. All VNIs (L2 and L3) should be cleared upon removal of this config. Signed-off-by: Mitesh Kanjariya --- bgpd/bgp_evpn.c | 2 +- zebra/zebra_vxlan.c | 29 +++++++++++++++++++++++++---- zebra/zebra_vxlan_private.h | 4 +++- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index 6d898afdd0..cb74515b91 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -1856,7 +1856,7 @@ static int uninstall_evpn_route_entry_in_vrf(struct bgp *bgp_vrf, memset(pp, 0, sizeof(struct prefix)); if (evp->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE) ip_prefix_from_type2_prefix(evp, pp); - else if(evp->prefix.route_type == BGP_EVPN_IP_PREFIX_ROUTE) + else if (evp->prefix.route_type == BGP_EVPN_IP_PREFIX_ROUTE) ip_prefix_from_type5_prefix(evp, pp); if (bgp_debug_zebra(NULL)) { diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index 767fc03081..8c06298ec5 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -2818,6 +2818,19 @@ static void zvni_cleanup_all(struct hash_backet *backet, void *zvrf) zvni_del(zvni); } +/* cleanup L3VNI */ +static void zl3vni_cleanup_all(struct hash_backet *backet, + void *args) +{ + zebra_l3vni_t *zl3vni = NULL; + + zl3vni = (zebra_l3vni_t *)backet->data; + if (!zl3vni) + return; + + zebra_vxlan_process_l3vni_oper_down(zl3vni); +} + static int is_host_present_in_host_list(struct list *list, struct prefix *host) { @@ -3588,7 +3601,7 @@ static int zl3vni_send_del_to_client(zebra_l3vni_t *zl3vni) static void zebra_vxlan_process_l3vni_oper_up(zebra_l3vni_t *zl3vni) { if (IS_ZEBRA_DEBUG_VXLAN) - zlog_debug("L3-VNI %u is UP - send add to BGP and update all neigh enries", + zlog_debug("L3-VNI %u is UP - send add to BGP", zl3vni->vni); /* send l3vni add to BGP */ @@ -3598,7 +3611,7 @@ static void zebra_vxlan_process_l3vni_oper_up(zebra_l3vni_t *zl3vni) static void zebra_vxlan_process_l3vni_oper_down(zebra_l3vni_t *zl3vni) { if (IS_ZEBRA_DEBUG_VXLAN) - zlog_debug("L3-VNI %u is Down - send del to BGP and update all neigh enries", + zlog_debug("L3-VNI %u is Down - Send del to BGP", zl3vni->vni); /* send l3-vni del to BGP*/ @@ -6499,8 +6512,9 @@ stream_failure: int zebra_vxlan_advertise_all_vni(struct zserv *client, u_short length, struct zebra_vrf *zvrf) { - struct stream *s; - int advertise; + struct stream *s = NULL; + int advertise = 0; + struct zebra_ns *zns = NULL; if (zvrf_id(zvrf) != VRF_DEFAULT) { zlog_err("EVPN VNI Adv for non-default VRF %u", @@ -6538,6 +6552,13 @@ int zebra_vxlan_advertise_all_vni(struct zserv *client, * kernel and free entries. */ hash_iterate(zvrf->vni_table, zvni_cleanup_all, zvrf); + + /* cleanup all l3vnis */ + zns = zebra_ns_lookup(NS_DEFAULT); + if (!zns) + return -1; + + hash_iterate(zns->l3vni_table, zl3vni_cleanup_all, NULL); } stream_failure: diff --git a/zebra/zebra_vxlan_private.h b/zebra/zebra_vxlan_private.h index 8aeb46c945..ef6f9b99cb 100644 --- a/zebra/zebra_vxlan_private.h +++ b/zebra/zebra_vxlan_private.h @@ -30,6 +30,7 @@ #include "if.h" #include "linklist.h" +#include "zebra_vxlan.h" #define ERR_STR_SZ 256 @@ -165,6 +166,7 @@ static inline const char *zl3vni_rmac2str(zebra_l3vni_t *zl3vni, char *buf, /* * l3-vni is oper up when: + * 0. if EVPN is enabled (advertise-all-vni cfged) * 1. it is associated to a vxlan-intf * 2. Associated vxlan-intf is oper up * 3. it is associated to an SVI @@ -172,7 +174,7 @@ static inline const char *zl3vni_rmac2str(zebra_l3vni_t *zl3vni, char *buf, */ static inline int is_l3vni_oper_up(zebra_l3vni_t *zl3vni) { - return (zl3vni && + return (is_evpn_enabled() && zl3vni && (zl3vni->vrf_id != VRF_UNKNOWN) && zl3vni->vxlan_if && if_is_operative(zl3vni->vxlan_if) && zl3vni->svi_if && if_is_operative(zl3vni->svi_if)); -- 2.39.5