diff mbox series

[v2,1/3] net: checksum: Skip fragmented IP packets

Message ID 1607679312-51325-1-git-send-email-bmeng.cn@gmail.com
State New
Headers show
Series [v2,1/3] net: checksum: Skip fragmented IP packets | expand

Commit Message

Bin Meng Dec. 11, 2020, 9:35 a.m. UTC
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(+)

Comments

Bin Meng Dec. 17, 2020, 5:41 a.m. UTC | #1
Hi Jason,

On Fri, Dec 11, 2020 at 5:35 PM Bin Meng <bmeng.cn@gmail.com> wrote:
>
> 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(+)
>

Ping?

Regards,
Bin
Jason Wang Dec. 17, 2020, 7:25 a.m. UTC | #2
On 2020/12/17 下午1:41, Bin Meng wrote:
> Hi Jason,
>
> On Fri, Dec 11, 2020 at 5:35 PM Bin Meng <bmeng.cn@gmail.com> wrote:
>> 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(+)
>>
> Ping?
>
> Regards,
> Bin


Queued.

Thanks


>
diff mbox series

Patch

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