freebsd-dev/sys/netgraph
Gleb Smirnoff 779f106aa1 Listening sockets improvements.
o Separate fields of struct socket that belong to listening from
  fields that belong to normal dataflow, and unionize them.  This
  shrinks the structure a bit.
  - Take out selinfo's from the socket buffers into the socket. The
    first reason is to support braindamaged scenario when a socket is
    added to kevent(2) and then listen(2) is cast on it. The second
    reason is that there is future plan to make socket buffers pluggable,
    so that for a dataflow socket a socket buffer can be changed, and
    in this case we also want to keep same selinfos through the lifetime
    of a socket.
  - Remove struct struct so_accf. Since now listening stuff no longer
    affects struct socket size, just move its fields into listening part
    of the union.
  - Provide sol_upcall field and enforce that so_upcall_set() may be called
    only on a dataflow socket, which has buffers, and for listening sockets
    provide solisten_upcall_set().

o Remove ACCEPT_LOCK() global.
  - Add a mutex to socket, to be used instead of socket buffer lock to lock
    fields of struct socket that don't belong to a socket buffer.
  - Allow to acquire two socket locks, but the first one must belong to a
    listening socket.
  - Make soref()/sorele() to use atomic(9).  This allows in some situations
    to do soref() without owning socket lock.  There is place for improvement
    here, it is possible to make sorele() also to lock optionally.
  - Most protocols aren't touched by this change, except UNIX local sockets.
    See below for more information.

o Reduce copy-and-paste in kernel modules that accept connections from
  listening sockets: provide function solisten_dequeue(), and use it in
  the following modules: ctl(4), iscsi(4), ng_btsocket(4), ng_ksocket(4),
  infiniband, rpc.

