freebsd-dev/sys/netinet
Robert Watson 623dce13c6 Update TCP for infrastructural changes to the socket/pcb refcount model,
pru_abort(), pru_detach(), and in_pcbdetach():

- Universally support and enforce the invariant that so_pcb is
  never NULL, converting dozens of unnecessary NULL checks into
  assertions, and eliminating dozens of unnecessary error handling
  cases in protocol code.

- In some cases, eliminate unnecessary pcbinfo locking, as it is no
  longer required to ensure so_pcb != NULL.  For example, the receive
  code no longer requires the pcbinfo lock, and the send code only
  requires it if building a new connection on an otherwise unconnected
  socket triggered via sendto() with an address.  This should
  significnatly reduce tcbinfo lock contention in the receive and send
  cases.

- In order to support the invariant that so_pcb != NULL, it is now
  necessary for the TCP code to not discard the tcpcb any time a
  connection is dropped, but instead leave the tcpcb until the socket
  is shutdown.  This case is handled by setting INP_DROPPED, to
  substitute for using a NULL so_pcb to indicate that the connection
  has been dropped.  This requires the inpcb lock, but not the pcbinfo
  lock.

- Unlike all other protocols in the tree, TCP may need to retain access
  to the socket after the file descriptor has been closed.  Set
  SS_PROTOREF in tcp_detach() in order to prevent the socket from being
  freed, and add a flag, INP_SOCKREF, so that the TCP code knows whether
  or not it needs to free the socket when the connection finally does
  close.  The typical case where this occurs is if close() is called on
  a TCP socket before all sent data in the send socket buffer has been
  transmitted or acknowledged.  If INP_SOCKREF is found when the
  connection is dropped, we release the inpcb, tcpcb, and socket instead
  of flagging INP_DROPPED.

- Abort and detach protocol switch methods no longer return failures,
  nor attempt to free sockets, as the socket layer does this.

- Annotate the existence of a long-standing race in the TCP timer code,
  in which timers are stopped but not drained when the socket is freed,
  as waiting for drain may lead to deadlocks, or have to occur in a
  context where waiting is not permitted.  This race has been handled
  by testing to see if the tcpcb pointer in the inpcb is NULL (and vice
  versa), which is not normally permitted, but may be true of a inpcb
  and tcpcb have been freed.  Add a counter to test how often this race
  has actually occurred, and a large comment for each instance where
  we compare potentially freed memory with NULL.  This will have to be
  fixed in the near future, but requires is to further address how to
  handle the timer shutdown shutdown issue.

- Several TCP calls no longer potentially free the passed inpcb/tcpcb,
  so no longer need to return a pointer to indicate whether the argument
  passed in is still valid.

- Un-macroize debugging and locking setup for various protocol switch
  methods for TCP, as it lead to more obscurity, and as locking becomes
  more customized to the methods, offers less benefit.

- Assert copyright on tcp_usrreq.c due to significant modifications that
  have been made as part of this work.

These changes significantly modify the memory management and connection
logic of our TCP implementation, and are (as such) High Risk Changes,
and likely to contain serious bugs.  Please report problems to the
current@ mailing list ASAP, ideally with simple test cases, and
optionally, packet traces.

