summaryrefslogtreecommitdiffstats
path: root/zebra/zebra_vrf.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/zebra_vrf.c')
-rw-r--r--zebra/zebra_vrf.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c
index 2b3cfc876..7bfe07b4c 100644
--- a/zebra/zebra_vrf.c
+++ b/zebra/zebra_vrf.c
@@ -98,6 +98,14 @@ static int zebra_vrf_new(struct vrf *vrf)
zvrf = zebra_vrf_alloc(vrf);
if (!vrf_is_backend_netns())
zvrf->zns = zebra_ns_lookup(NS_DEFAULT);
+ else if (vrf->vrf_id == VRF_DEFAULT) {
+ struct ns *ns;
+
+ strlcpy(vrf->data.l.netns_name, VRF_DEFAULT_NAME, NS_NAMSIZ);
+ ns = ns_lookup(NS_DEFAULT);
+ ns->vrf_ctxt = vrf;
+ vrf->ns_ctxt = ns;
+ }
otable_init(&zvrf->other_tables);
@@ -417,6 +425,25 @@ vrf_id_t zebra_vrf_lookup_by_table(uint32_t table_id, ns_id_t ns_id)
return VRF_DEFAULT;
}
+/*
+ * Lookup tableid by vrfid; handle vrf-lite and vrf-netns cases
+ */
+int zebra_vrf_lookup_tableid(vrf_id_t vrf_id, ns_id_t ns_id)
+{
+ struct zebra_vrf *zvrf;
+
+ /* Handle vrf-lite and vrf-netns */
+ if (vrf_is_backend_netns())
+ zvrf = vrf_info_lookup(ns_id);
+ else
+ zvrf = vrf_info_lookup(vrf_id);
+
+ if (zvrf)
+ return zvrf->table_id;
+ else
+ return ZEBRA_ROUTE_TABLE_UNKNOWN;
+}
+
/* Lookup VRF by identifier. */
struct zebra_vrf *zebra_vrf_lookup_by_id(vrf_id_t vrf_id)
{