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

Submitted by:  David van Moolenbroek <dcvmoole>
Submitted on:  Wed 08 Mar 2017 07:56:14 PM UTC  
 
Category: TCPSeverity: 3 - Normal
Item Group: Faulty BehaviourStatus: Fixed
Privacy: PublicAssigned to: Simon Goldschmidt <goldsimon>
Open/Closed: ClosedPlanned Release: None
lwIP version: git head

Thu 09 Mar 2017 12:50:03 PM UTC, comment #4:

Pushed in http://git.savannah.gnu.org/cgit/lwip.git/commit/?id=5827c168c28b43d98ffbf91f45c38a054e848eda
Additional fixes in http://git.savannah.gnu.org/cgit/lwip.git/commit/?id=7ffe5bfb3c4bb21a09046e254a2b6a12e3450ada

Just saw your comment here :-)

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
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>
Project AdministratorIn charge of this item.
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>

 

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by goldsimon (Posted a comment)
  • -unavailable- added by dcvmoole (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 09 Mar 2017 12:50:03 PM UTCgoldsimonStatusNone=>Fixed
      Assigned toNone=>goldsimon
      Open/ClosedOpen=>Closed
    Thu 09 Mar 2017 12:33:22 PM UTCdcvmooleAttached File-=>Added 0001-tcp-do-not-keep-sending-SYNs-when-getting-ACKs.patch, #39954
    Wed 08 Mar 2017 07:56:14 PM UTCdcvmooleAttached File-=>Added 0001-tcp-do-not-keep-sending-SYNs-when-getting-ACKs.patch, #39950

    Back to the top


    Powered by Savane 3.1-cleanup1