From ecec94950f3a959fad5d8e418a21d0bbfc9b4ce8 Mon Sep 17 00:00:00 2001 From: Anton Degtyarev Date: Wed, 14 Nov 2018 03:54:56 +0300 Subject: [PATCH] bgpd: Fix bgpd doing vpn_leak_postchange_all() every time "router bgp ASNUM" command is entered in vtysh In rare cases when the default BGP instance is instantiated after VRF bgp instances (see comment to bgp_mplsvpn.c:vpn_leak_postchange_all() for an example), the "router bgp" command needs to call vpn_leak_postchange_all() to start the route leaking process. The issue was it was never checked if the "router bgp" command was used to create the default BGP instance or just to enter into "router bgp" command context. This resulted in vpn_leak_postchange_all() executed every time (and vpn routes re-announced to all peers) when the user was entering "router bgp" command context. Signed-off-by: Anton Degtyarev --- bgpd/bgp_vty.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 4dd148bb41..d8c34d2d31 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -972,6 +972,7 @@ DEFUN_NOSH (router_bgp, int idx_asn = 2; int idx_view_vrf = 3; int idx_vrf = 4; + int is_new_bgp = 0; int ret; as_t as; struct bgp *bgp; @@ -1011,6 +1012,9 @@ DEFUN_NOSH (router_bgp, inst_type = BGP_INSTANCE_TYPE_VIEW; } + if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) + is_new_bgp = (bgp_lookup(as, name) == NULL); + ret = bgp_get(&bgp, &as, name, inst_type); switch (ret) { case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET: @@ -1034,7 +1038,7 @@ DEFUN_NOSH (router_bgp, * any pending VRF-VPN leaking that was configured via * earlier "router bgp X vrf FOO" blocks. */ - if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) + if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT) vpn_leak_postchange_all(); /* Pending: handle when user tries to change a view to vrf n vv. -- 2.39.5