tcp: Allow socket/syncache inheritance between SO_REUSEPORT listen sockets
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 31 Jul 2013 08:31:02 +0000 (16:31 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Thu, 1 Aug 2013 08:05:15 +0000 (16:05 +0800)
commit02ad2f0b874fb0a45eb69750219f79f5e8982272
tree1d80482481fc512baa1a7806d9c4d1ea0d64ad99
parenta01c761336053e6b4df8e22573d6fbd2a48e4eba
tcp: Allow socket/syncache inheritance between SO_REUSEPORT listen sockets

This is intend to address the drawback of the following SO_REUSEPORT tcp
listen socket usage model:
Multiple processses create their own listen socket w/ SO_REUSEPORT, if
one of the process crashed, i.e. the listen socket is closed, then any
syncache, pending sockets on the completion and incompletion queues
are just dropped.

Compared w/ multiple processes sharing the same tcp listen socket, this
drawback could be unacceptable (e.g. when nginx reload configure).

This commit addresses this drawback by allowing another tcp listen socket
in the same local group, i.e. bound to the same listen port and address,
to inherit the syncache and pending sockets of the to-be-closed tcp
listen socket.  The tcp listen socket, which inherits the syncache and
pending sockets, is the last tcp listen socket in the same local group.
sys/kern/uipc_socket.c
sys/netinet/in_pcb.c
sys/netinet/in_pcb.h
sys/netinet/tcp_subr.c
sys/netinet/tcp_syncache.c
sys/netinet/tcp_var.h
sys/sys/socketvar.h