Skip to content

Commit

Permalink
net/tap: fix IPv4 checksum offloading
Browse files Browse the repository at this point in the history
[ upstream commit 3e9c82e88069b1e6e945479626b4c054edf8ba96 ]

Checking that one of RTE_MBUF_F_TX_IPV4 or RTE_MBUF_F_TX_IP_CKSUM is
present is not compliant with the offloading API which specifies that IP
checksum requires RTE_MBUF_F_TX_IP_CKSUM.
On the other hand, RTE_MBUF_F_TX_IP_CKSUM is invalid for IPv6 packets,
so we can simply check for RTE_MBUF_F_TX_IP_CKSUM and assume this is an
IPv4 packet.

Fixes: 8ae3023 ("net/tap: add Rx/Tx checksum offload support")

Signed-off-by: David Marchand <david.marchand@redhat.com>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
  • Loading branch information
david-marchand authored and bluca committed Nov 8, 2023
1 parent 3c5688e commit 8932ba1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/net/tap/rte_eth_tap.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ tap_tx_l3_cksum(char *packet, uint64_t ol_flags, unsigned int l2_len,
{
void *l3_hdr = packet + l2_len;

if (ol_flags & (PKT_TX_IP_CKSUM | PKT_TX_IPV4)) {
if (ol_flags & PKT_TX_IP_CKSUM) {
struct rte_ipv4_hdr *iph = l3_hdr;
uint16_t cksum;

Expand Down Expand Up @@ -653,7 +653,7 @@ tap_write_mbufs(struct tx_queue *txq, uint16_t num_mbufs,

nb_segs = mbuf->nb_segs;
if (txq->csum &&
((mbuf->ol_flags & (PKT_TX_IP_CKSUM | PKT_TX_IPV4) ||
((mbuf->ol_flags & PKT_TX_IP_CKSUM ||
(mbuf->ol_flags & PKT_TX_L4_MASK) == PKT_TX_UDP_CKSUM ||
(mbuf->ol_flags & PKT_TX_L4_MASK) == PKT_TX_TCP_CKSUM))) {
unsigned int l4_len = 0;
Expand Down

0 comments on commit 8932ba1

Please sign in to comment.