freebsd-nq/sys/netipx
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
..
ipx_cksum.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ipx_if.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ipx_input.c Mark the IPX netisr as MPSAFE so that inbound IPX traffic is processed 2005-01-09 07:34:55 +00:00
ipx_ip.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ipx_ip.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ipx_outputfl.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ipx_pcb.c Assert or acquire the IPX PCB list lock or IPX PCB locks throughout 2005-01-09 05:10:43 +00:00
ipx_pcb.h Introduce a global mutex, ipxpcb_list_mtx, to protect the global 2005-01-09 05:00:41 +00:00
ipx_proto.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ipx_usrreq.c Protect ipx_pexseq with the IPX PCB list mutex. 2005-01-09 05:15:59 +00:00
ipx_var.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
ipx.c Recent changes have locked down most of the highly dynamic data 2005-01-09 05:34:37 +00:00
ipx.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
README /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
spx_debug.c /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
spx_debug.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
spx_timer.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
spx_usrreq.c In the current world order, solisten() implements the state transition of 2005-02-21 21:58:17 +00:00
spx_var.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00
spx.h /* -> /*- for license, minor formatting changes 2005-01-07 01:45:51 +00:00

$FreeBSD$

This protocol implements IPX/SPX over Ethernet_II frame type 0x8137.
Please note: the SPX implementation may require further work and testing
to insure proper operation.

Mike Mitchell, Network Engineer
AMTECH Systems Corporation, Technology and Manufacturing
8600 Jefferson Street, Albuquerque, New Mexico 87113 (505) 856-8000
supervisor@alb.asctmd.com

John Hay
Some Company
Some Address
jhay@mikom.csir.co.za

--- Copyright Information ---
/*-

Copyright (c) 1984, 1985, 1986, 1987, 1993
The Regents of the University of California.  All rights reserved.

Modifications Copyright (c) 2004, Robert N. M. Watson
Modifications Copyright (c) 1995, Mike Mitchell
Modifications Copyright (c) 1995, John Hay

*/