zebra: Move the EVPN VRF pointer to zebra_router

It had no logical reason to be in the default VRF. This moves it to the
zebra_router, which is better suited to store global references.

Signed-off-by: Tuetuopay <tuetuopay@me.com>
Sponsored-by: Scaleway
This commit is contained in:
Tuetuopay 2019-03-27 02:16:27 +01:00
parent 986512a320
commit 0fb2ad05d9
4 changed files with 20 additions and 20 deletions

View File

@ -104,6 +104,11 @@ struct zebra_router {
/* Mlag information for the router */ /* Mlag information for the router */
struct zebra_mlag_info mlag_info; struct zebra_mlag_info mlag_info;
/*
* The EVPN instance, if any
*/
struct zebra_vrf *evpn_vrf;
}; };
extern struct zebra_router zrouter; extern struct zebra_router zrouter;
@ -127,4 +132,14 @@ extern void zebra_router_sweep_route(void);
extern void zebra_router_show_table_summary(struct vty *vty); extern void zebra_router_show_table_summary(struct vty *vty);
extern uint32_t zebra_router_get_next_sequence(void); extern uint32_t zebra_router_get_next_sequence(void);
static inline vrf_id_t zebra_vrf_get_evpn_id(void)
{
return zrouter.evpn_vrf ? zvrf_id(zrouter.evpn_vrf) : VRF_DEFAULT;
}
static inline struct zebra_vrf *zebra_vrf_get_evpn(void)
{
return zrouter.evpn_vrf ? zrouter.evpn_vrf
: zebra_vrf_lookup_by_id(VRF_DEFAULT);
}
#endif #endif

View File

@ -124,11 +124,6 @@ struct zebra_vrf {
int advertise_svi_macip; int advertise_svi_macip;
/*
* The EVPN instance, if any
*/
vrf_id_t evpn_vrf_id;
/* l3-vni info */ /* l3-vni info */
vni_t l3vni; vni_t l3vni;
@ -201,15 +196,6 @@ extern struct zebra_vrf *zebra_vrf_lookup_by_name(const char *);
extern struct zebra_vrf *zebra_vrf_alloc(void); extern struct zebra_vrf *zebra_vrf_alloc(void);
extern struct route_table *zebra_vrf_table(afi_t, safi_t, vrf_id_t); 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)
{
return zebra_vrf_lookup_by_id(VRF_DEFAULT)->evpn_vrf_id;
}
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 * extern struct route_table *
zebra_vrf_other_route_table(afi_t afi, uint32_t table_id, vrf_id_t vrf_id); 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); extern int zebra_vrf_has_config(struct zebra_vrf *zvrf);

View File

@ -9042,9 +9042,6 @@ void zebra_vxlan_advertise_all_vni(ZAPI_HANDLER_ARGS)
struct stream *s = NULL; struct stream *s = NULL;
int advertise = 0; int advertise = 0;
enum vxlan_flood_control flood_ctrl; enum vxlan_flood_control flood_ctrl;
struct zebra_vrf *zvrf_default = NULL;
zvrf_default = zebra_vrf_lookup_by_id(VRF_DEFAULT);
/* Mismatch between EVPN VRF and current VRF (should be prevented by /* Mismatch between EVPN VRF and current VRF (should be prevented by
* bgpd's cli) */ * bgpd's cli) */
@ -9067,7 +9064,7 @@ void zebra_vxlan_advertise_all_vni(ZAPI_HANDLER_ARGS)
zvrf->advertise_all_vni = advertise; zvrf->advertise_all_vni = advertise;
if (EVPN_ENABLED(zvrf)) { if (EVPN_ENABLED(zvrf)) {
zvrf_default->evpn_vrf_id = zvrf_id(zvrf); zrouter.evpn_vrf = zvrf;
/* Note BUM handling */ /* Note BUM handling */
zvrf->vxlan_flood_ctrl = flood_ctrl; zvrf->vxlan_flood_ctrl = flood_ctrl;
@ -9093,8 +9090,8 @@ void zebra_vxlan_advertise_all_vni(ZAPI_HANDLER_ARGS)
/* cleanup all l3vnis */ /* cleanup all l3vnis */
hash_iterate(zrouter.l3vni_table, zl3vni_cleanup_all, NULL); hash_iterate(zrouter.l3vni_table, zl3vni_cleanup_all, NULL);
/* Fallback to the default VRF. */ /* Mark as "no EVPN VRF" */
zvrf_default->evpn_vrf_id = VRF_DEFAULT; zrouter.evpn_vrf = NULL;
} }
stream_failure: stream_failure:
@ -9135,6 +9132,7 @@ void zebra_vxlan_init(void)
{ {
zrouter.l3vni_table = hash_create(l3vni_hash_keymake, l3vni_hash_cmp, zrouter.l3vni_table = hash_create(l3vni_hash_keymake, l3vni_hash_cmp,
"Zebra VRF L3 VNI table"); "Zebra VRF L3 VNI table");
zrouter.evpn_vrf = NULL;
} }
/* free l3vni table */ /* free l3vni table */

View File

@ -25,6 +25,7 @@
#define _ZEBRA_VXLAN_H #define _ZEBRA_VXLAN_H
#include <zebra.h> #include <zebra.h>
#include <zebra/zebra_router.h>
#include "linklist.h" #include "linklist.h"
#include "if.h" #include "if.h"