From: Bin Meng <bmeng.cn@gmail.com>
To: qemu-devel@nongnu.org
Cc: Jason Wang <jasowang@redhat.com>,
Bin Meng <bin.meng@windriver.com>,
Markus Carlstedt <markus.carlstedt@windriver.com>
Subject: [PATCH 1/3] net: checksum: Skip fragmented IP packets
Date: Sun, 6 Dec 2020 10:14:05 +0800 [thread overview]
Message-ID: <1607220847-24096-1-git-send-email-bmeng.cn@gmail.com> (raw)
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>
---
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
next reply other threads:[~2020-12-06 2:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-06 2:14 Bin Meng [this message]
2020-12-06 2:14 ` [PATCH 2/3] net: checksum: Add IP header checksum calculation Bin Meng
2020-12-06 2:14 ` [PATCH 3/3] net: checksum: Introduce fine control over checksum type Bin Meng
2020-12-06 11:50 ` Philippe Mathieu-Daudé
2020-12-06 12:44 ` Bin Meng
2020-12-09 8:33 ` Cédric Le Goater
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1607220847-24096-1-git-send-email-bmeng.cn@gmail.com \
--to=bmeng.cn@gmail.com \
--cc=bin.meng@windriver.com \
--cc=jasowang@redhat.com \
--cc=markus.carlstedt@windriver.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).