o UNIX local sockets.
  - Removal of ACCEPT_LOCK() global uncovered several races in the UNIX
    local sockets.  Most races exist around spawning a new socket, when we
    are connecting to a local listening socket.  To cover them, we need to
    hold locks on both PCBs when spawning a third one.  This means holding
    them across sonewconn().  This creates a LOR between pcb locks and
    unp_list_lock.
  - To fix the new LOR, abandon the global unp_list_lock in favor of global
    unp_link_lock.  Indeed, separating these two locks didn't provide us any
    extra parralelism in the UNIX sockets.
  - Now call into uipc_attach() may happen with unp_link_lock hold if, we
    are accepting, or without unp_link_lock in case if we are just creating
    a socket.
  - Another problem in UNIX sockets is that uipc_close() basicly did nothing
    for a listening socket.  The vnode remained opened for connections.  This
    is fixed by removing vnode in uipc_close().  Maybe the right way would be
    to do it for all sockets (not only listening), simply move the vnode
    teardown from uipc_detach() to uipc_close()?

Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D9770
2017-06-08 21:30:34 +00:00
..
atm Remove the NATM framework including the en(4), fatm(4), hatm(4), and 2017-04-24 21:21:49 +00:00
bluetooth Listening sockets improvements. 2017-06-08 21:30:34 +00:00
netflow Fix style(9). 2016-05-26 19:17:51 +00:00
netgraph.h sys/netgraph: spelling fixes in comments. 2016-04-29 21:25:05 +00:00
ng_async.c
ng_async.h
ng_atmllc.c Remove the NATM framework including the en(4), fatm(4), hatm(4), and 2017-04-24 21:21:49 +00:00
ng_atmllc.h
ng_base.c Fix return value from ng_uncallout(). 2016-12-02 09:29:22 +00:00
ng_bpf.c
ng_bpf.h
ng_bridge.c sys/netgraph: spelling fixes in comments. 2016-04-29 21:25:05 +00:00
ng_bridge.h
ng_car.c sys/netgraph: spelling fixes in comments. 2016-04-29 21:25:05 +00:00
ng_car.h sys/netgraph: spelling fixes in comments. 2016-04-29 21:25:05 +00:00
ng_checksum.c netgraph module for reconstructing checksums 2016-08-01 12:09:04 +00:00
ng_checksum.h netgraph module for reconstructing checksums 2016-08-01 12:09:04 +00:00
ng_cisco.c
ng_cisco.h
ng_deflate.c Move zlib.c from net to libkern. 2015-04-22 14:38:58 +00:00
ng_deflate.h
ng_device.c
ng_device.h
ng_echo.c
ng_echo.h
ng_eiface.c Get closer to a VIMAGE network stack teardown from top to bottom rather 2016-06-21 13:48:49 +00:00
ng_eiface.h
ng_etf.c sys/netgraph: spelling fixes in comments. 2016-04-29 21:25:05 +00:00
ng_etf.h
ng_ether_echo.c
ng_ether_echo.h
ng_ether.c sys/netgraph: spelling fixes in comments. 2016-04-29 21:25:05 +00:00
ng_ether.h
ng_frame_relay.c sys/netgraph: spelling fixes in comments. 2016-04-29 21:25:05 +00:00
ng_frame_relay.h
ng_gif_demux.c sys/netgraph: spelling fixes in comments. 2016-04-29 21:25:05 +00:00
ng_gif_demux.h
ng_gif.c sys/netgraph: spelling fixes in comments. 2016-04-29 21:25:05 +00:00
ng_gif.h
ng_hole.c
ng_hole.h
ng_hub.c
ng_hub.h
ng_iface.c Get closer to a VIMAGE network stack teardown from top to bottom rather 2016-06-21 13:48:49 +00:00
ng_iface.h
ng_ip_input.c
ng_ip_input.h
ng_ipfw.c Cleanup unnecessary semicolons from the kernel. 2016-04-10 23:07:00 +00:00
ng_ipfw.h
ng_ksocket.c Listening sockets improvements. 2017-06-08 21:30:34 +00:00
ng_ksocket.h
ng_l2tp.c Writing out the L2TP control packet requires 12 bytes of 2016-11-17 14:03:44 +00:00
ng_l2tp.h sys/netgraph: spelling fixes in comments. 2016-04-29 21:25:05 +00:00
ng_lmi.c sys/netgraph: spelling fixes in comments. 2016-04-29 21:25:05 +00:00
ng_lmi.h
ng_message.h
ng_mppc.c mppc - Finish pluging NETGRAPH_MPPC_COMPRESSION. 2017-01-20 00:02:11 +00:00
ng_mppc.h
ng_nat.c Cleanup unnecessary semicolons from the kernel. 2016-04-10 23:07:00 +00:00
ng_nat.h
ng_one2many.c sys/netgraph: spelling fixes in comments. 2016-04-29 21:25:05 +00:00
ng_one2many.h
ng_parse.c Fix a bunch of -Wcast-qual warnings in netgraph's ng_parse.c, by using 2015-01-30 21:59:53 +00:00
ng_parse.h
ng_patch.c Changes to allow the patching of packets with an offset (and other changes.. see man page) 2016-12-02 10:47:10 +00:00
ng_patch.h Changes to allow the patching of packets with an offset (and other changes.. see man page) 2016-12-02 10:47:10 +00:00
ng_pipe.c
ng_pipe.h
ng_ppp.c sys/netgraph: spelling fixes in comments. 2016-04-29 21:25:05 +00:00
ng_ppp.h
ng_pppoe.c sys/netgraph: spelling fixes in comments. 2016-04-29 21:25:05 +00:00
ng_pppoe.h Add support for PPP-Max-Payload PPPoE tag (RFC4638). 2015-09-11 09:15:27 +00:00
ng_pptpgre.c sys/netgraph: spelling fixes in comments. 2016-04-29 21:25:05 +00:00
ng_pptpgre.h
ng_pred1.c
ng_pred1.h
ng_rfc1490.c
ng_rfc1490.h
ng_sample.c sys/netgraph: spelling fixes in comments. 2016-04-29 21:25:05 +00:00
ng_sample.h
ng_socket.c sys: use our nitems() macro when param.h is available. 2016-04-21 19:40:10 +00:00
ng_socket.h
ng_socketvar.h
ng_source.c sys/netgraph: spelling fixes in comments. 2016-04-29 21:25:05 +00:00
ng_source.h
ng_split.c
ng_split.h sys/netgraph: spelling fixes in comments. 2016-04-29 21:25:05 +00:00
ng_sppp.c
ng_sppp.h
ng_tag.c
ng_tag.h
ng_tcpmss.c
ng_tcpmss.h
ng_tee.c sys/netgraph: spelling fixes in comments. 2016-04-29 21:25:05 +00:00
ng_tee.h
ng_tty.c sys/netgraph: spelling fixes in comments. 2016-04-29 21:25:05 +00:00
ng_tty.h
ng_UI.c
ng_UI.h
ng_vjc.c sys/netgraph: spelling fixes in comments. 2016-04-29 21:25:05 +00:00
ng_vjc.h
ng_vlan.c sys/netgraph: spelling fixes in comments. 2016-04-29 21:25:05 +00:00
ng_vlan.h
NOTES