Commit b7f9a22c56 for frr
commit b7f9a22c56e4d48e9380197735f4a81f168c6e64
Author: Kyrylo Yatsenko <hedrok@gmail.com>
Date: Fri Nov 6 17:20:20 2026 +0200
bgpd: Remove extra leak processing on router bgp
On each vty command `router bgp` (no vrf) there was a call of
`vpn_leak_postchange_all` even when there was no change in configuration
at all.
frr-reload.py can issue a lot of `router bgp` commands for a
configuration change, which made its usage in such cases very
time-consuming.
This was introduced in 9f7177af13c4ccf8166bf861994702635703dd9a with
change:
```
- if (is_new_bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT)
+ if (bgp && inst_type == BGP_INSTANCE_TYPE_DEFAULT)
```
After that comment (removed in this commit) became outdated:
```
* If we just instantiated the default instance, complete
* any pending VRF-VPN leaking that was configured via
* earlier "router bgp X vrf FOO" blocks.
```
`bgp` was always not NULL at that point, so later commit
25b6751d14900f3a3b6304f5c1292da6516dc119 removed it.
The call is not needed anymore at all after
94d12dc490d7c4109828e7d4421e7ae0d84c3448 as now
`vpn_leak_postchange_all` is called from `bgp_ifp_create` on every
loopback/vrf interface creation message, so when default bgp instance is
created, it receives these messages and calls this function anyway.
Even one extra call can take a long time when import table is large.
Signed-off-by: Kyrylo Yatsenko <hedrok@gmail.com>
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index 9d2e8caa87..11ef8aefad 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -4158,9 +4158,6 @@ vrf_id_t get_first_vrf_for_redirect_with_rt(struct ecommunity *eckey)
*
* router bgp NNN
* ...
- *
- * This function gets called when the default instance ("router bgp NNN")
- * is created.
*/
void vpn_leak_postchange_all(void)
{
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index f5ea993927..e65ce3a615 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -1808,15 +1808,9 @@ DEFUN_NOSH (router_bgp,
vty_out(vty, "BGP instance not found\n");
return CMD_WARNING_CONFIG_FAILED;
}
- /*
- * If we just instantiated the default instance, complete
- * any pending VRF-VPN leaking that was configured via
- * earlier "router bgp X vrf FOO" blocks.
- */
- if (inst_type == BGP_INSTANCE_TYPE_DEFAULT) {
+
+ if (inst_type == BGP_INSTANCE_TYPE_DEFAULT)
bgp_need_listening(bgp, vty);
- vpn_leak_postchange_all();
- }
if (inst_type == BGP_INSTANCE_TYPE_VRF || IS_BGP_INSTANCE_HIDDEN(bgp)) {
bgp_vpn_leak_export(bgp);
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index 5fa3e0f386..af02f8eb96 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -3753,6 +3753,10 @@ static int bgp_ifp_create(struct interface *ifp)
vpn_leak_zebra_vrf_label_update(bgp, AFI_IP6);
vpn_leak_zebra_vrf_sid_update(bgp, AFI_IP);
vpn_leak_zebra_vrf_sid_update(bgp, AFI_IP6);
+ /* Be careful when changing: this call is also responsible for
+ * processing deferred route leaks when default BGP instance is
+ * created
+ */
vpn_leak_postchange_all();
}