]> Git Repo - qemu.git/commitdiff
net: checksum: Skip fragmented IP packets
authorMarkus Carlstedt <[email protected]>
Fri, 11 Dec 2020 09:35:10 +0000 (17:35 +0800)
committerJason Wang <[email protected]>
Mon, 25 Jan 2021 09:04:56 +0000 (17:04 +0800)
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 <[email protected]>
Signed-off-by: Bin Meng <[email protected]>
Signed-off-by: Jason Wang <[email protected]>
net/checksum.c

index aaa4000238ac1cf1d3361009a2c83ec65a144f48..5cb8b2c36896d3daffd689673497c896abe12db2 100644 (file)
@@ -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 */
This page took 0.025094 seconds and 4 git commands to generate.