Commit 6fa5360eb1 for frr
commit 6fa5360eb1eae54b161d8bf5d57aa6fdc10a08ed
Author: Carmine Scarpitta <cscarpit@cisco.com>
Date: Tue Nov 24 10:54:43 2026 +0100
bgpd: Fix crash when processing VPN leaks without a default instance
Configuring an SRv6 locator for a VRF before the default BGP instance
exists invokes `vpn_leak_postchange_all()`, which asserts that the
default instance is present and crashes bgpd.
For example, start bgpd and zebra with an empty configuration, then
apply:
```
vrf vrf1
exit-vrf
!
segment-routing
srv6
locators
locator MAIN
prefix fcbb:bbbb:1::/48
format usid-f3216
exit
exit
exit
!
router bgp 65001 vrf vrf1
segment-routing srv6
locator MAIN
exit
exit
```
This configuration triggers the assertion and aborts bgpd:
```
2026/11/24 04:47:54 BGP: bgpd/bgp_mplsvpn.c:4208: vpn_leak_postchange_all(): assertion (bgp_default) failed
BGP: Received signal 6 at 1795513674 (si_addr 0x870011a0eb, PC 0x7f298c8969fc); aborting...
BGP: zlog_signal+0x404 7f298ce7c320 7ffd45150070 /usr/lib/frr/libfrr.so.0 (mapped at 0x7f298cc00000)
BGP: core_handler+0x1ef 7f298cf711ce 7ffd45150270 /usr/lib/frr/libfrr.so.0 (mapped at 0x7f298cc00000)
BGP: __sigaction+0x50 7f298c842520 7ffd45150480 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x7f298c800000)
BGP: ---- signal ----
BGP: pthread_kill+0x12c 7f298c8969fc 7ffd45150a30 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x7f298c800000)
BGP: raise+0x16 7f298c842476 7ffd45150af0 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x7f298c800000)
BGP: abort+0xd3 7f298c8287f3 7ffd45150b00 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x7f298c800000)
BGP: _zlog_assert_failed+0x3d3 7f298d027a4b 7ffd45150c40 /usr/lib/frr/libfrr.so.0 (mapped at 0x7f298cc00000)
BGP: vpn_leak_postchange_all+0x43 55fb6f803af6 7ffd45150dc0 /usr/lib/frr/bgpd (mapped at 0x55fb6f2f5000)
BGP: bgp_zebra_process_srv6_locator_internal+0x2ea 55fb6fa516e4 7ffd45150df0 /usr/lib/frr/bgpd (mapped at 0x55fb6f2f5000)
BGP: bgp_zebra_process_srv6_locator_add+0x27f 55fb6fa55bc5 7ffd45150e20 /usr/lib/frr/bgpd (mapped at 0x55fb6f2f5000)
BGP: zclient_read+0x921 7f298d01f1eb 7ffd45151080 /usr/lib/frr/libfrr.so.0 (mapped at 0x7f298cc00000)
BGP: event_call+0x52a 7f298cfb8cb3 7ffd451510e0 /usr/lib/frr/libfrr.so.0 (mapped at 0x7f298cc00000)
BGP: frr_run+0x54d 7f298ce56784 7ffd451512f0 /usr/lib/frr/libfrr.so.0 (mapped at 0x7f298cc00000)
BGP: main+0xa13 55fb6f6414d8 7ffd45151480 /usr/lib/frr/bgpd (mapped at 0x55fb6f2f5000)
BGP: __libc_init_first+0x90 7f298c829d90 7ffd45151500 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x7f298c800000)
BGP: __libc_start_main+0x80 7f298c829e40 7ffd451515a0 /lib/x86_64-linux-gnu/libc.so.6 (mapped at 0x7f298c800000)
BGP: _start+0x25 55fb6f63d8b5 7ffd451515f0 /usr/lib/frr/bgpd (mapped at 0x55fb6f2f5000)
BGP: in thread zclient_read scheduled from lib/zclient.c:5179 zclient_event()
```
Fix this by returning early when the default instance is absent,
preserving the configured VRF leaks. Once the default instance becomes
available, `vpn_leak_postchange_all()` is called again to process the
configured leaks and populate the VPN RIB.
Fixes #24494
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index 5aca26fc41..6d4336001b 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -4205,7 +4205,8 @@ void vpn_leak_postchange_all(void)
struct bgp *bgp;
struct bgp *bgp_default = bgp_get_default();
- assert(bgp_default);
+ if (!bgp_default)
+ return;
/* First, do any exporting from VRFs to the single VPN RIB */
for (ALL_LIST_ELEMENTS_RO(bm->bgp, next, bgp)) {