From: Tomasz Kulasek <tomaszx.kulasek@intel.com>
To: ian.betts@intel.com
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v2] examples/performance-thread: fix logic in get_dst_port of l3fwd-thread
Date: Fri, 29 Apr 2016 18:30:56 +0200 [thread overview]
Message-ID: <1461947456-7728-1-git-send-email-tomaszx.kulasek@intel.com> (raw)
In-Reply-To: <1461163527-7348-1-git-send-email-tomaszx.kulasek@intel.com>
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 <tomaszx.kulasek@intel.com>
---
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
next prev parent reply other threads:[~2016-04-29 16:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-20 14:45 [dpdk-dev] [PATCH] examples/performance-thread: fix size of destination port ids in l3fwd-thread Tomasz Kulasek
2016-04-27 15:25 ` Thomas Monjalon
2016-04-29 16:30 ` [dpdk-dev] [PATCH v2] " Tomasz Kulasek
2016-06-08 20:25 ` Thomas Monjalon
2016-04-29 16:30 ` Tomasz Kulasek [this message]
2016-06-08 20:25 ` [dpdk-dev] [PATCH v2] examples/performance-thread: fix logic in get_dst_port of l3fwd-thread 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=1461947456-7728-1-git-send-email-tomaszx.kulasek@intel.com \
--to=tomaszx.kulasek@intel.com \
--cc=dev@dpdk.org \
--cc=ian.betts@intel.com \
/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).