summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorMarkus Carlstedt2020-12-11 10:35:10 +0100
committerJason Wang2021-01-25 10:04:56 +0100
commit0dcf0c0aeefd2bc1023c9fe7ab0f1b6bc993c360 (patch)
tree66afc6eb0f2fea9fd9c1404a026295b36a90af93 /net
parentnet: Fix handling of id in netdev_add and netdev_del (diff)
downloadqemu-0dcf0c0aeefd2bc1023c9fe7ab0f1b6bc993c360.tar.gz
qemu-0dcf0c0aeefd2bc1023c9fe7ab0f1b6bc993c360.tar.xz
qemu-0dcf0c0aeefd2bc1023c9fe7ab0f1b6bc993c360.zip
net: checksum: Skip fragmented IP packets
To calculate the TCP/UDP checksum we need the whole datagram. Unless the hardware has some logic to collect all fragments before sending the whole datagram first, it can only be done by the network stack, which is normally the case for the NICs we have seen so far. Skip these fragmented IP packets to avoid checksum corruption. Signed-off-by: Markus Carlstedt <markus.carlstedt@windriver.com> Signed-off-by: Bin Meng <bin.meng@windriver.com> Signed-off-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'net')
-rw-r--r--net/checksum.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/net/checksum.c b/net/checksum.c
index aaa4000238..5cb8b2c368 100644
--- a/net/checksum.c
+++ b/net/checksum.c
@@ -106,6 +106,10 @@ void net_checksum_calculate(uint8_t *data, int length)
return; /* not IPv4 */
}
+ if (IP4_IS_FRAGMENT(ip)) {
+ return; /* a fragmented IP packet */
+ }
+
ip_len = lduw_be_p(&ip->ip_len);
/* Last, check that we have enough data for the all IP frame */