-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
lib: Free Temporary Memory for AF_FLOWSPEC Prefix #14372
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the flowspec memory leak is a fundamental problem in how prefixes are handled. This will not actually fix the problem, but instead create fun down the road
lib/table.c
Outdated
@@ -324,6 +324,12 @@ struct route_node *route_node_get(struct route_table *table, | |||
table->count++; | |||
route_lock_node(new); | |||
|
|||
if (p->family == AF_FLOWSPEC){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah no. This is just a crash waiting to happen. This is not how to fix this problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It appears that the CI tests passed successfully.
To clarify, the reason for suggesting to check for the AF_FLOWSPEC
condition when freeing the temporary memory allocated by prefix_copy
is because the same condition is used for memory allocation. Furthermore, it's worth noting that the value stored in this temporary memory is subsequently copied to node->p
within the route_node_set
function, which means the temporary memory becomes unnecessary at that point.
Did I get that correctly? Thanks for your input!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Keelan10, the good solution has to deal with a clean architecture. and what you do here it to mess flowspec with tables, which has nothing to do together.
I tried to do something without success . please see #7485 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pguibert6WIND You make a valid point. Thanks for the feedback
Continuous Integration Result: SUCCESSFULCongratulations, this patch passed basic tests Tested-by: NetDEF / OpenSourceRouting.org CI System CI System Testrun URL: https://ci1.netdef.org/browse/FRR-PULLREQ2-14048/ This is a comment from an automated CI system. Warnings Generated during build:Checkout code: Successful with additional warnings
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
893c75b
to
bc7a0d3
Compare
bc7a0d3
to
e7e7680
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Keelan10 thank you for this pull request.
prefix_flowspec_ptr_free() looks now good to me.
However, you must use it in other places in the code to solve all the possible memory leaks.
You can search for prefix_linkstate_ptr_free in the code
You need that:
|
e7e7680
to
aec00d2
Compare
This commit addresses a leak where temporary memory allocated earlier by the `prefix_copy` function for AF_FLOWSPEC prefixes was not being freed. To ensure proper memory management, we now release this temporary memory by calling `prefix_flowspec_ptr_free`. The ASan leak log for reference: ``` *********************************************************************************** Address Sanitizer Error detected in bgp_flowspec.test_bgp_flowspec_topo/r1.asan.bgpd.11539 ================================================================= ==11539==ERROR: LeakSanitizer: detected memory leaks Direct leak of 56 byte(s) in 2 object(s) allocated from: #0 0x7feaa956ad28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28) FRRouting#1 0x7feaa8f670da in qcalloc lib/memory.c:105 FRRouting#2 0x7feaa8fac1d4 in prefix_copy lib/prefix.c:346 FRRouting#3 0x7feaa8ff43e8 in route_node_get lib/table.c:274 FRRouting#4 0x56247cc798c0 in bgp_node_get bgpd/bgp_table.h:236 FRRouting#5 0x56247cc798c0 in bgp_afi_node_get bgpd/bgp_route.c:145 FRRouting#6 0x56247cc92622 in bgp_update bgpd/bgp_route.c:4188 FRRouting#7 0x56247ce55b21 in bgp_nlri_parse_flowspec bgpd/bgp_flowspec.c:193 FRRouting#8 0x56247cc4cdd8 in bgp_nlri_parse bgpd/bgp_packet.c:350 FRRouting#9 0x56247cc4f37c in bgp_update_receive bgpd/bgp_packet.c:2153 FRRouting#10 0x56247cc591e2 in bgp_process_packet bgpd/bgp_packet.c:3214 FRRouting#11 0x7feaa9005b99 in event_call lib/event.c:1979 FRRouting#12 0x7feaa8f4a379 in frr_run lib/libfrr.c:1213 FRRouting#13 0x56247cb51b21 in main bgpd/bgp_main.c:510 FRRouting#14 0x7feaa7f8dc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) SUMMARY: AddressSanitizer: 56 byte(s) leaked in 2 allocation(s). *********************************************************************************** ``` Signed-off-by: Keelan Cannoo <[email protected]>
aec00d2
to
a7fe30e
Compare
@louis-6wind thank you for the valuable input! |
This commit addresses a leak where temporary memory allocated earlier by the
prefix_copy
function for AF_FLOWSPEC prefixes was not being freed. To ensure proper memory management, we now release this temporary memory usingXFREE
.The ASan leak log for reference: