aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Tuexen <tuexen@FreeBSD.org>2021-03-18 20:25:47 +0000
committerMichael Tuexen <tuexen@FreeBSD.org>2021-03-18 20:35:49 +0000
commit11660fa28fd39a644cb7d30a4378cf4751b89f15 (patch)
tree0ca7ab8318e6080882ee3d0ee89c784f68c3ba30
parentfaa41af1fed350327cc542cb240ca2c6e1e8ba0c (diff)
vtnet: fix TSO for TCP/IPv6
The decision whether a TCP packet is sent over IPv4 or IPv6 was based on ethertype, which works correctly. In D27926 the criteria was changed to checking if the CSUM_IP_TSO flag is set in the csum-flags and then considering it to be TCP/IPv4. However, the TCP stack sets the flag to CSUM_TSO for IPv4 and IPv6, where CSUM_TSO is defined as CSUM_IP_TSO|CSUM_IP6_TSO. Therefore TCP/IPv6 packets gets mis-classified as TCP/IPv4, which breaks TSO for TCP/IPv6. This patch bases the check again on the ethertype. This fix is instantly MFCed. Approved by: re(gjb) PR: 254366 Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D29331 (cherry picked from commit d4697a6b56168876fc0ffec1a0bb1b24d25b198e) (cherry picked from commit 6064ea8172f078c54954bc6e8865625feb7979fe)
-rw-r--r--sys/dev/virtio/network/if_vtnet.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/dev/virtio/network/if_vtnet.c b/sys/dev/virtio/network/if_vtnet.c
index e64b7de113c8..7aee77839bf3 100644
--- a/sys/dev/virtio/network/if_vtnet.c
+++ b/sys/dev/virtio/network/if_vtnet.c
@@ -2389,7 +2389,7 @@ vtnet_txq_offload_ctx(struct vtnet_txq *txq, struct mbuf *m, int *etype,
}
static int
-vtnet_txq_offload_tso(struct vtnet_txq *txq, struct mbuf *m, int flags,
+vtnet_txq_offload_tso(struct vtnet_txq *txq, struct mbuf *m, int eth_type,
int offset, struct virtio_net_hdr *hdr)
{
static struct timeval lastecn;
@@ -2407,8 +2407,8 @@ vtnet_txq_offload_tso(struct vtnet_txq *txq, struct mbuf *m, int flags,
hdr->hdr_len = vtnet_gtoh16(sc, offset + (tcp->th_off << 2));
hdr->gso_size = vtnet_gtoh16(sc, m->m_pkthdr.tso_segsz);
- hdr->gso_type = (flags & CSUM_IP_TSO) ?
- VIRTIO_NET_HDR_GSO_TCPV4 : VIRTIO_NET_HDR_GSO_TCPV6;
+ hdr->gso_type = eth_type == ETHERTYPE_IP ? VIRTIO_NET_HDR_GSO_TCPV4 :
+ VIRTIO_NET_HDR_GSO_TCPV6;
if (__predict_false(tcp->th_flags & TH_CWR)) {
/*
@@ -2474,7 +2474,7 @@ vtnet_txq_offload(struct vtnet_txq *txq, struct mbuf *m,
goto drop;
}
- error = vtnet_txq_offload_tso(txq, m, flags, csum_start, hdr);
+ error = vtnet_txq_offload_tso(txq, m, etype, csum_start, hdr);
if (error)
goto drop;
}