net/bnxt: fix null dereference in session cleanup
[dpdk.git] / app / test-pmd / 5tswap.c
index d9026ce..629d3e0 100644 (file)
@@ -27,9 +27,9 @@ swap_mac(struct rte_ether_hdr *eth_hdr)
        struct rte_ether_addr addr;
 
        /* Swap dest and src mac addresses. */
-       rte_ether_addr_copy(&eth_hdr->d_addr, &addr);
-       rte_ether_addr_copy(&eth_hdr->s_addr, &eth_hdr->d_addr);
-       rte_ether_addr_copy(&addr, &eth_hdr->s_addr);
+       rte_ether_addr_copy(&eth_hdr->dst_addr, &addr);
+       rte_ether_addr_copy(&eth_hdr->src_addr, &eth_hdr->dst_addr);
+       rte_ether_addr_copy(&addr, &eth_hdr->src_addr);
 }
 
 static inline void
@@ -114,11 +114,10 @@ pkt_burst_5tuple_swap(struct fwd_stream *fs)
         */
        nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst,
                                 nb_pkt_per_burst);
+       inc_rx_burst_stats(fs, nb_rx);
        if (unlikely(nb_rx == 0))
                return;
 
-       inc_rx_burst_stats(fs, nb_rx);
-
        fs->rx_packets += nb_rx;
        txp = &ports[fs->tx_port];
        ol_flags = ol_flags_init(txp->dev_conf.txmode.offloads);
@@ -143,7 +142,7 @@ pkt_burst_5tuple_swap(struct fwd_stream *fs)
                if (proto == RTE_BE16(RTE_ETHER_TYPE_IPV4)) {
                        swap_ipv4(h.ipv4);
                        next_proto = h.ipv4->next_proto_id;
-                       mb->l3_len = (h.ipv4->version_ihl & 0x0f) * 4;
+                       mb->l3_len = rte_ipv4_hdr_len(h.ipv4);
                        h.byte += mb->l3_len;
                } else if (proto == RTE_BE16(RTE_ETHER_TYPE_IPV6)) {
                        swap_ipv6(h.ipv6);