-
Notifications
You must be signed in to change notification settings - Fork 1.4k
bgpd: fix crash in aspath remove/replace chain, add a test for it #19575
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
base: master
Are you sure you want to change the base?
Conversation
|
@Mergifyio backport stable/10.4 stable/10.3 stable/10.2 |
🟠 Waiting for conditions to match
|
|
all AS had been removed from as-path by remove-private-AS all the configuration is, to say the least, not working well. but the end user did it |
|
If we didn't receive the AS path at all would the segment->len be 0? Do we properly handle 0 in all the other places that might be? It seems like we hsould have one way of representing no aspath at all and it should be consistent in the code base. |
|
in fact we receive an full as path, in code there are many tests on segment->length |
we encounter the following crash stack:
rpki_curr_state=RPKI_NOT_BEING_USED, json_paths=0x5b4df1ae71c0, pattr=0x5b4df1bab350) at /build/make-pkg/output/_packages/cp-routing/src/bgpd/bgp_route.c:10945
pathtype=BGP_PATH_SHOW_ALL, display=0x7ffe45d984c8, rpki_target_state=RPKI_NOT_BEING_USED, attr=0x5b4df1bab350) at /build/make-pkg/output/_packages/cp-routing/src/bgpd/bgp_route.c:12314
json=0x5b4df1bdbb40, json_ar=0x5b4df1b52330, show_flags=513, header1=0x7ffe45d98810, header2=0x7ffe45d98814, rd_str=0x7ffe45d98870 "", match=0x0, output_count=0x7ffe45d98828,
filtered_count=0x7ffe45d98830) at /build/make-pkg/output/_packages/cp-routing/src/bgpd/bgp_route.c:14612
at /build/make-pkg/output/_packages/cp-routing/src/bgpd/bgp_route.c:14798
argv=0x5b4df1bf9a50, viewvrfname=0x5b4df1ab0d30 "INTERNET", all=0x0, neighbors=0x5b4df1bba0a0 "198.18.253.15", route_map=0x0, prefix=0x7ffe45d9aa20, prefix_str=0x0,
detail=0x5b4df1c34a50 "detail", uj=0x5b4df1b9d390 "json", wide=0x0) at /build/make-pkg/output/_packages/cp-routing/src/bgpd/bgp_route.c:14968
argv=0x5b4df1bf9a50) at ./bgpd/bgp_route_clippy.c:796
at /build/make-pkg/output/_packages/cp-routing/src/lib/command.c:1209
at /build/make-pkg/output/_packages/cp-routing/src/lib/vty.c:627
crash occurs with a combinaison of
as path replace route maps and remove-private-AS all
commands
route-map OLDCORE-INTERNET-IN-IPv4 permit 5
set as-path replace any 65398
route-map OLDCORE-INTERNET-OUT-IPv4 permit 5
set as-path replace any 65399
neighbor 203.0.113.0 remove-private-AS all
neighbor 203.0.113.0 soft-reconfiguration inbound
neighbor 203.0.113.0 route-map OLDCORE-INTERNET-IN-IPv4 in
neighbor 203.0.113.0 route-map OLDCORE-INTERNET-OUT-IPv4 out
issue is dur to a lack of test in "aspath_get_first_as" function.
fix add a test on as path segment length.
Signed-off-by: Francois Dumontet <[email protected]>
we add a configuration:
configure terminal
route-map OLDCORE-INTERNET-IN-IPv4 permit 5
set as-path replace any 65398
exit
route-map OLDCORE-INTERNET-OUT-IPv4 permit 5
set as-path replace any 65399
exit
router bgp 65002
bgp deterministic-med
address-family ipv4 unicast
neighbor 203.0.113.0 remove-private-AS all
neighbor 203.0.113.0 soft-reconfiguration inbound
neighbor 203.0.113.0 route-map OLDCORE-INTERNET-IN-IPv4 in
neighbor 203.0.113.0 route-map OLDCORE-INTERNET-OUT-IPv4 out
exit-address-family
that leads to a crash.
Signed-off-by: Francois Dumontet <[email protected]>
496f510 to
d082034
Compare
| _crash_scenario() | ||
|
|
||
|
|
||
| exit |
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.
Leftovers?
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.
Up
| unsigned int aspath_get_first_as(struct aspath *aspath) | ||
| { | ||
| if (aspath == NULL || aspath->segments == NULL) | ||
| if (aspath == NULL || aspath->segments == NULL || aspath->segments->length == 0) |
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.
Or maybe we should release aspath->segments if the length is 0 (if we use replace as / remove as)?
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.
that point is pertinent. i will study the impact.
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.
looks good ... waiting on @ton31337 's comments
|
@fdumontet6WIND any updates? |
|
my concern is that if we free the aspath->segments, we will need to allocate it (shortly) after. Since many rules are applied. |
otoh, we might not ... the only way to solve this is to set a timer to clear the memory at some point in the future, as we don't want a leak ... that seems like a lot of work, though (?) |
|
Hi Russ, |
crash occurs with a combinaison of
as path replace route maps and remove-private-AS all
commands
issue is dur to a lack of test in "aspath_get_first_as" function.
fix add a test on as path segment length.