diff options
author | Tuetuopay <tuetuopay@me.com> | 2019-03-27 02:16:27 +0100 |
---|---|---|
committer | Tuetuopay <tuetuopay@me.com> | 2019-03-27 02:16:27 +0100 |
commit | 0fb2ad05d9e11a211915208e3fa648c8e170e31e (patch) | |
tree | be11673f4ca34ef658cf1e66814aa3d7d526c485 /zebra | |
parent | zebra: Change checks for EVPN VRF to a macro (diff) | |
download | frr-0fb2ad05d9e11a211915208e3fa648c8e170e31e.tar.xz frr-0fb2ad05d9e11a211915208e3fa648c8e170e31e.zip |
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
Diffstat (limited to 'zebra')
-rw-r--r-- | zebra/zebra_router.h | 15 | ||||
-rw-r--r-- | zebra/zebra_vrf.h | 14 | ||||
-rw-r--r-- | zebra/zebra_vxlan.c | 10 | ||||
-rw-r--r-- | zebra/zebra_vxlan.h | 1 |
4 files changed, 20 insertions, 20 deletions
diff --git a/zebra/zebra_router.h b/zebra/zebra_router.h index fb2849591..a60a0b7be 100644 --- a/zebra/zebra_router.h +++ b/zebra/zebra_router.h @@ -104,6 +104,11 @@ struct zebra_router { /* Mlag information for the router */ struct zebra_mlag_info mlag_info; + + /* + * The EVPN instance, if any + */ + struct zebra_vrf *evpn_vrf; }; 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 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 diff --git a/zebra/zebra_vrf.h b/zebra/zebra_vrf.h index 115d2b9d0..f6566d02a 100644 --- a/zebra/zebra_vrf.h +++ b/zebra/zebra_vrf.h @@ -124,11 +124,6 @@ struct zebra_vrf { int advertise_svi_macip; - /* - * The EVPN instance, if any - */ - vrf_id_t evpn_vrf_id; - /* l3-vni info */ 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 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 * 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); diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index c7a5e1ad8..70c5aa7c8 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -9042,9 +9042,6 @@ 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; - - zvrf_default = zebra_vrf_lookup_by_id(VRF_DEFAULT); /* Mismatch between EVPN VRF and current VRF (should be prevented by * bgpd's cli) */ @@ -9067,7 +9064,7 @@ void zebra_vxlan_advertise_all_vni(ZAPI_HANDLER_ARGS) zvrf->advertise_all_vni = advertise; if (EVPN_ENABLED(zvrf)) { - zvrf_default->evpn_vrf_id = zvrf_id(zvrf); + zrouter.evpn_vrf = zvrf; /* Note BUM handling */ zvrf->vxlan_flood_ctrl = flood_ctrl; @@ -9093,8 +9090,8 @@ 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; + /* Mark as "no EVPN VRF" */ + zrouter.evpn_vrf = NULL; } stream_failure: @@ -9135,6 +9132,7 @@ void zebra_vxlan_init(void) { zrouter.l3vni_table = hash_create(l3vni_hash_keymake, l3vni_hash_cmp, "Zebra VRF L3 VNI table"); + zrouter.evpn_vrf = NULL; } /* free l3vni table */ diff --git a/zebra/zebra_vxlan.h b/zebra/zebra_vxlan.h index 46165cf4d..409f1c3f7 100644 --- a/zebra/zebra_vxlan.h +++ b/zebra/zebra_vxlan.h @@ -25,6 +25,7 @@ #define _ZEBRA_VXLAN_H #include <zebra.h> +#include <zebra/zebra_router.h> #include "linklist.h" #include "if.h" |