summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2017-12-22 16:21:09 +0100
committerPhilippe Guibert <philippe.guibert@6wind.com>2018-02-27 11:11:24 +0100
commitfbb65ff50428eefba0653e8f3f6f33afa003c4cd (patch)
tree4a6dc70da920d45186793dc15f9958ca67d80bdd
parent2c7d402164cc027a62be8ed2be2ffb25b17da1bd (diff)
zebra: zns context is filled in when vrf is enabled
This commit is also a fix that avoids a VRF to be attached to the wrong namespace context, at creation time. Because the VRF, at creation time does not know yet the namespace where it will get its information. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
-rw-r--r--zebra/zebra_vrf.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c
index a3596a4263..276687ca83 100644
--- a/zebra/zebra_vrf.c
+++ b/zebra/zebra_vrf.c
@@ -91,12 +91,9 @@ static int zebra_vrf_new(struct vrf *vrf)
zlog_info("VRF %s created, id %u", vrf->name, vrf->vrf_id);
zvrf = zebra_vrf_alloc();
- zvrf->zns = zebra_ns_lookup(
- NS_DEFAULT); /* Point to the global (single) NS */
- router_id_init(zvrf);
vrf->info = zvrf;
zvrf->vrf = vrf;
-
+ router_id_init(zvrf);
return 0;
}
@@ -117,6 +114,10 @@ static int zebra_vrf_enable(struct vrf *vrf)
zlog_debug("VRF %s id %u is now active",
zvrf_name(zvrf), zvrf_id(zvrf));
+ if (vrf_is_backend_netns())
+ zvrf->zns = zebra_ns_lookup((ns_id_t)vrf->vrf_id);
+ else
+ zvrf->zns = zebra_ns_lookup(NS_DEFAULT);
/* Inform clients that the VRF is now active. This is an
* add for the clients.
*/