freebsd-skq/sys/netgraph
rwatson 26df80bf2c In the current world order, solisten() implements the state transition of
a socket from a regular socket to a listening socket able to accept new
connections.  As part of this state transition, solisten() calls into the
protocol to update protocol-layer state.  There were several bugs in this
implementation that could result in a race wherein a TCP SYN received
in the interval between the protocol state transition and the shortly
following socket layer transition would result in a panic in the TCP code,
as the socket would be in the TCPS_LISTEN state, but the socket would not
have the SO_ACCEPTCONN flag set.

This change does the following:

- Pushes the socket state transition from the socket layer solisten() to
  to socket "library" routines called from the protocol.  This permits
  the socket routines to be called while holding the protocol mutexes,
  preventing a race exposing the incomplete socket state transition to TCP
  after the TCP state transition has completed.  The check for a socket
  layer state transition is performed by solisten_proto_check(), and the
  actual transition is performed by solisten_proto().

- Holds the socket lock for the duration of the socket state test and set,
  and over the protocol layer state transition, which is now possible as
  the socket lock is acquired by the protocol layer, rather than vice
  versa.  This prevents additional state related races in the socket
  layer.

This permits the dual transition of socket layer and protocol layer state
to occur while holding locks for both layers, making the two changes
atomic with respect to one another.  Similar changes are likely require
elsewhere in the socket/protocol code.

Reported by:		Peter Holm <peter@holm.cc>
Review and fixes from:	emax, Antoine Brodin <antoine.brodin@laposte.net>
Philosophical head nod:	gnn
2005-02-21 21:58:17 +00:00
..
atm Fixed an off-by-one error when dealing with interface name 2005-02-03 12:54:18 +00:00
bluetooth In the current world order, solisten() implements the state transition of 2005-02-21 21:58:17 +00:00
netflow Expire aged flows in normal expiry thread. This fixes the problem, when 2005-02-05 10:00:04 +00:00
netgraph.h Make netgraph ISR and callout MPSAFE. 2005-02-12 09:52:36 +00:00
ng_async.c
ng_async.h
ng_atmllc.c
ng_atmllc.h
ng_base.c Make netgraph ISR and callout MPSAFE. 2005-02-12 09:52:36 +00:00
ng_bpf.c
ng_bpf.h Fix typo in a comment. 2005-02-12 18:10:26 +00:00
ng_bridge.c In revision 1.29 timeout() was converted to ng_callout(). 2005-02-09 15:14:44 +00:00
ng_bridge.h
ng_cisco.c
ng_cisco.h
ng_device.c Make WITNESS happier: 2005-02-14 13:47:06 +00:00
ng_device.h
ng_echo.c
ng_echo.h
ng_eiface.c bzero() -> M_ZERO. 2005-02-08 10:31:55 +00:00
ng_eiface.h Added ASCII version of the NGM_EIFACE_GET_IFNAME message, "getifname". 2005-02-03 11:52:42 +00:00
ng_etf.c Make M_NETGRAPH_ETF static 2005-02-10 12:26:57 +00:00
ng_etf.h
ng_ether.c Add new netgraph control message NGM_ETHER_DETACH, which actually 2005-02-14 12:01:09 +00:00
ng_ether.h Add new netgraph control message NGM_ETHER_DETACH, which actually 2005-02-14 12:01:09 +00:00
ng_fec.c bzero() -> M_ZERO. 2005-02-08 10:31:55 +00:00
ng_fec.h
ng_frame_relay.c
ng_frame_relay.h
ng_gif_demux.c
ng_gif_demux.h
ng_gif.c Removed redundant MODULE_VERSION(). 2005-02-12 11:14:25 +00:00
ng_gif.h
ng_hole.c
ng_hole.h
ng_hub.c
ng_hub.h
ng_iface.c Create a per-module mutex on MOD_LOAD, and destroy it on MOD_UNLOAD. 2005-02-05 08:28:36 +00:00
ng_iface.h Bump cookie value to reflect change in NGM_IFACE_GET_IFNAME semantics. 2005-02-13 16:36:41 +00:00
ng_ip_input.c
ng_ip_input.h
ng_ipfw.c style: fix indentation and spacing. 2005-02-11 23:17:50 +00:00
ng_ipfw.h Add a ng_ipfw node, implementing a quick and simple interface between 2005-02-05 12:06:33 +00:00
ng_ksocket.c Reimplement recursion protection, checking whether current thread holds 2005-02-19 14:41:49 +00:00
ng_ksocket.h When netgraph(4) was converted to use mbuf_tags(9) instead of meta-data 2005-02-12 14:54:19 +00:00
ng_l2tp.c
ng_l2tp.h
ng_lmi.c Ups, misprint, change and => add. 2005-01-16 23:30:45 +00:00
ng_lmi.h
ng_message.h Increase size of arglen to uint32_t, since uint16_t proved to be 2005-02-05 23:23:14 +00:00
ng_mppc.c
ng_mppc.h
ng_one2many.c
ng_one2many.h
ng_parse.c
ng_parse.h Fix variable name in comment num=>alen. (Lost part of commit rev 1.2) 2005-01-16 19:12:27 +00:00
ng_ppp.c
ng_ppp.h Fix incorrect comment. 2005-02-10 02:43:26 +00:00
ng_pppoe.c Drop mythical module dependency on ng_ether. 2005-02-13 00:50:18 +00:00
ng_pppoe.h
ng_pptpgre.c
ng_pptpgre.h
ng_rfc1490.c
ng_rfc1490.h
ng_sample.c Whitespace. 2005-02-06 19:24:59 +00:00
ng_sample.h
ng_socket.c Create a per-module mutex on MOD_LOAD, and destroy it on MOD_UNLOAD. 2005-02-05 08:28:36 +00:00
ng_socket.h
ng_socketvar.h
ng_source.c Fallout from the ALTQ import. 2005-02-12 17:03:01 +00:00
ng_source.h
ng_split.c bzero() -> M_ZERO. 2005-02-08 10:31:55 +00:00
ng_split.h
ng_sppp.c Parse "getifname" using the standard parse string type. 2005-02-03 13:03:31 +00:00
ng_sppp.h Parse "getifname" using the standard parse string type. 2005-02-03 13:03:31 +00:00
ng_tee.c
ng_tee.h
ng_tty.c
ng_tty.h
ng_UI.c
ng_UI.h
ng_vjc.c
ng_vjc.h
ng_vlan.c
ng_vlan.h
NOTES