Skip to content

Commit

Permalink
lib, zebra: move ns context intialization to zebra
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
idryzhov committed Dec 27, 2024
1 parent 59eefe5 commit 20d5957
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
9 changes: 0 additions & 9 deletions lib/vrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,15 +539,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)) {
Expand Down
9 changes: 9 additions & 0 deletions zebra/zebra_vrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ 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);

Expand Down

0 comments on commit 20d5957

Please sign in to comment.