From: Thibaut Collet Date: Thu, 30 Aug 2018 09:42:55 +0000 (+0200) Subject: vrf: return vrf implementation for default vrf X-Git-Tag: frr-7.1-dev~373^2~3 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=20c87e98d8399c322f3f8da9d34ca19fd4ca1865;p=mirror%2Ffrr.git vrf: return vrf implementation for default vrf To correct potential crash with netns implementation of vrf (see next commit) it is necessary to allow any daemons to know the vrf implementation whatever the vrf. With current implementation the daemons do not know the vrf implementation for the default vrf. For this vrf the returned vrf implementation is always vrf-lite. To solve this issue a netns name is set to the default vrf to just test is presence to know the used implementation. For zebra a netns name (if needed) is set in the vrf_init function just before enabling the vrf. So this information is propagated to the other daemons thanks the zapi message called when the vrf is enable at zebra layer and override the default configuration (vrf-lite) of the daemon. Signed-off-by: Thibaut Collet --- diff --git a/lib/vrf.c b/lib/vrf.c index 1fb1b786c7..696ae3f48c 100644 --- a/lib/vrf.c +++ b/lib/vrf.c @@ -497,6 +497,16 @@ void vrf_init(int (*create)(struct vrf *), int (*enable)(struct vrf *), strlcpy(default_vrf->data.l.netns_name, VRF_DEFAULT_NAME, NS_NAMSIZ); + if (vrf_is_backend_netns()) { + struct ns *ns; + + strlcpy(default_vrf->data.l.netns_name, + VRF_DEFAULT_NAME, NS_NAMSIZ); + ns = ns_lookup(ns_get_default_id()); + ns->vrf_ctxt = (void *)default_vrf; + default_vrf->ns_ctxt = (void *)ns; + } + /* Enable the default VRF. */ if (!vrf_enable(default_vrf)) { flog_err(LIB_ERR_VRF_START, @@ -711,8 +721,6 @@ int vrf_is_mapped_on_netns(struct vrf *vrf) { if (!vrf || vrf->data.l.netns_name[0] == '\0') return 0; - if (vrf->vrf_id == VRF_DEFAULT) - return 0; return 1; }