Bgp crashes - #21778
Conversation
Greptile SummaryThis PR fixes two shutdown-order crashes in the BGP EVPN multi-homing code. First, it adds Confidence Score: 4/5Safe to merge; both changes are tightly scoped shutdown-path fixes with no impact on the data-plane code path. Both fixes follow established patterns already present in the codebase (same reap loop, same list_delete NULL-after-free convention) and address confirmed topotest crashes. No new logic is introduced in normal (non-shutdown) operation. Score is 4 rather than 5 because the purge function accesses pi->peer inside bgp_path_info_reap during a phase where the BGP instance may be partially torn down, but this same risk exists in the surrounding callers and the check bgpd/bgp_evpn_mh.c β confirm bgp_path_info_reap is safe when called after bgp instance teardown (peer pointers may be stale). Important Files Changed
Sequence DiagramsequenceDiagram
participant MH as bgp_evpn_mh_finish
participant Purge as bgp_evpn_es_route_table_purge (NEW)
participant Reap as bgp_path_info_reap
participant ESFree as bgp_evpn_es_free
participant Table as bgp_table_unlock
MH->>Purge: for each ES in rb_tree
Purge->>Purge: loop over dest/pi in route_table
Purge->>Reap: bgp_path_info_mark_for_delete + reap
Reap-->>Purge: dest (assert non-NULL)
MH->>MH: force-cleanup ES-EVIs
MH->>ESFree: bgp_evpn_es_local_info_clear β es_free
ESFree->>Table: bgp_table_unlock (pi_hash now empty β)
note over MH,Table: Without the purge, pi_hash non-empty crash here
Reviews (1): Last reviewed commit: "bgpd: Prevent crash when list is already..." | Re-trigger Greptile |
I am seeing this crash on shutdown: (gdb) bt 0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:44 1 __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78 2 __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ./nptl/pthread_kill.c:89 3 0x000073b03f64527e in __GI_raise (sig=6) at ../sysdeps/posix/raise.c:26 4 0x000073b03fb54184 in core_handler (signo=6, siginfo=0x7fffe7e9f770, context=0x7fffe7e9f640) at lib/sigevent.c:268 5 <signal handler called> 6 __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:44 7 __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78 8 __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6) at ./nptl/pthread_kill.c:89 9 0x000073b03f64527e in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 10 0x000073b03f6288ff in __GI_abort () at ./stdlib/abort.c:79 11 0x000073b03fb9d557 in _zlog_assert_failed (xref=0x60176b4ddaa0 <_xref.6>, extra=0x0) at lib/zlog.c:801 12 0x000060176b29555c in bgp_pi_hash_fini (h=0x60177324c238) at ./bgpd/bgp_route.h:761 13 0x000060176b295787 in bgp_table_unlock (rt=0x60177324c220) at bgpd/bgp_table.c:38 14 0x000060176b1b7817 in bgp_evpn_es_free (es=0x60177324c0e0, caller=0x60176b3e2200 <__func__.189> "bgp_evpn_es_local_info_clear") at bgpd/bgp_evpn_mh.c:2112 15 0x000060176b1b7a62 in bgp_evpn_es_local_info_clear (es=0x60177324c0e0, finish=true) at bgpd/bgp_evpn_mh.c:2179 16 0x000060176b1bfd11 in bgp_evpn_mh_finish () at bgpd/bgp_evpn_mh.c:5230 17 0x000060176b17344e in bgp_exit (status=0) at bgpd/bgp_main.c:193 18 0x000060176b17332e in sigint () at bgpd/bgp_main.c:141 19 0x000073b03fb53ef0 in frr_sigevent_process () at lib/sigevent.c:117 20 0x000073b03fb708e5 in event_fetch_inner_loop (m=0x6017729d5f60, event=0x0, fetch=0x7fffe7ea06d0, broken=0x7fffe7ea068e, continued=0x7fffe7ea068f) at lib/event.c:2437 21 0x000073b03fb70c1b in event_fetch (m=0x6017729d5f60, fetch=0x7fffe7ea06d0) at lib/event.c:2569 22 0x000073b03fadd06f in frr_run (loop=0x6017729d5f60) at lib/libfrr.c:1257 23 0x000060176b1740bf in main (argc=7, argv=0x7fffe7ea0968) at bgpd/bgp_main.c:550 The crash is happening because when finishing the pi has for the evpn data it is not actually cleaned up. Let's purge that data. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Ensure that the list is actually there on cleanup. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
5194536 to
c5638ab
Compare
see individual commits, but stop 2 shutdown crashes that happening in the topotests