zebra: Store the EVPN VRF in the default VRF

The EVPN VRF is defined by bgpd, and is the one vrf where
`advertise-all-vni` is present.

Signed-off-by: Tuetuopay <tuetuopay@me.com>
Sponsored-by: Scaleway
This commit is contained in:
Tuetuopay 2019-02-19 20:37:59 +00:00
parent e2f3a930c5
commit 150971b5ec
3 changed files with 32 additions and 11 deletions

View File

@ -107,23 +107,28 @@ struct zebra_vrf {
#define MPLS_FLAG_SCHEDULE_LSPS (1 << 0)
/*
* VNI hash table (for EVPN). Only in default instance.
* VNI hash table (for EVPN). Only in the EVPN instance.
*/
struct hash *vni_table;
/*
* Whether EVPN is enabled or not. Only in default instance.
* Whether EVPN is enabled or not. Only in the EVPN instance.
*/
int advertise_all_vni;
/*
* Whether we are advertising g/w macip in EVPN or not.
* Only in default instance.
* Only in the EVPN instance.
*/
int advertise_gw_macip;
int advertise_svi_macip;
/*
* The EVPN instance, if any
*/
vrf_id_t evpn_vrf_id;
/* l3-vni info */
vni_t l3vni;
@ -196,6 +201,17 @@ extern struct zebra_vrf *zebra_vrf_lookup_by_name(const char *);
extern struct zebra_vrf *zebra_vrf_alloc(void);
extern struct route_table *zebra_vrf_table(afi_t, safi_t, vrf_id_t);
static inline vrf_id_t zebra_vrf_get_evpn_id(void)
{
struct zebra_vrf *zvrf = NULL;
zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
return zvrf ? zvrf->evpn_vrf_id : VRF_DEFAULT;
}
static inline struct zebra_vrf *zebra_vrf_get_evpn(void)
{
return zebra_vrf_lookup_by_id(zebra_vrf_get_evpn_id());
}
extern struct route_table *
zebra_vrf_other_route_table(afi_t afi, uint32_t table_id, vrf_id_t vrf_id);
extern int zebra_vrf_has_config(struct zebra_vrf *zvrf);

View File

@ -324,7 +324,7 @@ static int advertise_gw_macip_enabled(zebra_vni_t *zvni)
{
struct zebra_vrf *zvrf;
zvrf = vrf_info_lookup(VRF_DEFAULT);
zvrf = zebra_vrf_get_evpn();
if (zvrf && zvrf->advertise_gw_macip)
return 1;
@ -9041,19 +9041,19 @@ void zebra_vxlan_advertise_all_vni(ZAPI_HANDLER_ARGS)
struct stream *s = NULL;
int advertise = 0;
enum vxlan_flood_control flood_ctrl;
struct zebra_vrf *zvrf_default = NULL;
if (zvrf_id(zvrf) != VRF_DEFAULT) {
zlog_debug("EVPN VNI Adv for non-default VRF %u",
zvrf_id(zvrf));
zvrf_default = zebra_vrf_lookup_by_id(VRF_DEFAULT);
if (!zvrf_default)
return;
}
s = msg;
STREAM_GETC(s, advertise);
STREAM_GETC(s, flood_ctrl);
if (IS_ZEBRA_DEBUG_VXLAN)
zlog_debug("EVPN VNI Adv %s, currently %s, flood control %u",
zlog_debug("EVPN VRF %s(%u) VNI Adv %s, currently %s, flood control %u",
zvrf_name(zvrf), zvrf_id(zvrf),
advertise ? "enabled" : "disabled",
is_evpn_enabled() ? "enabled" : "disabled",
flood_ctrl);
@ -9062,7 +9062,9 @@ void zebra_vxlan_advertise_all_vni(ZAPI_HANDLER_ARGS)
return;
zvrf->advertise_all_vni = advertise;
if (is_evpn_enabled()) {
if (zvrf->advertise_all_vni) {
zvrf_default->evpn_vrf_id = zvrf_id(zvrf);
/* Note BUM handling */
zvrf->vxlan_flood_ctrl = flood_ctrl;
@ -9086,6 +9088,9 @@ void zebra_vxlan_advertise_all_vni(ZAPI_HANDLER_ARGS)
/* cleanup all l3vnis */
hash_iterate(zrouter.l3vni_table, zl3vni_cleanup_all, NULL);
/* Fallback to the default VRF. */
zvrf_default->evpn_vrf_id = VRF_DEFAULT;
}
stream_failure:

View File

@ -40,7 +40,7 @@
static inline int is_evpn_enabled(void)
{
struct zebra_vrf *zvrf = NULL;
zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
zvrf = zebra_vrf_get_evpn();
return zvrf ? zvrf->advertise_all_vni : 0;
}