fib: fix adding default route overwriting entire table

Message ID 20231002151148.675857-1-vladimir.medvedkin@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series fib: fix adding default route overwriting entire table |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS

Commit Message

Vladimir Medvedkin Oct. 2, 2023, 3:11 p.m. UTC
  When FIB contains any route covering last ip address
(255.255.255.255), upon adding a new default route
the entire fib table will be overwritten with corresponding
default route next hop.

Previous fix added check for ledge against 0 for case
if default route is added as a first route, however
this check was also erroneously triggered in case when
ledge was wrapped around the address space
(this would happen if FIB contains any route covering
last possible address - 255.255.255.255).

This fix prevents wrap around from happening.

Fixes: 880bc2b5f3bd ("fib: fix adding default route")
Cc: stable@dpdk.org

Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
---
 lib/fib/dir24_8.c | 6 ++++++
 1 file changed, 6 insertions(+)
  

Comments

Thomas Monjalon Oct. 17, 2023, 1:26 p.m. UTC | #1
02/10/2023 17:11, Vladimir Medvedkin:
> When FIB contains any route covering last ip address
> (255.255.255.255), upon adding a new default route
> the entire fib table will be overwritten with corresponding
> default route next hop.
> 
> Previous fix added check for ledge against 0 for case
> if default route is added as a first route, however
> this check was also erroneously triggered in case when
> ledge was wrapped around the address space
> (this would happen if FIB contains any route covering
> last possible address - 255.255.255.255).
> 
> This fix prevents wrap around from happening.
> 
> Fixes: 880bc2b5f3bd ("fib: fix adding default route")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>

Applied, thanks.
  

Patch

diff --git a/lib/fib/dir24_8.c b/lib/fib/dir24_8.c
index 3efdcb533c..5f73b8a7f0 100644
--- a/lib/fib/dir24_8.c
+++ b/lib/fib/dir24_8.c
@@ -388,6 +388,12 @@  modify_fib(struct dir24_8_tbl *dp, struct rte_rib *rib, uint32_t ip,
 				return ret;
 			ledge = redge +
 				(uint32_t)(1ULL << (32 - tmp_depth));
+			/*
+			 * we got to the end of address space
+			 * and wrapped around
+			 */
+			if (ledge == 0)
+				break;
 		} else {
 			redge = ip + (uint32_t)(1ULL << (32 - depth));
 			if (ledge == redge && ledge != 0)