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

zebra: Set Free Functions for Traffic Control Hash Tables #14908

Merged
merged 1 commit into from
Nov 29, 2023

Conversation

Keelan10
Copy link
Contributor

Configure hash table cleanup with specific free functions for zrouter.filter_hash, zrouter.qdisc_hash, and zrouter.class_hash. This ensures proper memory cleanup, addressing memory leaks.

The ASan leak log for reference:

***********************************************************************************
Address Sanitizer Error detected in tc_basic.test_tc_basic/r1.asan.zebra.15495

=================================================================
==15495==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 176 byte(s) in 1 object(s) allocated from:
    #0 0x7fd5660ffd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x7fd565afe238 in qcalloc lib/memory.c:105
    #2 0x5564521c6c9e in tc_filter_alloc_intern zebra/zebra_tc.c:389
    #3 0x7fd565ac49e8 in hash_get lib/hash.c:147
    #4 0x5564521c7c74 in zebra_tc_filter_add zebra/zebra_tc.c:409
    #5 0x55645210755a in zread_tc_filter zebra/zapi_msg.c:3428
    #6 0x5564521127c1 in zserv_handle_commands zebra/zapi_msg.c:4004
    #7 0x5564522208b2 in zserv_process_messages zebra/zserv.c:520
    #8 0x7fd565b9e034 in event_call lib/event.c:1974
    #9 0x7fd565ae142b in frr_run lib/libfrr.c:1214
    #10 0x5564520c14b1 in main zebra/main.c:492
    #11 0x7fd564ec2c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

Direct leak of 40 byte(s) in 1 object(s) allocated from:
    #0 0x7fd5660ffd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x7fd565afe238 in qcalloc lib/memory.c:105
    #2 0x5564521c6c6e in tc_class_alloc_intern zebra/zebra_tc.c:239
    #3 0x7fd565ac49e8 in hash_get lib/hash.c:147
    #4 0x5564521c784f in zebra_tc_class_add zebra/zebra_tc.c:293
    #5 0x556452107ce5 in zread_tc_class zebra/zapi_msg.c:3315
    #6 0x5564521127c1 in zserv_handle_commands zebra/zapi_msg.c:4004
    #7 0x5564522208b2 in zserv_process_messages zebra/zserv.c:520
    #8 0x7fd565b9e034 in event_call lib/event.c:1974
    #9 0x7fd565ae142b in frr_run lib/libfrr.c:1214
    #10 0x5564520c14b1 in main zebra/main.c:492
    #11 0x7fd564ec2c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

Direct leak of 12 byte(s) in 1 object(s) allocated from:
    #0 0x7fd5660ffd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    #1 0x7fd565afe238 in qcalloc lib/memory.c:105
    #2 0x5564521c6c3e in tc_qdisc_alloc_intern zebra/zebra_tc.c:128
    #3 0x7fd565ac49e8 in hash_get lib/hash.c:147
    #4 0x5564521c753b in zebra_tc_qdisc_install zebra/zebra_tc.c:184
    #5 0x556452108203 in zread_tc_qdisc zebra/zapi_msg.c:3286
    #6 0x5564521127c1 in zserv_handle_commands zebra/zapi_msg.c:4004
    #7 0x5564522208b2 in zserv_process_messages zebra/zserv.c:520
    #8 0x7fd565b9e034 in event_call lib/event.c:1974
    #9 0x7fd565ae142b in frr_run lib/libfrr.c:1214
    #10 0x5564520c14b1 in main zebra/main.c:492
    #11 0x7fd564ec2c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

SUMMARY: AddressSanitizer: 228 byte(s) leaked in 3 allocation(s).
***********************************************************************************

Configure hash table cleanup with specific free functions for `zrouter.filter_hash`, `zrouter.qdisc_hash`, and `zrouter.class_hash`.
This ensures proper memory cleanup, addressing memory leaks.

The ASan leak log for reference:

