DPDK patches and discussions
 help / color / mirror / Atom feed
From: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
To: dev@dpdk.org
Cc: stable@dpdk.org
Subject: [PATCH] fib: fix adding default route overwriting entire table
Date: Mon,  2 Oct 2023 15:11:48 +0000	[thread overview]
Message-ID: <20231002151148.675857-1-vladimir.medvedkin@intel.com> (raw)

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(+)

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)
-- 
2.34.1


             reply	other threads:[~2023-10-02 15:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-02 15:11 Vladimir Medvedkin [this message]
2023-10-17 13:26 ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231002151148.675857-1-vladimir.medvedkin@intel.com \
    --to=vladimir.medvedkin@intel.com \
    --cc=dev@dpdk.org \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).