|
1 |
| -From 57ef410c4b175e6eeb14613745fba1ec6cde0780 Mon Sep 17 00:00:00 2001 |
| 1 | +From 2b8e4e4b93a78e5884e2e5b97050b4ea3843e2e0 Mon Sep 17 00:00:00 2001 |
2 | 2 | From: Donald Sharp <sharpd@nvidia.com>
|
3 | 3 | Date: Thu, 7 Mar 2024 22:18:18 -0500
|
4 |
| -Subject: [PATCH] bgpd: Combined patch to clean up filter leaks |
| 4 | +Subject: [PATCH 1/2] bgpd: Combined patch to clean up filter leaks |
5 | 5 |
|
6 | 6 | Customer has this valgrind trace:
|
7 | 7 |
|
@@ -52,6 +52,12 @@ to ensure memory is not leaked.
|
52 | 52 |
|
53 | 53 | Fixes: #15459
|
54 | 54 | Signed-off-by: Donald Sharp <sharpd@nvidia.com>
|
| 55 | +--- |
| 56 | + bgpd/bgp_conditional_adv.c | 5 +++-- |
| 57 | + bgpd/bgp_route.c | 19 +++++++++++------ |
| 58 | + bgpd/bgp_updgrp.h | 2 +- |
| 59 | + bgpd/bgp_updgrp_adv.c | 53 ++++++++++++++++++++++++++-------------------- |
| 60 | + 4 files changed, 47 insertions(+), 32 deletions(-) |
55 | 61 |
|
56 | 62 | diff --git a/bgpd/bgp_conditional_adv.c b/bgpd/bgp_conditional_adv.c
|
57 | 63 | index 4ad00ed121..89ea85ff46 100644
|
@@ -239,3 +245,59 @@ index af8ef751da..301a8b267e 100644
|
239 | 245 | --
|
240 | 246 | 2.14.1
|
241 | 247 |
|
| 248 | + |
| 249 | +From 761907075520aa3fae70a8d18fa717a24d3cbd65 Mon Sep 17 00:00:00 2001 |
| 250 | +From: Donald Sharp <sharpd@nvidia.com> |
| 251 | +Date: Wed, 13 Mar 2024 10:26:58 -0400 |
| 252 | +Subject: [PATCH 2/2] bgpd: Ensure that the correct aspath is free'd |
| 253 | + |
| 254 | +Currently in subgroup_default_originate the attr.aspath |
| 255 | +is set in bgp_attr_default_set, which hashs the aspath |
| 256 | +and creates a refcount for it. If this is a withdraw |
| 257 | +the subgroup_announce_check and bgp_adj_out_set_subgroup |
| 258 | +is called which will intern the attribute. This will |
| 259 | +cause the the attr.aspath to be set to a new value |
| 260 | +finally at the bottom of the function it intentionally |
| 261 | +uninterns the aspath which is not the one that was |
| 262 | +created for this function. This reduces the other |
| 263 | +aspath's refcount by 1 and if a clear bgp * is issued |
| 264 | +fast enough the aspath for that will be removed |
| 265 | +and the system will crash. |
| 266 | + |
| 267 | +Signed-off-by: Donald Sharp <sharpd@nvidia.com> |
| 268 | +--- |
| 269 | + bgpd/bgp_updgrp_adv.c | 4 +++- |
| 270 | + 1 file changed, 3 insertions(+), 1 deletion(-) |
| 271 | + |
| 272 | +diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c |
| 273 | +index 301a8b267e..75e377f9a1 100644 |
| 274 | +--- a/bgpd/bgp_updgrp_adv.c |
| 275 | ++++ b/bgpd/bgp_updgrp_adv.c |
| 276 | +@@ -817,6 +817,7 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw) |
| 277 | + struct bgp *bgp; |
| 278 | + struct attr attr; |
| 279 | + struct attr *new_attr = &attr; |
| 280 | ++ struct aspath *aspath; |
| 281 | + struct prefix p; |
| 282 | + struct peer *from; |
| 283 | + struct bgp_dest *dest; |
| 284 | +@@ -854,6 +855,7 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw) |
| 285 | + /* make coverity happy */ |
| 286 | + assert(attr.aspath); |
| 287 | + |
| 288 | ++ aspath = attr.aspath; |
| 289 | + attr.med = 0; |
| 290 | + attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC); |
| 291 | + |
| 292 | +@@ -1009,7 +1011,7 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw) |
| 293 | + } |
| 294 | + } |
| 295 | + |
| 296 | +- aspath_unintern(&attr.aspath); |
| 297 | ++ aspath_unintern(&aspath); |
| 298 | + } |
| 299 | + |
| 300 | + /* |
| 301 | +-- |
| 302 | +2.14.1 |
| 303 | + |
0 commit comments