]> git.puffer.fish Git - mirror/frr.git/commitdiff
vrf: return vrf implementation for default vrf
authorThibaut Collet <thibaut.collet@6wind.com>
Thu, 30 Aug 2018 09:42:55 +0000 (11:42 +0200)
committerThibaut Collet <thibaut.collet@6wind.com>
Thu, 30 Aug 2018 12:37:55 +0000 (14:37 +0200)
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 <thibaut.collet@6wind.com>
lib/vrf.c

index 1fb1b786c7d4d26d92cb3bf32b4acb14b06952b1..696ae3f48cf720ba3b7652b013803ac68985cab5 100644 (file)
--- 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;
 }