From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id C94065596 for ; Fri, 29 Apr 2016 18:31:03 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 29 Apr 2016 09:31:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,552,1455004800"; d="scan'208";a="965501187" Received: from unknown (HELO Sent) ([10.217.248.60]) by orsmga002.jf.intel.com with SMTP; 29 Apr 2016 09:31:01 -0700 Received: by Sent (sSMTP sendmail emulation); Fri, 29 Apr 2016 18:31:00 +0200 From: Tomasz Kulasek To: ian.betts@intel.com Cc: dev@dpdk.org Date: Fri, 29 Apr 2016 18:30:56 +0200 Message-Id: <1461947456-7728-1-git-send-email-tomaszx.kulasek@intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1461163527-7348-1-git-send-email-tomaszx.kulasek@intel.com> References: <1461163527-7348-1-git-send-email-tomaszx.kulasek@intel.com> Subject: [dpdk-dev] [PATCH v2] examples/performance-thread: fix logic in get_dst_port of l3fwd-thread X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Apr 2016 16:31:04 -0000 This fixes wrong logic in get_dst_port() on lpm path causing unpredictable return value when ipv4/ipv6 lookup success (return with no value). Fixes: dc81ebbacaeb ("lpm: extend IPv4 next hop field") Signed-off-by: Tomasz Kulasek --- v2: - split into two patches examples/performance-thread/l3fwd-thread/main.c | 25 +++++++++++------------ 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/examples/performance-thread/l3fwd-thread/main.c b/examples/performance-thread/l3fwd-thread/main.c index c008d6a..7d90a16 100644 --- a/examples/performance-thread/l3fwd-thread/main.c +++ b/examples/performance-thread/l3fwd-thread/main.c @@ -1343,24 +1343,23 @@ get_dst_port(struct rte_mbuf *pkt, uint32_t dst_ipv4, uint8_t portid) struct ether_hdr *eth_hdr; if (RTE_ETH_IS_IPV4_HDR(pkt->packet_type)) { - if (rte_lpm_lookup(RTE_PER_LCORE(lcore_conf)->ipv4_lookup_struct, - dst_ipv4, &next_hop_ipv4) != 0) { - next_hop_ipv4 = portid; - return next_hop_ipv4; - } + return (uint16_t) ((rte_lpm_lookup( + RTE_PER_LCORE(lcore_conf)->ipv4_lookup_struct, dst_ipv4, + &next_hop_ipv4) == 0) ? next_hop_ipv4 : portid); + } else if (RTE_ETH_IS_IPV6_HDR(pkt->packet_type)) { + eth_hdr = rte_pktmbuf_mtod(pkt, struct ether_hdr *); ipv6_hdr = (struct ipv6_hdr *)(eth_hdr + 1); - if (rte_lpm6_lookup(RTE_PER_LCORE(lcore_conf)->ipv6_lookup_struct, - ipv6_hdr->dst_addr, &next_hop_ipv6) != 0) { - next_hop_ipv6 = portid; - return next_hop_ipv6; - } - } else { - next_hop_ipv4 = portid; - return next_hop_ipv4; + + return (uint16_t) ((rte_lpm6_lookup( + RTE_PER_LCORE(lcore_conf)->ipv6_lookup_struct, + ipv6_hdr->dst_addr, &next_hop_ipv6) == 0) ? next_hop_ipv6 : + portid); + } + return portid; } static inline void -- 1.7.9.5