Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bgpd: Free Memory for SRv6 Functions and Locator Chunks #14907

Merged
merged 1 commit into from
Nov 30, 2023

Conversation

Keelan10
Copy link
Contributor

Implement proper memory cleanup for SRv6 functions and locator chunks to prevent potential memory leaks. The list callback deletion functions have been set.

The ASan leak log for reference:

***********************************************************************************
Address Sanitizer Error detected in bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.asan.bgpd.4180

=================================================================
==4180==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 544 byte(s) in 2 object(s) allocated from:
    #0 0x7f8d176a0d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x7f8d1709f238 in qcalloc lib/memory.c:105
    #2 0x55d5dba6ee75 in sid_register bgpd/bgp_mplsvpn.c:591
    #3 0x55d5dba6ee75 in alloc_new_sid bgpd/bgp_mplsvpn.c:712
    #4 0x55d5dba6f3ce in ensure_vrf_tovpn_sid_per_af bgpd/bgp_mplsvpn.c:758
    #5 0x55d5dba6fb94 in ensure_vrf_tovpn_sid bgpd/bgp_mplsvpn.c:849
    #6 0x55d5dba7f975 in vpn_leak_postchange bgpd/bgp_mplsvpn.h:299
    #7 0x55d5dba7f975 in vpn_leak_postchange_all bgpd/bgp_mplsvpn.c:3704
    #8 0x55d5dbbb6c66 in bgp_zebra_process_srv6_locator_chunk bgpd/bgp_zebra.c:3164
    #9 0x7f8d1716f08a in zclient_read lib/zclient.c:4459
    #10 0x7f8d1713f034 in event_call lib/event.c:1974
    #11 0x7f8d1708242b in frr_run lib/libfrr.c:1214
    #12 0x55d5db99d19d in main bgpd/bgp_main.c:510
    #13 0x7f8d160c5c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

Direct leak of 296 byte(s) in 1 object(s) allocated from:
    #0 0x7f8d176a0d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x7f8d1709f238 in qcalloc lib/memory.c:105
    #2 0x7f8d170b1d5f in srv6_locator_chunk_alloc lib/srv6.c:135
    #3 0x55d5dbbb6a19 in bgp_zebra_process_srv6_locator_chunk bgpd/bgp_zebra.c:3144
    #4 0x7f8d1716f08a in zclient_read lib/zclient.c:4459
    #5 0x7f8d1713f034 in event_call lib/event.c:1974
    #6 0x7f8d1708242b in frr_run lib/libfrr.c:1214
    #7 0x55d5db99d19d in main bgpd/bgp_main.c:510
    #8 0x7f8d160c5c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)
***********************************************************************************

bgpd/bgpd.h Outdated Show resolved Hide resolved
lib/srv6.c Outdated Show resolved Hide resolved
Implement proper memory cleanup for SRv6 functions and locator chunks to prevent potential memory leaks.
The list callback deletion functions have been set.

The ASan leak log for reference:

```
***********************************************************************************
Address Sanitizer Error detected in bgp_srv6l3vpn_to_bgp_vrf.test_bgp_srv6l3vpn_to_bgp_vrf/r2.asan.bgpd.4180

=================================================================
==4180==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 544 byte(s) in 2 object(s) allocated from:
    #0 0x7f8d176a0d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    FRRouting#1 0x7f8d1709f238 in qcalloc lib/memory.c:105
    FRRouting#2 0x55d5dba6ee75 in sid_register bgpd/bgp_mplsvpn.c:591
    FRRouting#3 0x55d5dba6ee75 in alloc_new_sid bgpd/bgp_mplsvpn.c:712
    FRRouting#4 0x55d5dba6f3ce in ensure_vrf_tovpn_sid_per_af bgpd/bgp_mplsvpn.c:758
    FRRouting#5 0x55d5dba6fb94 in ensure_vrf_tovpn_sid bgpd/bgp_mplsvpn.c:849
    FRRouting#6 0x55d5dba7f975 in vpn_leak_postchange bgpd/bgp_mplsvpn.h:299
    FRRouting#7 0x55d5dba7f975 in vpn_leak_postchange_all bgpd/bgp_mplsvpn.c:3704
    FRRouting#8 0x55d5dbbb6c66 in bgp_zebra_process_srv6_locator_chunk bgpd/bgp_zebra.c:3164
    FRRouting#9 0x7f8d1716f08a in zclient_read lib/zclient.c:4459
    FRRouting#10 0x7f8d1713f034 in event_call lib/event.c:1974
    FRRouting#11 0x7f8d1708242b in frr_run lib/libfrr.c:1214
    FRRouting#12 0x55d5db99d19d in main bgpd/bgp_main.c:510
    FRRouting#13 0x7f8d160c5c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

Direct leak of 296 byte(s) in 1 object(s) allocated from:
    #0 0x7f8d176a0d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    FRRouting#1 0x7f8d1709f238 in qcalloc lib/memory.c:105
    FRRouting#2 0x7f8d170b1d5f in srv6_locator_chunk_alloc lib/srv6.c:135
    FRRouting#3 0x55d5dbbb6a19 in bgp_zebra_process_srv6_locator_chunk bgpd/bgp_zebra.c:3144
    FRRouting#4 0x7f8d1716f08a in zclient_read lib/zclient.c:4459
    FRRouting#5 0x7f8d1713f034 in event_call lib/event.c:1974
    FRRouting#6 0x7f8d1708242b in frr_run lib/libfrr.c:1214
    FRRouting#7 0x55d5db99d19d in main bgpd/bgp_main.c:510
    FRRouting#8 0x7f8d160c5c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)
***********************************************************************************

```

Signed-off-by: Keelan Cannoo <[email protected]>
@ton31337
Copy link
Member

@Mergifyio backport stable/9.1 stable/9.0

Copy link

mergify bot commented Nov 30, 2023

backport stable/9.1 stable/9.0

✅ Backports have been created

@ton31337 ton31337 merged commit 3ed1bc8 into FRRouting:master Nov 30, 2023
77 checks passed
ton31337 added a commit that referenced this pull request Nov 30, 2023
bgpd: Free Memory for SRv6 Functions and Locator Chunks (backport #14907)
ton31337 added a commit that referenced this pull request Nov 30, 2023
bgpd: Free Memory for SRv6 Functions and Locator Chunks (backport #14907)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants