summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Ryzhov <idryzhov@gmail.com>2024-12-27 14:10:27 +0100
committerIgor Ryzhov <idryzhov@gmail.com>2025-01-15 22:38:27 +0100
commit6f214d97d1a7883ea8d5866e10db31daffa0325a (patch)
tree2071f8d00712fb18532e2ce4a697012d0d8ea707
parentlib: remove VRF_BACKEND_UNKNOWN (diff)
downloadfrr-6f214d97d1a7883ea8d5866e10db31daffa0325a.tar.xz
frr-6f214d97d1a7883ea8d5866e10db31daffa0325a.zip
lib, zebra: move ns context intialization to zebra
vrf->ns_ctxt is only ever used in zebra, so move its initialization to zebra's callback. Ideally this pointer shouldn't even be a part of library's vrf struct, and moved to zebra-specific struct, but this is the first step. Signed-off-by: Igor Ryzhov <idryzhov@gmail.com>
-rw-r--r--lib/vrf.c9
-rw-r--r--zebra/zebra_vrf.c8
2 files changed, 8 insertions, 9 deletions
diff --git a/lib/vrf.c b/lib/vrf.c
index e57611116..0b39d9360 100644
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -581,15 +581,6 @@ void vrf_init(int (*create)(struct vrf *), int (*enable)(struct vrf *),
"vrf_init: failed to create the default VRF!");
exit(1);
}
- if (vrf_is_backend_netns()) {
- struct ns *ns;
-
- strlcpy(default_vrf->data.l.netns_name,
- VRF_DEFAULT_NAME, NS_NAMSIZ);
- ns = ns_lookup(NS_DEFAULT);
- ns->vrf_ctxt = default_vrf;
- default_vrf->ns_ctxt = ns;
- }
/* Enable the default VRF. */
if (!vrf_enable(default_vrf)) {
diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c
index c7781e86d..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);