buglwIP - A Lightweight TCP/IP stack - Bugs: bug #19953, Bug in TCP State Machine - SYN_RCVD

 
 

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

bug #19953: Bug in TCP State Machine - SYN_RCVD

Submitted by:  Tom Hennen <thennen>
Submitted on:  Thu 24 May 2007 02:40:55 PM UTC  
 
Category: TCPSeverity: 4 - Important
Item Group: Faulty BehaviourStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: ClosedPlanned Release: None
lwIP version: None

(Jump to the original submission Jump to the original submission)

Thu 16 Aug 2007 03:58:00 PM UTC, comment #7:

Thanks - have committed and closing this as fixed.

Kieran Mansley <kieranm>
Project Administrator
Thu 09 Aug 2007 06:33:47 PM UTC, comment #6:

I just tested the patch (on my modified 1.1.1 stack) and it looks like it does the job just fine. Normal connection setup seems to work properly also.

Tom Hennen <thennen>
Fri 27 Jul 2007 11:11:21 AM UTC, comment #5:

I'll be able to test it, but probably not until the end of next week.

I can tell you that I came across it when I had a test connecting and disconnecting rapidly in a tight loop.

Tom Hennen <thennen>
Fri 27 Jul 2007 07:38:58 AM UTC, comment #4:

I was hoping the original bug reporter might be able to reproduce and test it. If not, testing to make sure that it doesn't break the normal connection setup would be OK on its own I suppose. At least then we won't have made things worse.

Kieran Mansley <kieranm>
Project Administrator
Thu 26 Jul 2007 08:15:05 PM UTC, comment #3:

Patch seems ok, but how can we test it? Except writing a very low level unit test, it doesn't seem to be easy...

Frédéric Bernon <fbernon>
Project Member
Thu 26 Jul 2007 11:53:45 AM UTC, comment #2:

Attached is a patch to fix this. I would be grateful if someone else could review it. I'd also be grateful for any testing as I'm not in a position to check that it has actually fixed the original problem. It does however do what the suggested fix says it should!

(file #13477)

Kieran Mansley <kieranm>
Project Administrator
Fri 15 Jun 2007 09:31:31 AM UTC, comment #1:

I agree with the suggested fix in the last paragraph. i.e. check the FIN flag when moving form SYN_RCVD to ESTABLISHED, and if necessary carry straight on to CLOSE_WAIT.

Kieran Mansley <kieranm>
Project Administrator
Thu 24 May 2007 02:40:55 PM UTC, original submission:

It is possible for a client to send a FIN+ACK to a server in the SYN_RCVD state. This will currently cause the server to get stuck in FIN_WAIT_2 (until it times out), when it should really transition to CLOSE_WAIT.

This can happen if a client closes a connection immediately after
receiving the SYN+ACK in the SYN_SENT state. When this happens the client may queue an 'ACK' for the 'SYN+ACK', but the ACK is delayed (waiting for some data to go with it). Then, before the ACK is sent, the client calls 'close'. This causes the 'FIN' flag to be set and the packet to be sent to the server. Thus the server, sitting in the 'SYN_RCVD' state will receive a packet with 'FIN+ACK' set.

As of lwIP 1.1.1 this will cause the state to be transitioned to
ESTABLISHED, the 'connected' callback will be called and then when tcp_process calls tcp_receive. tcp_receive notices the 'FIN' flag and calls the server's tcp_recv callback with a NULL pbuf. The server, then calls 'tcp_close', which as the state is ESTABLISHED will cause the state to transition to FIN_WAIT_1 when in fact it should transition to CLOSE_WAIT. Since the client is also in FIN_WAIT_1 another 'FIN' will not be sent and the client will transition to TIME_WAIT, thus leaving server stuck in FIN_WAIT_2.

I figure the fix to this involves checking for the 'FIN' flag in the SYN_RCVD state, after notifying the server via the 'connected' callback, transitioning to the ESTABLISHED state and then transitioning to the CLOSE_WAIT state.

Tom Hennen <thennen>

 

Attached Files
file #13477:  bug19953.patch added by kieranm (1009B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by fbernon (Posted a comment)
  • -unavailable- added by kieranm (Posted a comment)
  • -unavailable- added by thennen (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 7 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 16 Aug 2007 03:58:00 PM UTCkieranmStatusReady For Test=>Fixed
      Open/ClosedOpen=>Closed
    Thu 26 Jul 2007 11:54:09 AM UTCkieranmStatusNone=>Ready For Test
    Thu 26 Jul 2007 11:53:45 AM UTCkieranmAttached File-=>Added bug19953.patch, #13477
    Fri 13 Jul 2007 11:49:08 AM UTCkieranmSeverity3 - Normal=>4 - Important
      Planned Release=>1.3.0
    Thu 24 May 2007 02:40:55 PM UTCthennenCarbon-Copy-=>Added thennen

    Back to the top


    Powered by Savane 3.1-cleanup1