qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: qemu-devel@nongnu.org, peter.maydell@linaro.org
Cc: Jason Wang <jasowang@redhat.com>,
	Bin Meng <bin.meng@windriver.com>,
	Markus Carlstedt <markus.carlstedt@windriver.com>
Subject: [RESEND PULL 2/4] net: checksum: Skip fragmented IP packets
Date: Mon, 25 Jan 2021 20:23:05 +0800	[thread overview]
Message-ID: <1611577387-4296-3-git-send-email-jasowang@redhat.com> (raw)
In-Reply-To: <1611577387-4296-1-git-send-email-jasowang@redhat.com>

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>
Signed-off-by: Jason Wang <jasowang@redhat.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



  parent reply	other threads:[~2021-01-25 12:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-25 12:23 [RESEND PULL 0/4] Net patches Jason Wang
2021-01-25 12:23 ` [RESEND PULL 1/4] net: Fix handling of id in netdev_add and netdev_del Jason Wang
2021-01-25 12:23 ` Jason Wang [this message]
2021-01-25 12:23 ` [RESEND PULL 3/4] net: checksum: Add IP header checksum calculation Jason Wang
2021-01-25 12:23 ` [RESEND PULL 4/4] net: checksum: Introduce fine control over checksum type Jason Wang
2021-01-25 18:17 ` [RESEND PULL 0/4] Net patches Peter Maydell

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=1611577387-4296-3-git-send-email-jasowang@redhat.com \
    --to=jasowang@redhat.com \
    --cc=bin.meng@windriver.com \
    --cc=markus.carlstedt@windriver.com \
    --cc=peter.maydell@linaro.org \
    --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).