qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/3] net: checksum: Skip fragmented IP packets
@ 2020-12-11  9:35 Bin Meng
  2020-12-11  9:35 ` [PATCH v2 2/3] net: checksum: Add IP header checksum calculation Bin Meng
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Bin Meng @ 2020-12-11  9:35 UTC (permalink / raw)
  To: qemu-devel; +Cc: Jason Wang, Bin Meng, Markus Carlstedt

From: Markus Carlstedt <markus.carlstedt@windriver.com>

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>
---

(no changes since v1)

 net/checksum.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/checksum.c b/net/checksum.c
index aaa4000..5cb8b2c 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 */
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-12-17  7:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-11  9:35 [PATCH v2 1/3] net: checksum: Skip fragmented IP packets Bin Meng
2020-12-11  9:35 ` [PATCH v2 2/3] net: checksum: Add IP header checksum calculation Bin Meng
2020-12-11  9:35 ` [PATCH v2 3/3] net: checksum: Introduce fine control over checksum type Bin Meng
2020-12-11 12:19   ` Cédric Le Goater
2020-12-17  5:41 ` [PATCH v2 1/3] net: checksum: Skip fragmented IP packets Bin Meng
2020-12-17  7:25   ` Jason Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).