From e7682ccd1b4929a7b2690b2c2f49ec9d4cf18875 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 1 Sep 2021 20:50:31 -0400 Subject: [PATCH] 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 --- bgpd/bgpd.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 9004dff3b8..7236b9fe4b 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -3409,8 +3409,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); -- 2.39.5