```
***********************************************************************************
Address Sanitizer Error detected in tc_basic.test_tc_basic/r1.asan.zebra.15495

=================================================================
==15495==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 176 byte(s) in 1 object(s) allocated from:
    #0 0x7fd5660ffd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    FRRouting#1 0x7fd565afe238 in qcalloc lib/memory.c:105
    FRRouting#2 0x5564521c6c9e in tc_filter_alloc_intern zebra/zebra_tc.c:389
    FRRouting#3 0x7fd565ac49e8 in hash_get lib/hash.c:147
    FRRouting#4 0x5564521c7c74 in zebra_tc_filter_add zebra/zebra_tc.c:409
    FRRouting#5 0x55645210755a in zread_tc_filter zebra/zapi_msg.c:3428
    FRRouting#6 0x5564521127c1 in zserv_handle_commands zebra/zapi_msg.c:4004
    FRRouting#7 0x5564522208b2 in zserv_process_messages zebra/zserv.c:520
    FRRouting#8 0x7fd565b9e034 in event_call lib/event.c:1974
    FRRouting#9 0x7fd565ae142b in frr_run lib/libfrr.c:1214
    FRRouting#10 0x5564520c14b1 in main zebra/main.c:492
    FRRouting#11 0x7fd564ec2c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

Direct leak of 40 byte(s) in 1 object(s) allocated from:
    #0 0x7fd5660ffd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    FRRouting#1 0x7fd565afe238 in qcalloc lib/memory.c:105
    FRRouting#2 0x5564521c6c6e in tc_class_alloc_intern zebra/zebra_tc.c:239
    FRRouting#3 0x7fd565ac49e8 in hash_get lib/hash.c:147
    FRRouting#4 0x5564521c784f in zebra_tc_class_add zebra/zebra_tc.c:293
    FRRouting#5 0x556452107ce5 in zread_tc_class zebra/zapi_msg.c:3315
    FRRouting#6 0x5564521127c1 in zserv_handle_commands zebra/zapi_msg.c:4004
    FRRouting#7 0x5564522208b2 in zserv_process_messages zebra/zserv.c:520
    FRRouting#8 0x7fd565b9e034 in event_call lib/event.c:1974
    FRRouting#9 0x7fd565ae142b in frr_run lib/libfrr.c:1214
    FRRouting#10 0x5564520c14b1 in main zebra/main.c:492
    FRRouting#11 0x7fd564ec2c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

Direct leak of 12 byte(s) in 1 object(s) allocated from:
    #0 0x7fd5660ffd28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    FRRouting#1 0x7fd565afe238 in qcalloc lib/memory.c:105
    FRRouting#2 0x5564521c6c3e in tc_qdisc_alloc_intern zebra/zebra_tc.c:128
    FRRouting#3 0x7fd565ac49e8 in hash_get lib/hash.c:147
    FRRouting#4 0x5564521c753b in zebra_tc_qdisc_install zebra/zebra_tc.c:184
    FRRouting#5 0x556452108203 in zread_tc_qdisc zebra/zapi_msg.c:3286
    FRRouting#6 0x5564521127c1 in zserv_handle_commands zebra/zapi_msg.c:4004
    FRRouting#7 0x5564522208b2 in zserv_process_messages zebra/zserv.c:520
    FRRouting#8 0x7fd565b9e034 in event_call lib/event.c:1974
    FRRouting#9 0x7fd565ae142b in frr_run lib/libfrr.c:1214
    FRRouting#10 0x5564520c14b1 in main zebra/main.c:492
    FRRouting#11 0x7fd564ec2c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

SUMMARY: AddressSanitizer: 228 byte(s) leaked in 3 allocation(s).
***********************************************************************************
```

Signed-off-by: Keelan Cannoo <[email protected]>
@frrbot frrbot bot added the zebra label Nov 29, 2023
@donaldsharp donaldsharp merged commit 8a72aff into FRRouting:master Nov 29, 2023
78 checks passed
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.

2 participants