buglwIP - A Lightweight TCP/IP stack - Bugs: bug #57452, CHECKSUM_ON_COPY leads to random...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #57452: CHECKSUM_ON_COPY leads to random bit error in TCP checksum

Submitter:  Victor Brzeski <vbrzeski>
Submitted:  Thu 19 Dec 2019 09:42:25 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open Planned Release:  None
lwIP version:  git head

Fri 27 Mar 2020 01:39:08 AM UTC, comment #3: 

Hello Simon,

I spent some time this week looking at this issue.
 - Very likely not an issue with the memcpy/csum routines
 - Likely not an issue my netif (I did make some improvements)
 - UDP checksum on copy works fine
 - Turning off all non-lwip macros doesn't aid the problem
 - Using lwIP's checksum on copy algorithm doesn't aid the problem

I may have come full circle with my work on this, but it doesn't seem to be present with UDP from what I can tell so far.

I will try and dedicate a bit more time in the next few months to work on this further, but I need to ignore the feature for now.


Victor Brzeski <vbrzeski>
Sat 11 Jan 2020 12:34:23 AM UTC, comment #2: 


comment #1:

> Have you tried TCP_CHECKSUM_ON_COPY_SANITY_CHECK? That should run TCP_CHECKSUM_ON_COPY and traditional checksum in parallel and report errors at the same time. If you put a breakpoint on the error-reporting lines or insert code to dump state there, you might be able to debug what's wrong.


Yes I have,

I have even went as far as to write a sanity check for each call to my own LWIP_CHKSUM (compared to algorithm 2), and LWIP_CHKSUM_COPY (compared to algorithm 2, and memcmp).

I have done breakpoints, but the issue seems random. I did have a bug in my netif driver which proved unrelated. There just seems to be a random bit error, where the normal checksum routine doesn't have it, nor my own LWIP_CHKSUM.

When using TCP_CHECKSUM_ON_COPY_SANITY_CHECK the checksum that was incorrect is corrected in the packet itself, and not reported via Wireshark, but only via the DEBUGF utility.

I have attached a capture, as well as a log. To find an example of the error, ctrl+F for "tcp_output_segment: calculated checksum is FF56 instead of FF55"

Every single one of the checksum errors is off by 1. I will dedicate more time to debugging in a week or two.

Victor Brzeski <vbrzeski>
Fri 10 Jan 2020 09:22:01 PM UTC, comment #1: 

Have you tried TCP_CHECKSUM_ON_COPY_SANITY_CHECK? That should run TCP_CHECKSUM_ON_COPY and traditional checksum in parallel and report errors at the same time. If you put a breakpoint on the error-reporting lines or insert code to dump state there, you might be able to debug what's wrong.

Simon Goldschmidt <goldsimon>
Group administrator
Thu 19 Dec 2019 09:42:25 PM UTC, original submission:  

Hello,

I am having problems after developing a LWIP_CHKSUM_COPY() assembly routine. Implementations of a superior MEMCPY to the standard library, as well as a faster LWIP_CHKSUM by utilizing ADDC instructions were both successful. Unfortunately this improvement has caused me much frustration.

Naturally I assumed my assembly code was erroneous so I spent time I disabled all of these macros and found the error to still exist. Considering the bug was consistent (checksum off by 1 in MSB of checksum) I attempted to squish it. Unfortunately after a few days I was unsuccessful.

I have done:
 - Sanity checks of my MEMCPY(), LWIP_CHKSUM_COPY() and LWIP_CHKSUM() - data copied correctly and checksum correct
 - Turned off these features
 - Turned off my asm byteswapping functions
 - Turned off compiler optimizations (only constant folding)

Chasing the bug it seems random, and I cannot define the behavior that reproduces it, however, it is very common. I have attached logs of debug messages as well as a netcap with the sanity check override disabled (commenting line 1595 in tcp_out.c).

Target: Infineon XC22xxM with ASIX Ax88796b netif

Thanks & regards,
-Victor

Victor Brzeski <vbrzeski>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #48092:  csum_copy_capture.pcapng added by vbrzeski (69KiB - application/octet-stream - examples of checksum issues)
file #48093:  teraterm.log added by vbrzeski (597KiB - application/octet-stream - examples of checksum issues)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by vbrzeski (Submitted the item)
  • -email is unavailable- added by vbrzeski (work)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-12-19 vbrzeski Attached File- Added csum_copy_capture.pcapng, #48092
        Attached File- Added teraterm.log, #48093
        Carbon-Copy- Added -email is unavailable-

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code