]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: Move the EVPN VRF pointer to zebra_router
authorTuetuopay <tuetuopay@me.com>
Wed, 27 Mar 2019 01:16:27 +0000 (02:16 +0100)
committerTuetuopay <tuetuopay@me.com>
Wed, 27 Mar 2019 01:16:27 +0000 (02:16 +0100)
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
zebra/zebra_router.h
zebra/zebra_vrf.h
zebra/zebra_vxlan.c
zebra/zebra_vxlan.h

index fb28495917ab9990cebc06be458598cb0c3a7cfb..a60a0b7be9aeac6d705b111e2e901fd5abe4ae81 100644 (file)
@@ -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
index 115d2b9d0196102281a94f8718c30537a5bd4c94..f6566d02ac8eea9d65d0eca25b0002b30d5198e1 100644 (file)
@@ -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);
index c7a5e1ad86374694c885e9617a70b74ef529c123..70c5aa7c8a68ed601858397fac69812cae3563db 100644 (file)
@@ -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 */
index 46165cf4daff23175bea4115df9e77f2fa074361..409f1c3f7ff544edb4996dbb83e691c67b4cd83e 100644 (file)
@@ -25,6 +25,7 @@
 #define _ZEBRA_VXLAN_H
 
 #include <zebra.h>
+#include <zebra/zebra_router.h>
 
 #include "linklist.h"
 #include "if.h"