aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Zec <zec@FreeBSD.org>2024-05-17 16:36:21 +0000
committerMarko Zec <zec@FreeBSD.org>2024-05-22 17:37:43 +0000
commit56d8fb27484746416a74c8bd36aacc9edd0f4794 (patch)
tree60179272048fbcf449b4ad60add7772ac2ca0705
parent9629a4b6865c5c56804f79a62f45512b175776e2 (diff)
fib_dxr: do not leak memory if FIB constellation hits structural limit
DXR lookup table encoding has an inherent structural limit on the amount of binary search ranges it can accomodate. With the current IPv4 BGP views (circa 1 M prefixes) and default DXR encoding we are only at around 5% of that limit, so far, far away from hitting it. Just in case it ever gets hit, make sure we free the allocated structures, instead of leaking it. MFC after: 1 week (cherry picked from commit 19bd24caa4c8c76ddf138b3a1598a21c8c5c3291)
-rw-r--r--sys/netinet/in_fib_dxr.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/netinet/in_fib_dxr.c b/sys/netinet/in_fib_dxr.c
index 539d7fe6c96f..326710cc4c45 100644
--- a/sys/netinet/in_fib_dxr.c
+++ b/sys/netinet/in_fib_dxr.c
@@ -1320,8 +1320,10 @@ dxr_change_rib_batch(struct rib_head *rnh, struct fib_change_queue *q,
dxr_build(new_dxr);
/* Structural limit exceeded, hard error */
- if (da->rtbl_top >= BASE_MAX)
+ if (da->rtbl_top >= BASE_MAX) {
+ dxr_destroy(new_dxr);
return (FLM_ERROR);
+ }
if (new_dxr->d == NULL) {
dxr_destroy(new_dxr);