]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/zebra_vrf.c
zebra: print unknown rule family as number
[mirror_frr.git] / zebra / zebra_vrf.c
index 63430549438d9e9c1eef998066c9ae0c17d1fa24..c392303760503c4b33812a66aeb408b6cceef46a 100644 (file)
@@ -29,6 +29,7 @@
 #include "vty.h"
 
 #include "zebra/zebra_router.h"
+#include "zebra/rtadv.h"
 #include "zebra/debug.h"
 #include "zebra/zapi_msg.h"
 #include "zebra/rib.h"
@@ -47,7 +48,8 @@ static void zebra_vrf_table_create(struct zebra_vrf *zvrf, afi_t afi,
 static void zebra_rnhtable_node_cleanup(struct route_table *table,
                                        struct route_node *node);
 
-DEFINE_MTYPE_STATIC(ZEBRA, OTHER_TABLE, "Other Table");
+DEFINE_MTYPE_STATIC(ZEBRA, ZEBRA_VRF, "ZEBRA VRF")
+DEFINE_MTYPE_STATIC(ZEBRA, OTHER_TABLE, "Other Table")
 
 /* VRF information update. */
 static void zebra_vrf_add_update(struct zebra_vrf *zvrf)
@@ -90,7 +92,7 @@ static int zebra_vrf_new(struct vrf *vrf)
        struct zebra_vrf *zvrf;
 
        if (IS_ZEBRA_DEBUG_EVENT)
-               zlog_info("VRF %s created, id %u", vrf->name, vrf->vrf_id);
+               zlog_debug("VRF %s created, id %u", vrf->name, vrf->vrf_id);
 
        zvrf = zebra_vrf_alloc();
        vrf->info = zvrf;
@@ -119,6 +121,10 @@ static int zebra_vrf_enable(struct vrf *vrf)
                zvrf->zns = zebra_ns_lookup((ns_id_t)vrf->vrf_id);
        else
                zvrf->zns = zebra_ns_lookup(NS_DEFAULT);
+#if defined(HAVE_RTADV)
+       rtadv_init(zvrf);
+#endif
+
        /* Inform clients that the VRF is now active. This is an
         * add for the clients.
         */
@@ -161,6 +167,10 @@ static int zebra_vrf_disable(struct vrf *vrf)
        /* Stop any VxLAN-EVPN processing. */
        zebra_vxlan_vrf_disable(zvrf);
 
+#if defined(HAVE_RTADV)
+       rtadv_terminate(zvrf);
+#endif
+
        /* Inform clients that the VRF is now inactive. This is a
         * delete for the clients.
         */
@@ -333,13 +343,12 @@ int zebra_vrf_has_config(struct zebra_vrf *zvrf)
  * - case VRF backend is default : on default VRF only
  * - case VRF backend is netns : on all VRFs
  */
-struct route_table *zebra_vrf_table_with_table_id(afi_t afi, safi_t safi,
-                                                 vrf_id_t vrf_id,
-                                                 uint32_t table_id)
+struct route_table *zebra_vrf_lookup_table_with_table_id(afi_t afi, safi_t safi,
+                                                        vrf_id_t vrf_id,
+                                                        uint32_t table_id)
 {
        struct zebra_vrf *zvrf = vrf_info_lookup(vrf_id);
        struct other_route_table ort, *otable;
-       struct route_table *table;
 
        if (!zvrf)
                return NULL;
@@ -354,9 +363,28 @@ struct route_table *zebra_vrf_table_with_table_id(afi_t afi, safi_t safi,
        ort.safi = safi;
        ort.table_id = table_id;
        otable = otable_find(&zvrf->other_tables, &ort);
+
        if (otable)
                return otable->table;
 
+       return NULL;
+}
+
+struct route_table *zebra_vrf_get_table_with_table_id(afi_t afi, safi_t safi,
+                                                     vrf_id_t vrf_id,
+                                                     uint32_t table_id)
+{
+       struct zebra_vrf *zvrf = vrf_info_lookup(vrf_id);
+       struct other_route_table *otable;
+       struct route_table *table;
+
+       table = zebra_vrf_lookup_table_with_table_id(afi, safi, vrf_id,
+                                                    table_id);
+
+       if (table)
+               goto done;
+
+       /* Create it as an `other` table */
        table = zebra_router_get_table(zvrf, table_id, afi, safi);
 
        otable = XCALLOC(MTYPE_OTHER_TABLE, sizeof(*otable));
@@ -366,6 +394,7 @@ struct route_table *zebra_vrf_table_with_table_id(afi_t afi, safi_t safi,
        otable->table = table;
        otable_add(&zvrf->other_tables, otable);
 
+done:
        return table;
 }
 
@@ -477,7 +506,16 @@ static int vrf_config_write(struct vty *vty)
 
                if (zvrf_id(zvrf) == VRF_DEFAULT) {
                        if (zvrf->l3vni)
-                               vty_out(vty, "vni %u\n", zvrf->l3vni);
+                               vty_out(vty, "vni %u%s\n", zvrf->l3vni,
+                                       is_l3vni_for_prefix_routes_only(
+                                               zvrf->l3vni)
+                                               ? " prefix-routes-only"
+                                               : "");
+                       if (zvrf->zebra_rnh_ip_default_route)
+                               vty_out(vty, "ip nht resolve-via-default\n");
+
+                       if (zvrf->zebra_rnh_ipv6_default_route)
+                               vty_out(vty, "ipv6 nht resolve-via-default\n");
                } else {
                        vty_frame(vty, "vrf %s\n", zvrf_name(zvrf));
                        if (zvrf->l3vni)
@@ -487,8 +525,14 @@ static int vrf_config_write(struct vty *vty)
                                                ? " prefix-routes-only"
                                                : "");
                        zebra_ns_config_write(vty, (struct ns *)vrf->ns_ctxt);
+                       if (zvrf->zebra_rnh_ip_default_route)
+                               vty_out(vty, " ip nht resolve-via-default\n");
+
+                       if (zvrf->zebra_rnh_ipv6_default_route)
+                               vty_out(vty, " ipv6 nht resolve-via-default\n");
                }
 
+
                zebra_routemap_config_write_protocol(vty, zvrf);
 
                if (zvrf_id(zvrf) != VRF_DEFAULT)