buglwIP - A Lightweight TCP/IP stack - Bugs: bug #54506, LWIP_CHECKSUM_ON_COPY causes wrong...

 
 

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

bug #54506: LWIP_CHECKSUM_ON_COPY causes wrong checksum (0xFFFF)

Submitter:  Sebastian Maier <basti>
Submitted:  Mon 13 Aug 2018 10:55:16 AM UTC
Votes: 100
 
Category:  TCP Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  Fixed
Privacy:  Public Assigned to:  goldsimon
Open/Closed:  Closed Planned Release:  2.1.0
lwIP version:  git head

Wed 12 Sep 2018 08:33:27 PM UTC, comment #2: 

Fixed as suggested in comment #1.

Thanks for reporting!

Simon Goldschmidt <goldsimon>
Group administrator
Sat 08 Sep 2018 08:37:12 PM UTC, comment #1: 

I think the correct version of the fix is to invert back 'acc' (as it is returned inverted by ip_chksum_pseudo_partial()), then do the calculation and fold and then inverting it again. As that is the same what's already done, it should be portable.

See attached patch.

(file #44958)

Simon Goldschmidt <goldsimon>
Group administrator
Mon 13 Aug 2018 10:55:16 AM UTC, original submission:  

I am currently using lwIP (HEAD) on x86-64 with a custom OS and an Intel e1000(e) ethernet adapter to transfer data via TCP.
For debugging purposes I implemented an echoserver (sending and receiving about 2 GiB of random data @ ~ 20 MiB/s) and used the following config options:


  #define LWIP_NETIF_TX_SINGLE_PBUF  1
  #define LWIP_CHECKSUM_ON_COPY      1


After some time Wireshark shows TCP packages (sent by lwIP) that have an invalid TCP checksum of 0xFFFF.
By enabling


  #define TCP_CHECKSUM_ON_COPY_SANITY_CHECK 1


the assertion in line


  tcp_out.c:1592


is triggered whenever the precalculated checksum of the segment (seg->chksum) is exactly the same as the checksum of the header (acc). In this case apperently the overall checksum (seg->tcphdr->chksum) should be 0x0 (but is 0xFFFF instead).

Either of the patches attached worked for me. Although I am not entirely sure, whether these patches will work for all weird architectures out there.

If required I can also provide a Wireshark capture of the problem or a patch that prints more debugging information (during the checksum-on-copy calculation).

Sebastian Maier <basti>

 

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

Attached Files
file #44958:  patch3.diff added by goldsimon (710B - application/octet-stream)
file #44770:  patch1.diff added by basti (529B - text/x-patch)
file #44771:  patch2.diff added by basti (536B - text/x-patch)
file #44772:  patch3.diff added by basti (535B - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by goldsimon (Updated the item)
  • -email is unavailable- added by flow
  • -email is unavailable- added by basti (Submitted the item)
  •  

    There are 100 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 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-09-12 goldsimon StatusNone Fixed
        Assigned toNone goldsimon
        Open/ClosedOpen Closed
        Planned ReleaseNone 2.1.0
    2018-09-08 goldsimon Attached File- Added patch3.diff, #44958
    2018-08-13 flow Carbon-Copy- Added flow
    2018-08-13 basti Attached File- Added patch1.diff, #44770
        Attached File- Added patch2.diff, #44771
        Attached File- Added patch3.diff, #44772

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code