git: 6064ea8172f0 - stable/13 - vtnet: fix TSO for TCP/IPv6

Michael Tuexen tuexen at FreeBSD.org
Thu Mar 18 20:35:00 UTC 2021


The branch stable/13 has been updated by tuexen:

URL: https://cgit.FreeBSD.org/src/commit/?id=6064ea8172f078c54954bc6e8865625feb7979fe

commit 6064ea8172f078c54954bc6e8865625feb7979fe
Author:     Michael Tuexen <tuexen at FreeBSD.org>
AuthorDate: 2021-03-18 20:25:47 +0000
Commit:     Michael Tuexen <tuexen at FreeBSD.org>
CommitDate: 2021-03-18 20:33:32 +0000

    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)
---
 sys/dev/virtio/network/if_vtnet.c | 8 ++++----
 1 file 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;
 	}


More information about the dev-commits-src-all mailing list