From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 864C7426A3 for ; Mon, 2 Oct 2023 17:12:07 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 80C81402E8; Mon, 2 Oct 2023 17:12:07 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 1305E402E1; Mon, 2 Oct 2023 17:12:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696259526; x=1727795526; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=9eWPxgOTutp71T8ZEhO7s4H5DUxkDr8+0bH9vhIXlIw=; b=egEaCT10aqjCh6KdDyAr8uDpZzIufvvZlpHdH/VC7tVj6cpz45TAjYan ApBw1qfIgal/zXSBpfJmojBR/Gd0RHxtCOag+r7nWJEEZcnd+gQnQJ98i IvUArQDGsnk9srsIFGGZcnjVfZXfKFhmwwnxI3HKiBBTgF2C4ycMOdBhG s7vclpXgkz6oK3Z5Vh7lG7dhrmycGC5jmbrQEb0+IMNge4QMNFqB1Fy/6 LqFczlPDhgP0kNYefTZ7nDE7+bgY0WC8Ku4759raR7zJOUGAbZxdI7mt3 AIQ/6IBeQy4NDomtXhuh+H2NmTCgcL/vvEiYsbyH9hF2cJQjmx8ff3Rxa w==; X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="367717994" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="367717994" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Oct 2023 08:12:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10851"; a="727297460" X-IronPort-AV: E=Sophos;i="6.03,194,1694761200"; d="scan'208";a="727297460" Received: from silpixa00400072.ir.intel.com (HELO silpixa00400072.ger.corp.intel.com) ([10.237.222.194]) by orsmga006.jf.intel.com with ESMTP; 02 Oct 2023 08:12:04 -0700 From: Vladimir Medvedkin 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 Message-Id: <20231002151201.675868-1-vladimir.medvedkin@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org 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 --- 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