Commit f24948a
committed
bgpd: fix valgrind memory leaks on daemon shutdown
During daemon termination, the default BGP instance leaks due to
two issues:
First, bgp_cleanup_routes() skips EVPN and ENCAP two-level table
cleanup for hidden instances, leaving route entries. Add a terminating
check so these tables are always cleaned during shutdown.
Second, a circular dependency exists between bgp_free() and VNI lock
release: each L2VNI holds a bgp_lock on the default instance via
bgpevpn_link_to_l3vni(), but the only code that releases these locks
(bgp_evpn_cleanup -> free_vni_entry -> bgpevpn_unlink_from_l3vni) lives
inside bgp_free(), which only runs when the lock count reaches zero.
Break this cycle by calling bgp_evpn_cleanup() from bgp_delete() during
termination, before the final bgp_unlock(). This releases VNI-held
locks so the refcount can reach zero and bgp_free() actually executes.
Signed-off-by: Soumya Roy <souroy@nvidia.com>1 parent 93ad76e commit f24948a
3 files changed
Lines changed: 15 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5377 | 5377 | | |
5378 | 5378 | | |
5379 | 5379 | | |
5380 | | - | |
| 5380 | + | |
| 5381 | + | |
5381 | 5382 | | |
5382 | 5383 | | |
5383 | 5384 | | |
| |||
7770 | 7771 | | |
7771 | 7772 | | |
7772 | 7773 | | |
| 7774 | + | |
| 7775 | + | |
| 7776 | + | |
| 7777 | + | |
7773 | 7778 | | |
7774 | 7779 | | |
7775 | 7780 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8030 | 8030 | | |
8031 | 8031 | | |
8032 | 8032 | | |
8033 | | - | |
| 8033 | + | |
8034 | 8034 | | |
8035 | 8035 | | |
8036 | 8036 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4590 | 4590 | | |
4591 | 4591 | | |
4592 | 4592 | | |
| 4593 | + | |
| 4594 | + | |
| 4595 | + | |
| 4596 | + | |
| 4597 | + | |
| 4598 | + | |
| 4599 | + | |
| 4600 | + | |
4593 | 4601 | | |
4594 | 4602 | | |
4595 | 4603 | | |
| |||
0 commit comments