freebsd-skq/sys/netgraph
Robert Watson 0daccb9c94 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 /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_async.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_atmllc.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_atmllc.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_base.c Make netgraph ISR and callout MPSAFE. 2005-02-12 09:52:36 +00:00
ng_bpf.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
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 /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_cisco.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_cisco.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_device.c Make WITNESS happier: 2005-02-14 13:47:06 +00:00
ng_device.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_echo.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_echo.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
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 /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
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 /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_frame_relay.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_frame_relay.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_gif_demux.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_gif_demux.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_gif.c Removed redundant MODULE_VERSION(). 2005-02-12 11:14:25 +00:00
ng_gif.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_hole.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_hole.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_hub.c Having moved metadata usage to mbuf tags, remove code that supports 2004-06-26 22:24:16 +00:00
ng_hub.h A simple packet distribution node type that acts like an Ethernet hub. 2004-04-17 12:42:17 +00:00
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 /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_ip_input.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
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 - Use ng_callout() instead of callout_reset(9). 2005-01-11 11:51:17 +00:00
ng_l2tp.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_lmi.c Ups, misprint, change and => add. 2005-01-16 23:30:45 +00:00
ng_lmi.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
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 /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_mppc.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_one2many.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_one2many.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_parse.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
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 Utilize callout_pending() macro 2005-01-11 12:20:28 +00:00
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 /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_pptpgre.c Utilize callout_pending() macro 2005-01-11 12:20:28 +00:00
ng_pptpgre.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_rfc1490.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_rfc1490.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_sample.c Whitespace. 2005-02-06 19:24:59 +00:00
ng_sample.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
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 /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_socketvar.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_source.c Fallout from the ALTQ import. 2005-02-12 17:03:01 +00:00
ng_source.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_split.c bzero() -> M_ZERO. 2005-02-08 10:31:55 +00:00
ng_split.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
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 /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_tee.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_tty.c Locking and cleanup of tty netgraph node. Tty stack is Giant-locked, 2005-01-13 07:43:12 +00:00
ng_tty.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_UI.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_UI.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_vjc.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_vjc.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ng_vlan.c Switch to using C99 sparse initialisers for the type methods array. 2004-05-29 00:51:19 +00:00
ng_vlan.h Netgraph node type for IEEE 802.1Q VLAN tagging. 2004-03-01 17:22:16 +00:00
NOTES