freebsd-skq/sys/netatm
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
..
ipatm In the current world order, solisten() implements the state transition of 2005-02-21 21:58:17 +00:00
sigpvc /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
spans /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
uni /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
atm_aal5.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
atm_cm.c In the current world order, solisten() implements the state transition of 2005-02-21 21:58:17 +00:00
atm_cm.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
atm_device.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
atm_if.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
atm_if.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
atm_ioctl.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
atm_pcb.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
atm_proto.c Mark netatm and netnatm explicitly as requiring Giant, as they still do. 2005-02-17 14:21:22 +00:00
atm_sap.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
atm_sigmgr.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
atm_signal.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
atm_socket.c In the current world order, solisten() implements the state transition of 2005-02-21 21:58:17 +00:00
atm_stack.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
atm_subr.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
atm_sys.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
atm_usrreq.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
atm_var.h In the current world order, solisten() implements the state transition of 2005-02-21 21:58:17 +00:00
atm_vc.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
atm.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
port.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
queue.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00