[202305] update frr patch for bgpd-Ensure-community-data-is-freed-in-some-cases (#18246)
Why I did it FRR issue FRRouting/frr#15459 Add patch for FRR PR for 202305 FRRouting/frr#15466 Work item tracking Microsoft ADO (number only): 26876083 How I did it Add patch for FRR PR FRRouting/frr#15466 How to verify it Run the original case locally
This commit is contained in:
parent
193c6c0cd3
commit
524dea665a
471
src/sonic-frr/patch/0037-bgp-community-memory-leak-fix.patch
Normal file
471
src/sonic-frr/patch/0037-bgp-community-memory-leak-fix.patch
Normal file
@ -0,0 +1,471 @@
|
|||||||
|
From 139e450bccf3c2591c7b158662b36e5b9ff33172 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Donald Sharp <sharpd@nvidia.com>
|
||||||
|
Date: Sat, 2 Mar 2024 09:42:30 -0500
|
||||||
|
Subject: [PATCH 1/5] bgpd: Include unsuppress-map as a valid outgoing policy
|
||||||
|
|
||||||
|
If unsuppress-map is setup for outgoing peers, consider that
|
||||||
|
policy is being applied as for RFC 8212.
|
||||||
|
|
||||||
|
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
|
||||||
|
---
|
||||||
|
bgpd/bgp_route.c | 8 ++++----
|
||||||
|
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
|
||||||
|
index f4dff0d802..3a03644f93 100644
|
||||||
|
--- a/bgpd/bgp_route.c
|
||||||
|
+++ b/bgpd/bgp_route.c
|
||||||
|
@@ -5834,10 +5834,10 @@ bool bgp_outbound_policy_exists(struct peer *peer, struct bgp_filter *filter)
|
||||||
|
if (peer->sort == BGP_PEER_IBGP)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
- if (peer->sort == BGP_PEER_EBGP
|
||||||
|
- && (ROUTE_MAP_OUT_NAME(filter) || PREFIX_LIST_OUT_NAME(filter)
|
||||||
|
- || FILTER_LIST_OUT_NAME(filter)
|
||||||
|
- || DISTRIBUTE_OUT_NAME(filter)))
|
||||||
|
+ if (peer->sort == BGP_PEER_EBGP &&
|
||||||
|
+ (ROUTE_MAP_OUT_NAME(filter) || PREFIX_LIST_OUT_NAME(filter) ||
|
||||||
|
+ FILTER_LIST_OUT_NAME(filter) || DISTRIBUTE_OUT_NAME(filter) ||
|
||||||
|
+ UNSUPPRESS_MAP_NAME(filter)))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.14.1
|
||||||
|
|
||||||
|
|
||||||
|
From 2e09994360cda6251fd95845feb878f83e4f9345 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Donatas Abraitis <donatas@opensourcerouting.org>
|
||||||
|
Date: Fri, 3 Mar 2023 17:33:51 +0200
|
||||||
|
Subject: [PATCH 2/5] bgpd: Intern attributes before putting into rib-out
|
||||||
|
|
||||||
|
```
|
||||||
|
==21860==ERROR: LeakSanitizer: detected memory leaks
|
||||||
|
|
||||||
|
Direct leak of 80 byte(s) in 2 object(s) allocated from:
|
||||||
|
0 0x7f8065294d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
|
||||||
|
1 0x7f8064cfd216 in qcalloc lib/memory.c:105
|
||||||
|
2 0x5646b7024073 in ecommunity_dup bgpd/bgp_ecommunity.c:252
|
||||||
|
3 0x5646b7153585 in route_set_ecommunity_lb bgpd/bgp_routemap.c:2925
|
||||||
|
4 0x7f8064d459be in route_map_apply_ext lib/routemap.c:2675
|
||||||
|
5 0x5646b7116584 in subgroup_announce_check bgpd/bgp_route.c:2374
|
||||||
|
6 0x5646b711b907 in subgroup_process_announce_selected bgpd/bgp_route.c:2918
|
||||||
|
7 0x5646b717ceb8 in group_announce_route_walkcb bgpd/bgp_updgrp_adv.c:184
|
||||||
|
8 0x7f8064cc6acd in hash_walk lib/hash.c:270
|
||||||
|
9 0x5646b717ae0c in update_group_af_walk bgpd/bgp_updgrp.c:2046
|
||||||
|
10 0x5646b7181275 in group_announce_route bgpd/bgp_updgrp_adv.c:1030
|
||||||
|
11 0x5646b711a986 in bgp_process_main_one bgpd/bgp_route.c:3303
|
||||||
|
12 0x5646b711b5bf in bgp_process_wq bgpd/bgp_route.c:3444
|
||||||
|
13 0x7f8064da12d7 in work_queue_run lib/workqueue.c:267
|
||||||
|
14 0x7f8064d891fb in thread_call lib/thread.c:1991
|
||||||
|
15 0x7f8064cdffcf in frr_run lib/libfrr.c:1185
|
||||||
|
16 0x5646b6feca67 in main bgpd/bgp_main.c:505
|
||||||
|
17 0x7f8063f96c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)
|
||||||
|
|
||||||
|
Indirect leak of 16 byte(s) in 2 object(s) allocated from:
|
||||||
|
0 0x7f8065294b40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40)
|
||||||
|
1 0x7f8064cfcf01 in qmalloc lib/memory.c:100
|
||||||
|
2 0x5646b7024151 in ecommunity_dup bgpd/bgp_ecommunity.c:256
|
||||||
|
3 0x5646b7153585 in route_set_ecommunity_lb bgpd/bgp_routemap.c:2925
|
||||||
|
4 0x7f8064d459be in route_map_apply_ext lib/routemap.c:2675
|
||||||
|
5 0x5646b7116584 in subgroup_announce_check bgpd/bgp_route.c:2374
|
||||||
|
6 0x5646b711b907 in subgroup_process_announce_selected bgpd/bgp_route.c:2918
|
||||||
|
7 0x5646b717ceb8 in group_announce_route_walkcb bgpd/bgp_updgrp_adv.c:184
|
||||||
|
8 0x7f8064cc6acd in hash_walk lib/hash.c:270
|
||||||
|
9 0x5646b717ae0c in update_group_af_walk bgpd/bgp_updgrp.c:2046
|
||||||
|
10 0x5646b7181275 in group_announce_route bgpd/bgp_updgrp_adv.c:1030
|
||||||
|
11 0x5646b711a986 in bgp_process_main_one bgpd/bgp_route.c:3303
|
||||||
|
12 0x5646b711b5bf in bgp_process_wq bgpd/bgp_route.c:3444
|
||||||
|
13 0x7f8064da12d7 in work_queue_run lib/workqueue.c:267
|
||||||
|
14 0x7f8064d891fb in thread_call lib/thread.c:1991
|
||||||
|
15 0x7f8064cdffcf in frr_run lib/libfrr.c:1185
|
||||||
|
16 0x5646b6feca67 in main bgpd/bgp_main.c:505
|
||||||
|
17 0x7f8063f96c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)
|
||||||
|
```
|
||||||
|
|
||||||
|
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
|
||||||
|
---
|
||||||
|
bgpd/bgp_route.c | 12 ++++++++----
|
||||||
|
1 file changed, 8 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
|
||||||
|
index 3a03644f93..1a7c0cc78e 100644
|
||||||
|
--- a/bgpd/bgp_route.c
|
||||||
|
+++ b/bgpd/bgp_route.c
|
||||||
|
@@ -2917,10 +2917,14 @@ void subgroup_process_announce_selected(struct update_subgroup *subgrp,
|
||||||
|
* in FIB, then it is advertised
|
||||||
|
*/
|
||||||
|
if (advertise) {
|
||||||
|
- if (!bgp_check_withdrawal(bgp, dest))
|
||||||
|
- bgp_adj_out_set_subgroup(
|
||||||
|
- dest, subgrp, &attr, selected);
|
||||||
|
- else
|
||||||
|
+ if (!bgp_check_withdrawal(bgp, dest)) {
|
||||||
|
+ struct attr *adv_attr =
|
||||||
|
+ bgp_attr_intern(&attr);
|
||||||
|
+
|
||||||
|
+ bgp_adj_out_set_subgroup(dest, subgrp,
|
||||||
|
+ adv_attr,
|
||||||
|
+ selected);
|
||||||
|
+ } else
|
||||||
|
bgp_adj_out_unset_subgroup(
|
||||||
|
dest, subgrp, 1, addpath_tx_id);
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.14.1
|
||||||
|
|
||||||
|
|
||||||
|
From 0b4e9c386c7d1caa83d9790d90652a794f69e91e Mon Sep 17 00:00:00 2001
|
||||||
|
From: Donatas Abraitis <donatas@opensourcerouting.org>
|
||||||
|
Date: Mon, 27 Feb 2023 23:40:32 +0200
|
||||||
|
Subject: [PATCH 3/5] bgpd: Intern attributes before putting into rib-out
|
||||||
|
|
||||||
|
After we call subgroup_announce_check(), we leave communities, large-communities
|
||||||
|
that are modified by route-maps uninterned, and here we have a memory leak.
|
||||||
|
|
||||||
|
```
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323:Direct leak of 80 byte(s) in 2 object(s) allocated from:
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #0 0x7f0858d90037 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #1 0x7f08589b15b2 in qcalloc lib/memory.c:105
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #2 0x561f5c4e08d2 in lcommunity_new bgpd/bgp_lcommunity.c:28
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #3 0x561f5c4e11d9 in lcommunity_dup bgpd/bgp_lcommunity.c:141
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #4 0x561f5c5c3b8b in route_set_lcommunity bgpd/bgp_routemap.c:2491
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #5 0x7f0858a177a5 in route_map_apply_ext lib/routemap.c:2675
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #6 0x561f5c5696f9 in subgroup_announce_check bgpd/bgp_route.c:2352
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #7 0x561f5c5fb728 in subgroup_announce_table bgpd/bgp_updgrp_adv.c:682
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #8 0x561f5c5fbd95 in subgroup_announce_route bgpd/bgp_updgrp_adv.c:765
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #9 0x561f5c5f6105 in peer_af_announce_route bgpd/bgp_updgrp.c:2187
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #10 0x561f5c5790be in bgp_announce_route_timer_expired bgpd/bgp_route.c:5032
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #11 0x7f0858a76e4e in thread_call lib/thread.c:1991
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #12 0x7f0858974c24 in frr_run lib/libfrr.c:1185
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #13 0x561f5c3e955d in main bgpd/bgp_main.c:505
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #14 0x7f08583a9d09 in __libc_start_main ../csu/libc-start.c:308
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323-
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323:Indirect leak of 144 byte(s) in 2 object(s) allocated from:
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #0 0x7f0858d8fe8f in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #1 0x7f08589b1579 in qmalloc lib/memory.c:100
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #2 0x561f5c4e1282 in lcommunity_dup bgpd/bgp_lcommunity.c:144
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #3 0x561f5c5c3b8b in route_set_lcommunity bgpd/bgp_routemap.c:2491
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #4 0x7f0858a177a5 in route_map_apply_ext lib/routemap.c:2675
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #5 0x561f5c5696f9 in subgroup_announce_check bgpd/bgp_route.c:2352
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #6 0x561f5c5fb728 in subgroup_announce_table bgpd/bgp_updgrp_adv.c:682
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #7 0x561f5c5fbd95 in subgroup_announce_route bgpd/bgp_updgrp_adv.c:765
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #8 0x561f5c5f6105 in peer_af_announce_route bgpd/bgp_updgrp.c:2187
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #9 0x561f5c5790be in bgp_announce_route_timer_expired bgpd/bgp_route.c:5032
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #10 0x7f0858a76e4e in thread_call lib/thread.c:1991
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #11 0x7f0858974c24 in frr_run lib/libfrr.c:1185
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #12 0x561f5c3e955d in main bgpd/bgp_main.c:505
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323- #13 0x7f08583a9d09 in __libc_start_main ../csu/libc-start.c:308
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323-
|
||||||
|
./bgp_large_community.test_bgp_large_community_topo_2/r1.bgpd.asan.2465323-SUMMARY: AddressSanitizer: 224 byte(s) leaked in 4 allocation(s).
|
||||||
|
```
|
||||||
|
|
||||||
|
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
|
||||||
|
---
|
||||||
|
bgpd/bgp_updgrp_adv.c | 9 ++++++---
|
||||||
|
1 file changed, 6 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c
|
||||||
|
index af8ef751da..de2b3206b7 100644
|
||||||
|
--- a/bgpd/bgp_updgrp_adv.c
|
||||||
|
+++ b/bgpd/bgp_updgrp_adv.c
|
||||||
|
@@ -715,11 +715,14 @@ void subgroup_announce_table(struct update_subgroup *subgrp,
|
||||||
|
&attr, NULL)) {
|
||||||
|
/* Check if route can be advertised */
|
||||||
|
if (advertise) {
|
||||||
|
- if (!bgp_check_withdrawal(bgp, dest))
|
||||||
|
+ if (!bgp_check_withdrawal(bgp, dest)) {
|
||||||
|
+ struct attr *adv_attr =
|
||||||
|
+ bgp_attr_intern(&attr);
|
||||||
|
+
|
||||||
|
bgp_adj_out_set_subgroup(
|
||||||
|
- dest, subgrp, &attr,
|
||||||
|
+ dest, subgrp, adv_attr,
|
||||||
|
ri);
|
||||||
|
- else
|
||||||
|
+ } else
|
||||||
|
bgp_adj_out_unset_subgroup(
|
||||||
|
dest, subgrp, 1,
|
||||||
|
bgp_addpath_id_for_peer(
|
||||||
|
--
|
||||||
|
2.14.1
|
||||||
|
|
||||||
|
|
||||||
|
From 4b6279f6779ff6f6041bd08b242f86a1098d6e6d Mon Sep 17 00:00:00 2001
|
||||||
|
From: Donald Sharp <sharpd@nvidia.com>
|
||||||
|
Date: Sat, 2 Mar 2024 09:50:38 -0500
|
||||||
|
Subject: [PATCH 4/5] bgpd: Ensure community data is freed in some cases.
|
||||||
|
|
||||||
|
Customer has this valgrind trace:
|
||||||
|
|
||||||
|
Direct leak of 2829120 byte(s) in 70728 object(s) allocated from:
|
||||||
|
0 in community_new ../bgpd/bgp_community.c:39
|
||||||
|
1 in community_uniq_sort ../bgpd/bgp_community.c:170
|
||||||
|
2 in route_set_community ../bgpd/bgp_routemap.c:2342
|
||||||
|
3 in route_map_apply_ext ../lib/routemap.c:2673
|
||||||
|
4 in subgroup_announce_check ../bgpd/bgp_route.c:2367
|
||||||
|
5 in subgroup_process_announce_selected ../bgpd/bgp_route.c:2914
|
||||||
|
6 in group_announce_route_walkcb ../bgpd/bgp_updgrp_adv.c:199
|
||||||
|
7 in hash_walk ../lib/hash.c:285
|
||||||
|
8 in update_group_af_walk ../bgpd/bgp_updgrp.c:2061
|
||||||
|
9 in group_announce_route ../bgpd/bgp_updgrp_adv.c:1059
|
||||||
|
10 in bgp_process_main_one ../bgpd/bgp_route.c:3221
|
||||||
|
11 in bgp_process_wq ../bgpd/bgp_route.c:3221
|
||||||
|
12 in work_queue_run ../lib/workqueue.c:282
|
||||||
|
|
||||||
|
The above leak detected by valgrind was from a screenshot so I copied it
|
||||||
|
by hand. Any mistakes in line numbers are purely from my transcription.
|
||||||
|
Additionally this is against a slightly modified 8.5.1 version of FRR.
|
||||||
|
Code inspection of 8.5.1 -vs- latest master shows the same problem
|
||||||
|
exists. Code should be able to be followed from there to here.
|
||||||
|
|
||||||
|
What is happening:
|
||||||
|
|
||||||
|
There is a route-map being applied that modifes the outgoing community
|
||||||
|
to a peer. This is saved in the attr copy created in
|
||||||
|
subgroup_process_announce_selected. This community pointer is not
|
||||||
|
interned. So the community->refcount is still 0. Normally when
|
||||||
|
a prefix is announced, the attr and the prefix are placed on a
|
||||||
|
adjency out structure where the attribute is interned. This will
|
||||||
|
cause the community to be saved in the community hash list as well.
|
||||||
|
In a non-normal operation when the decision to send is aborted after
|
||||||
|
the route-map application, the attribute is just dropped and the
|
||||||
|
pointer to the community is just dropped too, leading to situations
|
||||||
|
where the memory is leaked. The usage of bgp suppress-fib would
|
||||||
|
would be a case where the community is caused to be leaked.
|
||||||
|
Additionally the previous commit where an unsuppress-map is used
|
||||||
|
to modify the outgoing attribute but since unsuppress-map was
|
||||||
|
not considered part of outgoing policy the attribute would be dropped as
|
||||||
|
well. This pointer drop also extends to any dynamically allocated
|
||||||
|
memory saved by the attribute pointer that was not interned yet as well.
|
||||||
|
|
||||||
|
So let's modify the return case where the decision is made to
|
||||||
|
not send the prefix to the peer to always just flush the attribute
|
||||||
|
to ensure memory is not leaked.
|
||||||
|
|
||||||
|
Fixes: #15459
|
||||||
|
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
|
||||||
|
---
|
||||||
|
bgpd/bgp_conditional_adv.c | 5 +++--
|
||||||
|
bgpd/bgp_route.c | 19 +++++++++++++------
|
||||||
|
bgpd/bgp_updgrp.h | 2 +-
|
||||||
|
bgpd/bgp_updgrp_adv.c | 29 ++++++++++++++++++-----------
|
||||||
|
4 files changed, 35 insertions(+), 20 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/bgpd/bgp_conditional_adv.c b/bgpd/bgp_conditional_adv.c
|
||||||
|
index 4ad00ed121..89ea85ff46 100644
|
||||||
|
--- a/bgpd/bgp_conditional_adv.c
|
||||||
|
+++ b/bgpd/bgp_conditional_adv.c
|
||||||
|
@@ -134,8 +134,9 @@ static void bgp_conditional_adv_routes(struct peer *peer, afi_t afi,
|
||||||
|
if (update_type == UPDATE_TYPE_ADVERTISE &&
|
||||||
|
subgroup_announce_check(dest, pi, subgrp, dest_p,
|
||||||
|
&attr, &advmap_attr)) {
|
||||||
|
- bgp_adj_out_set_subgroup(dest, subgrp, &attr,
|
||||||
|
- pi);
|
||||||
|
+ if (!bgp_adj_out_set_subgroup(dest, subgrp,
|
||||||
|
+ &attr, pi))
|
||||||
|
+ bgp_attr_flush(&attr);
|
||||||
|
} else {
|
||||||
|
/* If default originate is enabled for
|
||||||
|
* the peer, do not send explicit
|
||||||
|
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
|
||||||
|
index 1a7c0cc78e..53eec67e41 100644
|
||||||
|
--- a/bgpd/bgp_route.c
|
||||||
|
+++ b/bgpd/bgp_route.c
|
||||||
|
@@ -2921,16 +2921,23 @@ void subgroup_process_announce_selected(struct update_subgroup *subgrp,
|
||||||
|
struct attr *adv_attr =
|
||||||
|
bgp_attr_intern(&attr);
|
||||||
|
|
||||||
|
- bgp_adj_out_set_subgroup(dest, subgrp,
|
||||||
|
- adv_attr,
|
||||||
|
- selected);
|
||||||
|
- } else
|
||||||
|
+ if (!bgp_adj_out_set_subgroup(dest,
|
||||||
|
+ subgrp,
|
||||||
|
+ adv_attr,
|
||||||
|
+ selected))
|
||||||
|
+ bgp_attr_unintern(&adv_attr);
|
||||||
|
+ } else {
|
||||||
|
bgp_adj_out_unset_subgroup(
|
||||||
|
dest, subgrp, 1, addpath_tx_id);
|
||||||
|
- }
|
||||||
|
- } else
|
||||||
|
+ bgp_attr_flush(&attr);
|
||||||
|
+ }
|
||||||
|
+ } else
|
||||||
|
+ bgp_attr_flush(&attr);
|
||||||
|
+ } else {
|
||||||
|
bgp_adj_out_unset_subgroup(dest, subgrp, 1,
|
||||||
|
addpath_tx_id);
|
||||||
|
+ bgp_attr_flush(&attr);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If selected is NULL we must withdraw the path using addpath_tx_id */
|
||||||
|
diff --git a/bgpd/bgp_updgrp.h b/bgpd/bgp_updgrp.h
|
||||||
|
index e27c1e7b67..b7b6aa07e9 100644
|
||||||
|
--- a/bgpd/bgp_updgrp.h
|
||||||
|
+++ b/bgpd/bgp_updgrp.h
|
||||||
|
@@ -458,7 +458,7 @@ extern struct bgp_adj_out *bgp_adj_out_alloc(struct update_subgroup *subgrp,
|
||||||
|
extern void bgp_adj_out_remove_subgroup(struct bgp_dest *dest,
|
||||||
|
struct bgp_adj_out *adj,
|
||||||
|
struct update_subgroup *subgrp);
|
||||||
|
-extern void bgp_adj_out_set_subgroup(struct bgp_dest *dest,
|
||||||
|
+extern bool bgp_adj_out_set_subgroup(struct bgp_dest *dest,
|
||||||
|
struct update_subgroup *subgrp,
|
||||||
|
struct attr *attr,
|
||||||
|
struct bgp_path_info *path);
|
||||||
|
diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c
|
||||||
|
index de2b3206b7..1ca79f818a 100644
|
||||||
|
--- a/bgpd/bgp_updgrp_adv.c
|
||||||
|
+++ b/bgpd/bgp_updgrp_adv.c
|
||||||
|
@@ -454,7 +454,7 @@ bgp_advertise_clean_subgroup(struct update_subgroup *subgrp,
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
|
||||||
|
-void bgp_adj_out_set_subgroup(struct bgp_dest *dest,
|
||||||
|
+bool bgp_adj_out_set_subgroup(struct bgp_dest *dest,
|
||||||
|
struct update_subgroup *subgrp, struct attr *attr,
|
||||||
|
struct bgp_path_info *path)
|
||||||
|
{
|
||||||
|
@@ -474,7 +474,7 @@ void bgp_adj_out_set_subgroup(struct bgp_dest *dest,
|
||||||
|
bgp = SUBGRP_INST(subgrp);
|
||||||
|
|
||||||
|
if (DISABLE_BGP_ANNOUNCE)
|
||||||
|
- return;
|
||||||
|
+ return false;
|
||||||
|
|
||||||
|
/* Look for adjacency information. */
|
||||||
|
adj = adj_lookup(
|
||||||
|
@@ -490,7 +490,7 @@ void bgp_adj_out_set_subgroup(struct bgp_dest *dest,
|
||||||
|
bgp_addpath_id_for_peer(peer, afi, safi,
|
||||||
|
&path->tx_addpath));
|
||||||
|
if (!adj)
|
||||||
|
- return;
|
||||||
|
+ return false;
|
||||||
|
|
||||||
|
subgrp->pscount++;
|
||||||
|
}
|
||||||
|
@@ -529,7 +529,7 @@ void bgp_adj_out_set_subgroup(struct bgp_dest *dest,
|
||||||
|
* will never be able to coalesce the 3rd peer down
|
||||||
|
*/
|
||||||
|
subgrp->version = MAX(subgrp->version, dest->version);
|
||||||
|
- return;
|
||||||
|
+ return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (adj->adv)
|
||||||
|
@@ -576,6 +576,8 @@ void bgp_adj_out_set_subgroup(struct bgp_dest *dest,
|
||||||
|
bgp_adv_fifo_add_tail(&subgrp->sync->update, adv);
|
||||||
|
|
||||||
|
subgrp->version = MAX(subgrp->version, dest->version);
|
||||||
|
+
|
||||||
|
+ return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The only time 'withdraw' will be false is if we are sending
|
||||||
|
@@ -719,9 +721,10 @@ void subgroup_announce_table(struct update_subgroup *subgrp,
|
||||||
|
struct attr *adv_attr =
|
||||||
|
bgp_attr_intern(&attr);
|
||||||
|
|
||||||
|
- bgp_adj_out_set_subgroup(
|
||||||
|
+ if (!bgp_adj_out_set_subgroup(
|
||||||
|
dest, subgrp, adv_attr,
|
||||||
|
- ri);
|
||||||
|
+ ri))
|
||||||
|
+ bgp_attr_unintern(&adv_attr);
|
||||||
|
} else
|
||||||
|
bgp_adj_out_unset_subgroup(
|
||||||
|
dest, subgrp, 1,
|
||||||
|
@@ -950,7 +953,7 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
|
||||||
|
if (dest) {
|
||||||
|
for (pi = bgp_dest_get_bgp_path_info(dest); pi;
|
||||||
|
pi = pi->next) {
|
||||||
|
- if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED))
|
||||||
|
+ if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)) {
|
||||||
|
if (subgroup_announce_check(
|
||||||
|
dest, pi, subgrp,
|
||||||
|
bgp_dest_get_prefix(dest),
|
||||||
|
@@ -958,10 +961,14 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
|
||||||
|
struct attr *default_attr =
|
||||||
|
bgp_attr_intern(&attr);
|
||||||
|
|
||||||
|
- bgp_adj_out_set_subgroup(
|
||||||
|
- dest, subgrp,
|
||||||
|
- default_attr, pi);
|
||||||
|
- }
|
||||||
|
+ if (!bgp_adj_out_set_subgroup(
|
||||||
|
+ dest, subgrp,
|
||||||
|
+ default_attr, pi))
|
||||||
|
+ bgp_attr_unintern(
|
||||||
|
+ &default_attr);
|
||||||
|
+ } else
|
||||||
|
+ bgp_attr_flush(&attr);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
bgp_dest_unlock_node(dest);
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.14.1
|
||||||
|
|
||||||
|
|
||||||
|
From 99a172180972145556887595a1ca75e82f71c244 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Donald Sharp <sharpd@nvidia.com>
|
||||||
|
Date: Mon, 4 Mar 2024 09:51:42 -0500
|
||||||
|
Subject: [PATCH 5/5] bgpd: Cleanup indenting for subgroup_default_originate
|
||||||
|
|
||||||
|
Part of the subgroup_default_originate function was indented
|
||||||
|
very deeply. Clean this up some.
|
||||||
|
|
||||||
|
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
|
||||||
|
---
|
||||||
|
bgpd/bgp_updgrp_adv.c | 33 +++++++++++++++++----------------
|
||||||
|
1 file changed, 17 insertions(+), 16 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c
|
||||||
|
index 1ca79f818a..364454e06c 100644
|
||||||
|
--- a/bgpd/bgp_updgrp_adv.c
|
||||||
|
+++ b/bgpd/bgp_updgrp_adv.c
|
||||||
|
@@ -953,22 +953,23 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
|
||||||
|
if (dest) {
|
||||||
|
for (pi = bgp_dest_get_bgp_path_info(dest); pi;
|
||||||
|
pi = pi->next) {
|
||||||
|
- if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)) {
|
||||||
|
- if (subgroup_announce_check(
|
||||||
|
- dest, pi, subgrp,
|
||||||
|
- bgp_dest_get_prefix(dest),
|
||||||
|
- &attr, NULL)) {
|
||||||
|
- struct attr *default_attr =
|
||||||
|
- bgp_attr_intern(&attr);
|
||||||
|
-
|
||||||
|
- if (!bgp_adj_out_set_subgroup(
|
||||||
|
- dest, subgrp,
|
||||||
|
- default_attr, pi))
|
||||||
|
- bgp_attr_unintern(
|
||||||
|
- &default_attr);
|
||||||
|
- } else
|
||||||
|
- bgp_attr_flush(&attr);
|
||||||
|
- }
|
||||||
|
+ if (!CHECK_FLAG(pi->flags, BGP_PATH_SELECTED))
|
||||||
|
+ continue;
|
||||||
|
+
|
||||||
|
+ if (subgroup_announce_check(
|
||||||
|
+ dest, pi, subgrp,
|
||||||
|
+ bgp_dest_get_prefix(dest), &attr,
|
||||||
|
+ NULL)) {
|
||||||
|
+ struct attr *default_attr =
|
||||||
|
+ bgp_attr_intern(&attr);
|
||||||
|
+
|
||||||
|
+ if (!bgp_adj_out_set_subgroup(
|
||||||
|
+ dest, subgrp, default_attr,
|
||||||
|
+ pi))
|
||||||
|
+ bgp_attr_unintern(
|
||||||
|
+ &default_attr);
|
||||||
|
+ } else
|
||||||
|
+ bgp_attr_flush(&attr);
|
||||||
|
}
|
||||||
|
bgp_dest_unlock_node(dest);
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.14.1
|
||||||
|
|
@ -0,0 +1,90 @@
|
|||||||
|
From 223ac7ed19e0b73b38c551797c42eb3892d1503d Mon Sep 17 00:00:00 2001
|
||||||
|
From: xuliping <xuliping@microsoft.com>
|
||||||
|
Date: Fri, 8 Mar 2024 05:57:17 +0000
|
||||||
|
Subject: [PATCH] update patch
|
||||||
|
|
||||||
|
---
|
||||||
|
bgpd/bgp_route.c | 6 +++---
|
||||||
|
bgpd/bgp_updgrp_adv.c | 23 ++++++++++++++---------
|
||||||
|
2 files changed, 17 insertions(+), 12 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
|
||||||
|
index 55db3fc7a..f7219ce94 100644
|
||||||
|
--- a/bgpd/bgp_route.c
|
||||||
|
+++ b/bgpd/bgp_route.c
|
||||||
|
@@ -2921,11 +2921,11 @@ void subgroup_process_announce_selected(struct update_subgroup *subgrp,
|
||||||
|
struct attr *adv_attr =
|
||||||
|
bgp_attr_intern(&attr);
|
||||||
|
|
||||||
|
- if (!bgp_adj_out_set_subgroup(dest,
|
||||||
|
+ bgp_adj_out_set_subgroup(dest,
|
||||||
|
subgrp,
|
||||||
|
adv_attr,
|
||||||
|
- selected))
|
||||||
|
- bgp_attr_unintern(&adv_attr);
|
||||||
|
+ selected);
|
||||||
|
+ bgp_attr_unintern(&adv_attr);
|
||||||
|
} else {
|
||||||
|
bgp_adj_out_unset_subgroup(
|
||||||
|
dest, subgrp, 1, addpath_tx_id);
|
||||||
|
diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c
|
||||||
|
index 364454e06..cc62548f6 100644
|
||||||
|
--- a/bgpd/bgp_updgrp_adv.c
|
||||||
|
+++ b/bgpd/bgp_updgrp_adv.c
|
||||||
|
@@ -670,7 +670,7 @@ void subgroup_announce_table(struct update_subgroup *subgrp,
|
||||||
|
{
|
||||||
|
struct bgp_dest *dest;
|
||||||
|
struct bgp_path_info *ri;
|
||||||
|
- struct attr attr;
|
||||||
|
+ struct attr attr = {0};
|
||||||
|
struct peer *peer;
|
||||||
|
afi_t afi;
|
||||||
|
safi_t safi;
|
||||||
|
@@ -721,19 +721,24 @@ void subgroup_announce_table(struct update_subgroup *subgrp,
|
||||||
|
struct attr *adv_attr =
|
||||||
|
bgp_attr_intern(&attr);
|
||||||
|
|
||||||
|
- if (!bgp_adj_out_set_subgroup(
|
||||||
|
+ bgp_adj_out_set_subgroup(
|
||||||
|
dest, subgrp, adv_attr,
|
||||||
|
- ri))
|
||||||
|
- bgp_attr_unintern(&adv_attr);
|
||||||
|
- } else
|
||||||
|
+ ri);
|
||||||
|
+ bgp_attr_unintern(&adv_attr);
|
||||||
|
+ } else {
|
||||||
|
bgp_adj_out_unset_subgroup(
|
||||||
|
dest, subgrp, 1,
|
||||||
|
bgp_addpath_id_for_peer(
|
||||||
|
peer, afi,
|
||||||
|
safi_rib,
|
||||||
|
&ri->tx_addpath));
|
||||||
|
+ bgp_attr_flush(&attr);
|
||||||
|
+ }
|
||||||
|
+ } else {
|
||||||
|
+ bgp_attr_flush(&attr);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
+ bgp_attr_flush(&attr);
|
||||||
|
/* If default originate is enabled for
|
||||||
|
* the peer, do not send explicit
|
||||||
|
* withdraw. This will prevent deletion
|
||||||
|
@@ -963,11 +968,11 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
|
||||||
|
struct attr *default_attr =
|
||||||
|
bgp_attr_intern(&attr);
|
||||||
|
|
||||||
|
- if (!bgp_adj_out_set_subgroup(
|
||||||
|
+ bgp_adj_out_set_subgroup(
|
||||||
|
dest, subgrp, default_attr,
|
||||||
|
- pi))
|
||||||
|
- bgp_attr_unintern(
|
||||||
|
- &default_attr);
|
||||||
|
+ pi);
|
||||||
|
+ bgp_attr_unintern(
|
||||||
|
+ &default_attr);
|
||||||
|
} else
|
||||||
|
bgp_attr_flush(&attr);
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.25.1
|
||||||
|
|
@ -33,3 +33,5 @@ cross-compile-changes.patch
|
|||||||
0034-fpm-Use-vrf_id-for-vrf-not-tabled_id.patch
|
0034-fpm-Use-vrf_id-for-vrf-not-tabled_id.patch
|
||||||
0035-fpm-ignore-route-from-default-table.patch
|
0035-fpm-ignore-route-from-default-table.patch
|
||||||
0036-Add-support-of-bgp-l3vni-evpn.patch
|
0036-Add-support-of-bgp-l3vni-evpn.patch
|
||||||
|
0037-bgp-community-memory-leak-fix.patch
|
||||||
|
0038-bgp-community-memory-leak-update.patch
|
||||||
|
Loading…
Reference in New Issue
Block a user