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] fib6: fix adding default route as first route
Date: Mon,  2 Oct 2023 15:12:01 +0000	[thread overview]
Message-ID: <20231002151201.675868-1-vladimir.medvedkin@intel.com> (raw)

Currently when adding default route as first route
it is not added and no error is reported.
When we enter the loop over an address range in
the general case we will eventually reach the check
for when the range has ended, and exit the loop.
However when adding default route as first route,
since address range covered begins and ends at zero
this also triggers loop exit without writing to the table.

Fixed by adding check for default route,
i.e. both ledge and redge are equal to 0::0.

Bugzilla ID: 1272
Fixes: c3e12e0f0354 ("fib: add dataplane algorithm for IPv6")
Cc: stable@dpdk.org

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

diff --git a/lib/fib/trie.c b/lib/fib/trie.c
index 3e780afdaf..09470e7287 100644
--- a/lib/fib/trie.c
+++ b/lib/fib/trie.c
@@ -451,6 +451,14 @@ get_nxt_net(uint8_t *ip, uint8_t depth)
 	}
 }
 
+static int
+v6_addr_is_zero(const uint8_t ip[RTE_FIB6_IPV6_ADDR_SIZE])
+{
+	uint8_t ip_addr[RTE_FIB6_IPV6_ADDR_SIZE] = {0};
+
+	return rte_rib6_is_equal(ip, ip_addr);
+}
+
 static int
 modify_dp(struct rte_trie_tbl *dp, struct rte_rib6 *rib,
 	const uint8_t ip[RTE_FIB6_IPV6_ADDR_SIZE],
@@ -484,11 +492,19 @@ modify_dp(struct rte_trie_tbl *dp, struct rte_rib6 *rib,
 				return ret;
 			get_nxt_net(redge, tmp_depth);
 			rte_rib6_copy_addr(ledge, redge);
+			/*
+			 * we got to the end of address space
+			 * and wrapped around
+			 */
+			if (v6_addr_is_zero(ledge))
+				break;
 		} else {
 			rte_rib6_copy_addr(redge, ip);
 			get_nxt_net(redge, depth);
-			if (rte_rib6_is_equal(ledge, redge))
+			if (rte_rib6_is_equal(ledge, redge) &&
+					!v6_addr_is_zero(ledge))
 				break;
+
 			ret = install_to_dp(dp, ledge, redge,
 				next_hop);
 			if (ret != 0)
-- 
2.34.1


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

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-02 15:12 Vladimir Medvedkin [this message]
2023-10-17 13:27 ` 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=20231002151201.675868-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).