lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [task #16111] Set checksum to zero optimized-out in case of


From: Zakaria Abu Al-Ailah
Subject: [lwip-devel] [task #16111] Set checksum to zero optimized-out in case of using a HW Checksum Block
Date: Fri, 21 Jan 2022 10:02:40 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36

URL:
  <https://savannah.nongnu.org/task/?16111>

                 Summary: Set checksum to zero optimized-out in case of using
a HW Checksum Block
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: zakaria
            Submitted on: Fri 21 Jan 2022 03:02:38 PM UTC
                Category: IPv4
         Should Start On: Fri 21 Jan 2022 12:00:00 AM UTC
   Should be Finished on: Mon 31 Jan 2022 12:00:00 AM UTC
                Priority: 9 - Immediate
                  Status: None
                 Privacy: Public
        Percent Complete: 0%
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None
                  Effort: 0.00

    _______________________________________________________

Details:

Hi,

There is an issue in the following file:
  - File: lwip/src/core/ipv4/icmp.c
  - Line: 236 and 239

In case `LWIP_CHKSUM` is defined by the user in order to be computed by a HW
block, the compiler is optimized-out the instruction `IPH_CHKSUM_SET(iphdr,
0);` which is in `icmp.c` file - line 236 (permalink:
https://github.com/lwip-tcpip/lwip/blob/34e435c78611fbf21c49c5ddb6c395a097e24cc7/src/core/ipv4/icmp.c#L236).

The problem is the existence of the next instruction `IPH_CHKSUM_SET(iphdr,
inet_chksum(iphdr, hlen));` (line 239).

This means the same field `iphdr->_chksum` is assigned twice as follows:
iphdr->_chksum = 0; // line 236
iphdr->_chksum = <checksum computed by HW>;  // line 239

Since the checksum is computed by HW, the compiler is not aware that the field
`iphdr->_chksum` will be taken into account in the HW Block. Therefore the
compiler is optimized-out the first assignment.

One solution for this problem is adding `volatile` to the field `_chksum`
which is in `struct ip_hdr`.


Regards,
Zakaria Abu Al-Ailah




    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/task/?16111>

_______________________________________________
  Message sent via Savannah
  https://savannah.nongnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]