[dpdk-dev,v2] examples/performance-thread: fix logic in get_dst_port of l3fwd-thread
Commit Message
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(-)
Comments
2016-04-29 18:30, Tomasz Kulasek:
> 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>
Applied, thanks
@@ -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