]> git.ipfire.org Git - thirdparty/qemu.git/commit
e1000: Separate TSO and non-TSO contexts, fixing UDP TX corruption
authorEd Swierk via Qemu-devel <qemu-devel@nongnu.org>
Tue, 14 Nov 2017 23:23:34 +0000 (15:23 -0800)
committerJason Wang <jasowang@redhat.com>
Fri, 22 Dec 2017 01:53:50 +0000 (09:53 +0800)
commitd62644b46a86bce2c069af7122501e3ffd349d3c
treea4ed379425aaf3cd4a089382cfbac836eed7d556
parent7d08c73e7bdc39b10e5f2f5acdce700f17ffe962
e1000: Separate TSO and non-TSO contexts, fixing UDP TX corruption

The device is supposed to maintain two distinct contexts for transmit
offloads: one has parameters for both segmentation and checksum
offload, the other only for checksum offload. The guest driver can
send two context descriptors, one for each context (the TSE flag
specifies which). Then the guest can refer to one or the other context
in subsequent transmit data descriptors, depending on what offloads it
wants applied to each packet.

Currently the e1000 device stores just one context, and misinterprets
the TSE flags in the context and data descriptors. This is often okay:
Linux happens to send a fresh context descriptor before every data
descriptor, so forgetting the other context doesn't matter. Windows
does rely on separate contexts for TSO vs. non-TSO packets, but for
mostly-TCP traffic the two contexts have identical TCP-specific
offload parameters so confusing them doesn't matter.

One case where this confusion matters is when a Windows guest sets up
a TSO context for TCP and a non-TSO context for UDP, and then
transmits both TCP and UDP traffic in parallel. The e1000 device
sometimes ends up using TCP-specific parameters while doing checksum
offload on a UDP datagram: it writes the checksum to offset 16 (the
correct location for a TCP checksum), stomping on two bytes of UDP
data, and leaving the wrong value in the actual UDP checksum field at
offset 6. (Even worse, the host network stack may then recompute the
UDP checksum, "correcting" it to match the corrupt data before sending
it out a physical interface.)

Correct this by tracking the TSO context independently of the non-TSO
context, and selecting the appropriate context based on the TSE flag
in each transmit data descriptor.

Signed-off-by: Ed Swierk <eswierk@skyportsystems.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
hw/net/e1000.c