]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Do not randomly generate a vrf id for -Z
authorDonald Sharp <sharpd@nvidia.com>
Thu, 2 Sep 2021 00:50:31 +0000 (20:50 -0400)
committerIgor Ryzhov <iryzhov@nfware.com>
Fri, 3 Sep 2021 14:08:51 +0000 (17:08 +0300)
When FRR added the -Z parameter the bgp daemon was setting
a vrf identifier based upon a number starting at 1.  This
caused issues when we upgraded the code to the outgoing
sockets to use vrf_bind always.

FRR should never just randomly select a vrf identifier.
Let's just use VRF_DEFAULT when we are in a -Z environment.
It's a safe bet.

Fixes: #9519
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
bgpd/bgpd.c

index e816b98e2747a537befceecf34890b12886ef9d3..66f5d997969fd4167c16cd1506b23d99fce61201 100644 (file)
@@ -3397,8 +3397,21 @@ int bgp_get(struct bgp **bgp_val, as_t *as, const char *name,
                return ret;
 
        bgp = bgp_create(as, name, inst_type);
-       if (bgp_option_check(BGP_OPT_NO_ZEBRA) && name)
-               bgp->vrf_id = vrf_generate_id();
+
+       /*
+        * view instances will never work inside of a vrf
+        * as such they must always be in the VRF_DEFAULT
+        * Also we must set this to something useful because
+        * of the vrf socket code needing an actual useful
+        * default value to send to the underlying OS.
+        *
+        * This code is currently ignoring vrf based
+        * code using the -Z option( and that is probably
+        * best addressed elsewhere in the code )
+        */
+       if (inst_type == BGP_INSTANCE_TYPE_VIEW)
+               bgp->vrf_id = VRF_DEFAULT;
+
        bgp_router_id_set(bgp, &bgp->router_id_zebra, true);
        bgp_address_init(bgp);
        bgp_tip_hash_init(bgp);