buglwIP - A Lightweight TCP/IP stack - Bugs: bug #50498, tcp: do not keep sending SYNs when...

 
 

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

bug #50498: tcp: do not keep sending SYNs when getting ACKs

Submitter:  David van Moolenbroek <dcvmoole>
Submitted:  Wed 08 Mar 2017 07:56:14 PM UTC
   
 
Category:  TCP Severity:  3 - Normal
Item Group:  Faulty Behaviour Status:  Fixed
Privacy:  Public Assigned to:  goldsimon
Open/Closed:  Closed Planned Release:  None
lwIP version:  git head

Thu 09 Mar 2017 12:50:03 PM UTC, comment #4: 
Simon Goldschmidt <goldsimon>
Group administrator
Thu 09 Mar 2017 12:35:15 PM UTC, comment #3: 

Ah, you beat me to it, and with a better fix too hehe. Thanks :)

David van Moolenbroek <dcvmoole>
Thu 09 Mar 2017 12:33:22 PM UTC, comment #2: 

Good point about the '==' check in tcp_slowtmr(). Attached is a new patch that makes those checks a bit more robust.

However, in my case, that does not even matter: tcp_slowtmr() is never even reached. I'm not sure how this works in other setups, but in my case, the main loop of my service feeds back pending loopback packets into lwIP as long as there are any, before making a kernel call to receive IPC messages. The lwIP timer system is driven by an 'alarm' IPC message. Since there are constantly more loopback packets to feed back into lwIP in this scenario, the main loop of my service never even gets to the point of receiving IPC messages, including the alarm message. Instead, tcp_rexmit_rto() keeps increasing pcb->nrtx forever, with (previously) nothing to check if any limit has been reached.

In my service I've now put a limit on the number of packets that can be fed back into lwIP without calling the main loop, but even that doesn't stop the service from consuming almost all CPU time for a few seconds.

(file #39954)

David van Moolenbroek <dcvmoole>
Thu 09 Mar 2017 12:10:16 PM UTC, comment #1: 

I'm OK with the change, but I don't see how the loop could be endless given that 'tcp_rexmit_rto()' increases 'pcb->nrtx' and 'tcp_slowtmr()' checks for TCP_SYNMAXRTX.

Wait, I see:
1) 'pcb->nrtx' can overflow if 'tcp_rexmit_rto()' is called too often and
2) 'tcp_slowtmr()' checks for '==' instead of '>='

We might want to fix these anyway since 'pcb->nrtx' is used as an offset into the 'tcp_backoff' array...

Simon Goldschmidt <goldsimon>
Group administrator
Wed 08 Mar 2017 07:56:14 PM UTC, original submission:  

An amendment to git-2e26fc9 ("tcp: Avoid 3-second delay for a half-open connection")

===

If a locally generated TCP SYN packet is replied to with an ACK packet, lwIP immediately sends a RST packet followed by resending the SYN packet.  This is expected, but on loopback interfaces the resent SYN packet may immediately get another ACK reply, typically when the other endpoint is in TIME_WAIT state (which ignores the RSTs).  The result is an endless loop of SYN, ACK, RST packets.

This patch applies the normal SYN retransmission limit in this scenario, such that the endless loop is limited to a brief storm.

David van Moolenbroek <dcvmoole>

 

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

 

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 dcvmoole (Submitted the item)
  •  

    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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-03-09 goldsimon StatusNone Fixed
        Assigned toNone goldsimon
        Open/ClosedOpen Closed
    2017-03-09 dcvmoole Attached File- Added 0001-tcp-do-not-keep-sending-SYNs-when-getting-ACKs.patch, #39954
    2017-03-08 dcvmoole Attached File- Added 0001-tcp-do-not-keep-sending-SYNs-when-getting-ACKs.patch, #39950

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code