summary refs log tree commit diff stats
path: root/hw/net/e1000.c
diff options
context:
space:
mode:
authorEd Swierk <eswierk@skyportsystems.com>2017-11-16 06:06:06 -0800
committerJason Wang <jasowang@redhat.com>2017-11-20 11:08:00 +0800
commit0dacea92d26c31d453c58de2e99c178fee554166 (patch)
tree5b8fd0c05385e02a586fbc136808821e603ea14f /hw/net/e1000.c
parentebc2327f0793deed845e2f7aeddf43b367c5c71c (diff)
downloadfocaccia-qemu-0dacea92d26c31d453c58de2e99c178fee554166.tar.gz
focaccia-qemu-0dacea92d26c31d453c58de2e99c178fee554166.zip
net: Transmit zero UDP checksum as 0xFFFF
The checksum algorithm used by IPv4, TCP and UDP allows a zero value
to be represented by either 0x0000 and 0xFFFF. But per RFC 768, a zero
UDP checksum must be transmitted as 0xFFFF because 0x0000 is a special
value meaning no checksum.

Substitute 0xFFFF whenever a checksum is computed as zero when
modifying a UDP datagram header. Doing this on IPv4 and TCP checksums
is unnecessary but legal. Add a wrapper for net_checksum_finish() that
makes the substitution.

(We can't just change net_checksum_finish(), as that function is also
used by receivers to verify checksums, and in that case the expected
value is always 0x0000.)

Signed-off-by: Ed Swierk <eswierk@skyportsystems.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'hw/net/e1000.c')
-rw-r--r--hw/net/e1000.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index c0abee4f7e..05a00cba31 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -503,7 +503,7 @@ putsum(uint8_t *data, uint32_t n, uint32_t sloc, uint32_t css, uint32_t cse)
         n = cse + 1;
     if (sloc < n-1) {
         sum = net_checksum_add(n-css, data+css);
-        stw_be_p(data + sloc, net_checksum_finish(sum));
+        stw_be_p(data + sloc, net_checksum_finish_nozero(sum));
     }
 }