MFC after:	3 months
2006-04-01 16:36:36 +00:00
..
libalias Fix prototype. 2005-11-24 14:17:35 +00:00
accf_data.c
accf_http.c
icmp6.h sync with KAME regarding NDP 2005-10-21 16:23:01 +00:00
icmp_var.h
if_atm.c Add newline to debuging printf. 2005-08-26 15:27:18 +00:00
if_atm.h
if_ether.c Further refine the bridge hack in the arp code. Only do the special arp 2006-03-07 21:40:44 +00:00
if_ether.h
igmp_var.h
igmp.c Consolidate all IP Options handling functions into ip_options.[ch] and 2005-11-18 20:12:40 +00:00
igmp.h
in_cksum.c
in_gif.c Add some initial locking to gif(4). It doesn't covers the whole driver, 2006-01-30 08:39:09 +00:00
in_gif.h
in_pcb.c Break out in_pcbdetach() into two functions: 2006-04-01 16:04:42 +00:00
in_pcb.h Break out in_pcbdetach() into two functions: 2006-04-01 16:04:42 +00:00
in_proto.c Add RFC 3378 EtherIP support. This change makes it possible to add gif 2005-12-21 21:29:45 +00:00
in_rmx.c Use monotonic 'time_uptime' instead of 'time_second' as timebase 2005-09-19 22:54:55 +00:00
in_systm.h
in_var.h Return mbuf pointer or NULL from ip_fastforward() as the mbuf pointer 2006-01-18 14:24:39 +00:00
in.c In in_control() remove the temporary in_ifaddr structure from the 2006-01-24 16:19:31 +00:00
in.h Use consistent indent character as other IPPROTO_* lines did. 2005-12-20 09:38:03 +00:00
ip6.h move RFC3542 related definitions into ip6.h. 2005-07-20 10:30:52 +00:00
ip_carp.c o Introduce carp_multicast_cleanup(), which removes and frees 2006-03-21 14:29:48 +00:00
ip_carp.h o Introduce carp_multicast_cleanup(), which removes and frees 2006-03-21 14:29:48 +00:00
ip_divert.c Update in_pcb-derived basic socket types following changes to 2006-04-01 16:20:54 +00:00
ip_divert.h
ip_dummynet.c Obey opt_inet6.h in kernel build directory. 2006-02-20 12:30:32 +00:00
ip_dummynet.h When sending a packet from dummynet, indicate that we're forwarding 2006-02-14 06:36:39 +00:00
ip_ecn.c
ip_ecn.h
ip_encap.c Normalize a significant number of kernel malloc type names: 2005-10-31 15:41:29 +00:00
ip_encap.h
ip_fastfwd.c Somewhat re-factor the read/write locking mechanism associated with the packet 2006-02-02 03:13:16 +00:00
ip_fw2.c - Do not leak read lock in IP_FW_TABLE_GETSIZE case of ipfw_ctl(). 2006-03-03 12:10:59 +00:00
ip_fw_pfil.c obey opt_inet6.h and opt_ipsec.h in kernel build directory. 2005-11-29 17:56:11 +00:00
ip_fw.h When sending a packet from dummynet, indicate that we're forwarding 2006-02-14 06:36:39 +00:00
ip_gre.c Convert last remaining function in ip_gre.c to ANSI C function 2006-01-22 01:08:30 +00:00
ip_gre.h Fix stack corruptions on amd64. 2006-01-21 10:44:34 +00:00
ip_icmp.c Add descriptions for the sysctls: 2006-03-20 21:44:12 +00:00
ip_icmp.h
ip_id.c
ip_input.c Fix five years old bug in ip_reass(): if we are using 'full' (i.e. including 2006-02-07 11:48:10 +00:00
ip_ipsec.c Move the IPSEC related code blocks to their own file to unclutter 2006-02-01 13:55:03 +00:00
ip_ipsec.h Move the IPSEC related code blocks to their own file to unclutter 2006-02-01 13:55:03 +00:00
ip_mroute.c In ip_mdq() compute the TV_DELTA the correct way around. 2006-01-24 17:09:12 +00:00
ip_mroute.h Brain-o (use standard int types now). 2006-02-01 06:15:37 +00:00
ip_options.c Remove 'ipprintfs' which were protected under DIAGNOSTIC. It doesn't 2005-11-19 17:04:52 +00:00
ip_options.h Move MAX_IPOPTLEN and struct ipoption back into ip_var.h as 2005-11-19 14:01:32 +00:00
ip_output.c Somewhat re-factor the read/write locking mechanism associated with the packet 2006-02-02 03:13:16 +00:00
ip_var.h Move MAX_IPOPTLEN and struct ipoption back into ip_var.h as 2005-11-19 14:01:32 +00:00
ip.h
ipprotosw.h
pim_var.h Remove public declarations of variables that were forgotten when they were 2005-08-10 07:10:02 +00:00
pim.h
raw_ip.c Update in_pcb-derived basic socket types following changes to 2006-04-01 16:20:54 +00:00
tcp_debug.c
tcp_debug.h
tcp_fsm.h
tcp_hostcache.c
tcp_input.c Update TCP for infrastructural changes to the socket/pcb refcount model, 2006-04-01 16:36:36 +00:00
tcp_output.c This patch fixes the problem where the current TCP code can not handle 2006-02-23 21:14:34 +00:00
tcp_reass.c Update TCP for infrastructural changes to the socket/pcb refcount model, 2006-04-01 16:36:36 +00:00
tcp_sack.c Remove unneeded includes and provide more accurate description 2006-02-18 17:05:00 +00:00
tcp_seq.h
tcp_subr.c Update TCP for infrastructural changes to the socket/pcb refcount model, 2006-04-01 16:36:36 +00:00
tcp_syncache.c Change soabort() from returning int to returning void, since all 2006-03-16 07:03:14 +00:00
tcp_timer.c Update TCP for infrastructural changes to the socket/pcb refcount model, 2006-04-01 16:36:36 +00:00
tcp_timer.h Have TCP Inflight disable itself if the RTT is below a certain 2006-02-16 19:38:07 +00:00
tcp_timewait.c Update TCP for infrastructural changes to the socket/pcb refcount model, 2006-04-01 16:36:36 +00:00
tcp_usrreq.c Update TCP for infrastructural changes to the socket/pcb refcount model, 2006-04-01 16:36:36 +00:00
tcp_var.h Update TCP for infrastructural changes to the socket/pcb refcount model, 2006-04-01 16:36:36 +00:00
tcp.h Add missing TH_PUSH to the TH_FLAGS enumeration. 2006-02-18 16:50:08 +00:00
tcpip.h
udp_usrreq.c Update in_pcb-derived basic socket types following changes to 2006-04-01 16:20:54 +00:00
udp_var.h
udp.h