[bug #54506] LWIP_CHECKSUM_ON_COPY causes wrong checksum (0xFFFF)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[bug #54506] LWIP_CHECKSUM_ON_COPY causes wrong checksum (0xFFFF)

Simon Goldschmidt
URL:
  <http://savannah.nongnu.org/bugs/?54506>

                 Summary: LWIP_CHECKSUM_ON_COPY causes wrong checksum (0xFFFF)
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: basti
            Submitted on: Mon 13 Aug 2018 10:55:16 AM UTC
                Category: TCP
                Severity: 3 - Normal
              Item Group: Faulty Behaviour
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None
            lwIP version: git head

    _______________________________________________________

Details:

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).



    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Mon 13 Aug 2018 10:55:16 AM UTC  Name: patch1.diff  Size: 529B   By:
basti

<http://savannah.nongnu.org/bugs/download.php?file_id=44770>
-------------------------------------------------------
Date: Mon 13 Aug 2018 10:55:16 AM UTC  Name: patch2.diff  Size: 536B   By:
basti

<http://savannah.nongnu.org/bugs/download.php?file_id=44771>
-------------------------------------------------------
Date: Mon 13 Aug 2018 10:55:16 AM UTC  Name: patch3.diff  Size: 535B   By:
basti

<http://savannah.nongnu.org/bugs/download.php?file_id=44772>

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?54506>

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


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[bug #54506] LWIP_CHECKSUM_ON_COPY causes wrong checksum (0xFFFF)

Simon Goldschmidt
Follow-up Comment #1, bug #54506 (project lwip):

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)
    _______________________________________________________

Additional Item Attachment:

File name: patch3.diff                    Size:0 KB


    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?54506>

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


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[bug #54506] LWIP_CHECKSUM_ON_COPY causes wrong checksum (0xFFFF)

Simon Goldschmidt
Update of bug #54506 (project lwip):

                  Status:                    None => Fixed                  
             Assigned to:                    None => goldsimon              
             Open/Closed:                    Open => Closed                
         Planned Release:                    None => 2.1.0                  

    _______________________________________________________

Follow-up Comment #2:

Fixed as suggested in comment #1.

Thanks for reporting!

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?54506>

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


_______________________________________________
lwip-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-devel