bgpd: Fix memory leak for EVPN Type-4 and dangling pointer for bgp_debug_rdpfxpath2str() (backport #22210)#22447
Merged
Merged
Conversation
==1==ERROR: AddressSanitizer: heap-use-after-free on address 0x50400007d818 at pc 0x55b8475e1bf8 bp 0x7ffe8b1f8c60 sp 0x7ffe8b1f8c50
READ of size 4 at 0x50400007d818 thread T0
0 0x55b8475e1bf7 in bgp_debug_rdpfxpath2str bgpd/bgp_debug.c:2941
1 0x55b84786dbb4 in bgp_update bgpd/bgp_route.c:6469
2 0x55b84760ce07 in process_type5_route bgpd/bgp_evpn.c:5289
3 0x55b847635fcc in bgp_nlri_parse_evpn bgpd/bgp_evpn.c:6501
4 0x55b8477c2ac8 in bgp_nlri_parse bgpd/bgp_packet.c:322
5 0x55b8477c9a89 in bgp_update_receive bgpd/bgp_packet.c:2506
6 0x55b8477e2c34 in bgp_process_packet bgpd/bgp_packet.c:4132
7 0x7f5fdd20306f in event_call lib/event.c:2740
8 0x7f5fdd01ef39 in frr_run lib/libfrr.c:1258
9 0x55b847578612 in main bgpd/bgp_main.c:549
10 0x7f5fdb5bf1c9 (/lib/x86_64-linux-gnu/libc.so.6+0x2a1c9) (BuildId: 8e9fd827446c24067541ac5390e6f527fb5947bb)
11 0x7f5fdb5bf28a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28a) (BuildId: 8e9fd827446c24067541ac5390e6f527fb5947bb)
12 0x55b847572ae4 in _start (/usr/local/sbin/bgpd+0xa9eae4) (BuildId: 326510628b5cbd02b862e3f4d4e817224ecbeb04)
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit cd8aaf7)
$ vtysh -c 'show bgp l2vpn evpn es'
ES Flags: B - bypass, L local, R remote, I inconsistent
VTEP Flags: E ESR/Type-4, A active nexthop
ESI Flags RD #VNIs VTEPs
03:aa:bb:cc:dd:ee:ff:00:00:01 L 172.54.0.10:2 0 10.99.0.1(E),10.99.0.2(E),10.99.0.3(E),10.99.0.4(E),10.99.0.5(E),10.99.0.6(E),10.99.0.7(E),10.99.0.8(E),10.99.0.9(E),10.99.0.10(E),10.99.0.11(E),10.99.0.12(E),10.99.0.13(E),10.99.0.14(E),10.99.0.15(E),10.99.0.16(E),10.99.0.17(E),10.99.0.18(E),10.99.0.19(E),10.99.0.20(E),10.99.0.21(E),10.99.0.22(E),10.99.0.23(E),10.99.0.24(E),10.99.0.25(E),10.99.0.26(E),10.99.0.27(E),10.99.0.28(E),10.99.0.29(E),10.99.0.30(E),10.99.0.31(E),10.99.0.32(E),10.99.0.33(E),10.99.0.34(E),10.99.0.35(E),10.99.0.36(E),10.99.0.37(E),10.99.0.38(E),...
$ vtysh -c 'show memory bgp' | grep 'ES VTEP'
BGP EVPN ES VTEP : 50 112 5600 50 5600
$ vtysh -c 'show bgp l2vpn evpn route type es'
Network Next Hop Metric LocPrf Weight Path
Route Distinguisher: 65002:1
*> [4]:[03:aa:bb:cc:dd:ee:ff:00:00:01]:[32]:[10.99.0.1] RD 65002:1
10.99.0.50 0 65002 i
...
Displayed 2 prefixes (2 paths) (of requested type)
```
After MP_UNREACH withdraw of the prefix, **49** vteps remain; only the
last-swapped NH `10.99.0.50` is deleted:
```
$ vtysh -c 'show memory bgp' | grep 'ES VTEP'
BGP EVPN ES VTEP : 49 112 5488 50 5600
```
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
(cherry picked from commit 6b9fd94)
|
Target branch is not in the allowed branches list. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an automatic backport of pull request #22210 done by [Mergify](https://mergify.com).