buglwIP - A Lightweight TCP/IP stack - Bugs: bug #29067, TCP PCB stays in stated CLOSED...

 
 

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

bug #29067: TCP PCB stays in stated CLOSED when close() initiated by LwIP

Submitted by:  Stephane Lesage <slesage>
Submitted on:  Thu 04 Mar 2010 08:57:51 AM UTC  
 
Category: TCPSeverity: 3 - Normal
Item Group: Faulty BehaviourStatus: Invalid
Privacy: PublicAssigned to: None
Open/Closed: ClosedPlanned Release: None
lwIP version: CVS Head

Thu 04 Mar 2010 03:52:10 PM UTC, comment #3:

This is TCP... :-)

> Well, I suppose I would need SO_REUSEADDR or SO_REUSEPORT for
> this. But the SO_REUSE option results in a #error. I thought it
> has been implemented now.


Not completely, at least on the socket layer. I guess it will be included in 1.4.0, though.

Simon Goldschmidt <goldsimon>
Project Administrator
Thu 04 Mar 2010 10:40:04 AM UTC, comment #2:

Well, I checked the TCP state machine, and LwIP behaves correctly. The peer initiating the FIN finally goes in TIME_WAIT state.
I can't understand why TCP isn't symetrical...

Well, I suppose I would need SO_REUSEADDR or SO_REUSEPORT for this. But the SO_REUSE option results in a #error. I thought it has been implemented now.

It is really necessary to set this option ?
We can listen on one port and each new connection will create a new pcb on this port. Why can't we listen again ?

Stephane Lesage <slesage>
Thu 04 Mar 2010 09:29:47 AM UTC, comment #1:

oups! Forget the tcp_close: closing in State: CLOSED.
This is my application closing the socket which could not be bound.
(please someone change the bug title...)

The problem is:
tcp_close: closing in State: TIME_WAIT

in tcp_input():
/* If a FIN segment was received, we call the callback
function with a NULL buffer to indicate EOF. */
if (recv_flags & TF_GOT_FIN) {
/* correct rcv_wnd as the application won't call tcp_recved()
for the FIN's seqno */
if (pcb->rcv_wnd != TCP_WND) {
pcb->rcv_wnd++;
}
TCP_EVENT_RECV(pcb, NULL, ERR_OK, err);
if (err == ERR_ABRT) {
goto aborted;
}
}

At this time the callback is tcp_recv_null() which finally calls tcp_close_shutdown():

default:
/* Has already been closed, do nothing. */
err = ERR_OK;
pcb = NULL;
break;
}

Shouldn't we kill the PCB at this time when receiving a FIN ?

Stephane Lesage <slesage>
Thu 04 Mar 2010 08:57:51 AM UTC, original submission:

This was first posted on [lwip-users] close(), TIME_WAIT and bind().

I have checked with Wireshark that the connection is closed properly with the peer (FIN, FIN+ACK, ACK)

I enabled TCP_DEBUG to see what happens:

1. When the peer closes the connection, there is no problem.

tcp_bind: bind to port 12302
TCP connection request 21413 -> 12302.
TCP connection established 21413 -> 12302.
tcp_close: closing in State: LISTEN
tcp_slowtmr: processing active pcb
tcp_slowtmr: polling application
tcp_slowtmr: processing active pcb
tcp_close: closing in State: CLOSE_WAIT
TCP connection closed: LAST_ACK 21413 -> 12302.
tcp_pcb_purge
tcp_bind: bind to port 12302

2. Now (CVS head), whenever my device closes the connection, I cannot bind() for exactly 2 minutes (I thought the last connection stayed in TIME_WAIT...)

tcp_bind: bind to port 12302
TCP connection request 21400 -> 12302.
TCP connection established 21400 -> 12302.
tcp_close: closing in State: LISTEN
tcp_recved: recveived 1 bytes, wnd 8192 (0).
tcp_fasttmr: delayed ACK
tcp_slowtmr: processing active pcb
tcp_recved: recveived 5 bytes, wnd 8192 (0).
tcp_close: closing in State: ESTABLISHED
TCP connection closed: FIN_WAIT_2 21400 -> 12302.
tcp_pcb_purge
tcp_close: closing in State: TIME_WAIT
tcp_close: closing in State: CLOSED
tcp_close: closing in State: CLOSED
tcp_close: closing in State: CLOSED
tcp_close: closing in State: CLOSED
tcp_close: closing in State: CLOSED
tcp_slowtmr: no active pcbs
tcp_close: closing in State: CLOSED
tcp_close: closing in State: CLOSED
tcp_close: closing in State: CLOSED
tcp_close: closing in State: CLOSED
tcp_close: closing in State: CLOSED
tcp_slowtmr: no active pcbs
tcp_close: closing in State: CLOSED
tcp_close: closing in State: CLOSED
tcp_close: closing in State: CLOSED
tcp_close: closing in State: CLOSED
tcp_close: closing in State: CLOSED
tcp_slowtmr: no active pcbs
tcp_close: closing in State: CLOSED
tcp_close: closing in State: CLOSED
tcp_close: closing in State: CLOSED
tcp_close: closing in State: CLOSED
tcp_close: closing in State: CLOSED
tcp_slowtmr: no active pcbs
tcp_close: closing in State: CLOSED
tcp_close: closing in State: CLOSED
tcp_close: closing in State: CLOSED
tcp_close: closing in State: CLOSED
tcp_close: closing in State: CLOSED
tcp_slowtmr: no active pcbs
tcp_close: closing in State: CLOSED
tcp_close: closing in State: CLOSED
tcp_close: closing in State: CLOSED
tcp_close: closing in State: CLOSED
tcp_close: closing in State: CLOSED
tcp_slowtmr: no active pcbs
tcp_close: closing in State: CLOSED
tcp_close: closing in State: CLOSED
tcp_close: closing in State: CLOSED
tcp_close: closing in State: CLOSED

[...]

Stephane Lesage <slesage>

 

No files currently attached

 

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 slesage (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 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 04 Mar 2010 03:52:10 PM UTCgoldsimonStatusNone=>Invalid
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1