Subject: kern/17616: accept on a tcp socket loses options
To: None <>
From: None <>
List: netbsd-bugs
Date: 07/16/2002 21:12:16
>Number:         17616
>Category:       kern
>Synopsis:       accept on a tcp socket loses options
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jul 16 14:13:01 PDT 2002
>Originator:     Bill Studenmund
>Release:        NetBSD 1.6, though it has been around a while
System: NetBSD mail 1.5 NetBSD 1.5 (HOMEWORLD) #0: Sat Feb 10 08:13:16 EET 2001 i386

	When a listening tcp socket gains a new connection (which will be
retrieved by accept(2)), the tcp options of the listening socket
are not copied over. Quoting man 2 accept, "The accept() argument
extracts the first connection request on the queue of pending
connections, creates a new socket with the same properties of s
[the accepted-on socket] and allocates a new file descriptor for
the socket." tcp options certainly are properties of the accepted-
on socket (though admittedly not socket-level ones).
	Other operating systems, such as Linux, do copy over the
tcp options. While I don't think we should do something just because
someone else did, in this case, I think copying tcp options is the
right thing to do.


	Create a tcp socket & bind it to an address. Set tcp options
on it, such as TCP_NODELAY. accept() a new connection. You now have
a socket without the option(s) you set above.


	Not sure. But when we transition a tcp connection from
TCPS_SYN_RECEIVED to ESTABLISHED, we should copy the tcp options
of the listen-on socket. One possible way to do this is to save
the tcp options along with the ip options when we add an entry to
the syn cache.