]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: Store the EVPN VRF in the default VRF
authorTuetuopay <tuetuopay@me.com>
Tue, 19 Feb 2019 20:37:59 +0000 (20:37 +0000)
committerTuetuopay <tuetuopay@me.com>
Tue, 19 Mar 2019 10:56:25 +0000 (11:56 +0100)
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
zebra/zebra_vrf.h
zebra/zebra_vxlan.c
zebra/zebra_vxlan.h

index e35101d83313d6ba6a92c2df525cb505fd812bfc..3574f4b67c333a6ebf5c30ae1ffc139253e049c6 100644 (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);
index 9a7d20bc498560c4a981e14c685692cf9ccb0043..fe7391f740b12a98d1146777df418cec493ad211 100644 (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:
index 2cf21ff90b649c0a2997e54513f0a97e05347294..38fef4b988c6b39bb3a952c0d1f38347d212081b 100644 (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;
 }