Skip to contentSkip to conversation

fib: fix incorrect prefix addition handling

PATCH Applied Vladimir Medvedkin 2 participants 2 messages Jan 21 – Feb 16

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fib: fix incorrect prefix addition handling

When adding a prefix longer than /24 in FIB/FIB6 as a first prefix within its corresponding /24 supernet with the same next hop as its parent, the code would incorrectly skip incrementing the number of reserved TBL8 due to an early return statement. This could lead to integer overflow in 'dp->rsvd_tbl8s'. This commit corrects the logic to ensure that the reserved TBL8 count is properly incremented in such scenarios.

Bugzilla ID: 1731

Fixes 7dc7868b200d ("fib: add DIR24-8 dataplane algorithm")
Fixes c3e12e0f0354 ("fib: add dataplane algorithm for IPv6")
---
 lib/fib/dir24_8.c | 3 ++-
 lib/fib/trie.c    | 4 ++--
 2 files changed, 4 insertions(+), 3 deletions(-)
lib/fib/dir24_8.c +2 -1
index 2ba7e93511..1d99c8b21f 100644
@@ -495,13 +495,14 @@ dir24_8_modify(struct rte_fib *fib, uint32_t ip, uint8_t depth,
 		if (parent != NULL) {
 			rte_rib_get_nh(parent, &par_nh);
 			if (par_nh == next_hop)
-				return 0;
+				goto successfully_added;
 		}
 		ret = modify_fib(dp, rib, ip, depth, next_hop);
 		if (ret != 0) {
 			rte_rib_remove(rib, ip, depth);
 			return ret;
 		}
+successfully_added:
 		if ((depth > 24) && (tmp == NULL))
 			dp->rsvd_tbl8s++;
 		return 0;
lib/fib/trie.c +2 -2
index 24a08b827d..edb7442cb1 100644
@@ -571,14 +571,14 @@ trie_modify(struct rte_fib6 *fib, const struct rte_ipv6_addr *ip,
 		if (parent != NULL) {
 			rte_rib6_get_nh(parent, &par_nh);
 			if (par_nh == next_hop)
-				return 0;
+				goto successfully_added;
 		}
 		ret = modify_dp(dp, rib, &ip_masked, depth, next_hop);
 		if (ret != 0) {
 			rte_rib6_remove(rib, &ip_masked, depth);
 			return ret;
 		}
-
+successfully_added:
 		dp->rsvd_tbl8s += depth_diff;
 		return 0;
 	case RTE_FIB6_DEL:
Signature · 1 line
2.43.0
#1 lore raw

21/01/2026 18:57, Vladimir Medvedkin:

Quoted 7 lines

When adding a prefix longer than /24 in FIB/FIB6 as a first prefix within its corresponding /24 supernet with the same next hop as its parent, the code would incorrectly skip incrementing the number of reserved TBL8 due to an early return statement. This could lead to integer overflow in 'dp->rsvd_tbl8s'. This commit corrects the logic to ensure that the reserved TBL8 count is properly incremented in such scenarios.

Quoted 6 lines

Bugzilla ID: 1731

Fixes 7dc7868b200d ("fib: add DIR24-8 dataplane algorithm")
Fixes c3e12e0f0354 ("fib: add dataplane algorithm for IPv6")

Applied, thanks.