[ipxe-devel] About recent TCP stack improvements

Michael Brown mbrown at fensystems.co.uk
Thu Jul 22 11:27:58 UTC 2010


(Redirecting to ipxe-devel)

On Thursday 22 Jul 2010 11:09:23 Michael Brown wrote:
> [tcp] Receive and Close flow adjustment
> 
> This is difficult to apply following the changes to support out-of-order
> packets, and I'm not sure how valuable it is.  Since commit 9ff8229 ("[tcp]
> Update received sequence number before delivering received data"), which
> fixes a problem that you identified (thank you!), I think that the TCP
> state is consistent at the time the data is delivered to the upper layer,
> so any actions it might take are safe.

Ignore that; I've just worked out that this patch makes perfect sense *if* we 
also distinguish between passive and active close, and I see how it can be 
implemented cleanly on top of the recent out-of-order changes.

tcp_rx_data() should add the I/O buffer to a list rather than delivering it via 
xfer_deliver_iob().  tcp_rx_fin() should not call tcp_close().  
tcp_process_rx_queue() should be adjusted to do something like:

  struct list_head received = LIST_HEAD_INIT ( received );
  ...
  while ( ! list_empty ( &tcp->rx_queue ) ) {
     ...
     tcp_rx_data ( tcp, seq, iob_disown ( iobuf ), &received );
     ...
  }

  list_for_each_entry_safe ( iobuf, tmp, &received, list ) {
    // deliver iobuf via xfer_deliver_iob()
  }

  if ( tcp->state & TCP_STATE_RCVD ( TCP_FIN ) )
    tcp_close ( tcp, 0 );

I think that would handle everything sensibly, and would mean that we could 
properly handle passive close since, in the case of a received data+FIN packet 
that will also cause our higher layer protocol (e.g. http.c) to close the 
connection, tcp_rx_fin() would see the FIN before http.c called xfer_close().

Does this seem correct to you?  If so, would you like to put together a patch?

Michael



More information about the ipxe-devel mailing list