From: Donald Sharp Date: Thu, 2 Sep 2021 00:50:31 +0000 (-0400) Subject: bgpd: Do not randomly generate a vrf id for -Z X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=ee0451642e48d67690bfc141af294b9810accb2d;p=matthieu%2Ffrr.git bgpd: Do not randomly generate a vrf id for -Z 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 --- diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 4d3812bf60..0e546db841 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -3222,8 +3222,21 @@ int bgp_get(struct bgp **bgp_val, as_t *as, const char *name, } 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);