sys: general adoption of SPDX licensing ID tags.Mainly focus on files that use BSD 2-Clause license, however the tool Iwas using misidentified many licenses so this was mostly a manual - errorpro
sys: general adoption of SPDX licensing ID tags.Mainly focus on files that use BSD 2-Clause license, however the tool Iwas using misidentified many licenses so this was mostly a manual - errorprone - task.The Software Package Data Exchange (SPDX) group provides a specificationto make it easier for automated tools to detect and summarize well knownopensource licenses. We are gradually adopting the specification, notingthat the tags are considered only advisory and do not, in any way,superceed or replace the license texts.No functional change intended.
show more ...
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. -
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: NetflixDifferential Revision: https://reviews.freebsd.org/D9770
Disconnect LE socket when the HCI connection associated is disconnected.
sys/netgraph: spelling fixes in comments.No functional change.
Remove slightly used const values that can be replaced with nitems().Suggested by: jhb
Make it possible for sbappend() to preserve M_NOTREADY on mbufs, just likesbappendstream() does. Although, M_NOTREADY may appear only on SOCK_STREAMsockets, due to sendfile(2) supporting only the l
Make it possible for sbappend() to preserve M_NOTREADY on mbufs, just likesbappendstream() does. Although, M_NOTREADY may appear only on SOCK_STREAMsockets, due to sendfile(2) supporting only the latter, there is a cornercase of AF_UNIX/SOCK_STREAM socket, that still uses records for the sakeof control data, albeit being stream socket.Provide private version of m_clrprotoflags(), which understands PRUS_NOTREADY,similar to m_demote().
- grab ng_btsocket_l2cap_sockets_mtx lock in ng_btsocket_l2cap_process_l2ca_enc_change() before calling ng_btsocket_l2cap_pcb_by_cid();- handle possible NULL value returned from ng_btsocket_l
- grab ng_btsocket_l2cap_sockets_mtx lock in ng_btsocket_l2cap_process_l2ca_enc_change() before calling ng_btsocket_l2cap_pcb_by_cid();- handle possible NULL value returned from ng_btsocket_l2cap_pcb_by_cid();Submitted by: Hans Petter Selasky; hps at selasky dot orgMFC after: 1 week
Fix encryption error handling.Close l2cap connection on encryption error.
Bluetooth LE Security Management channel support.Add a socket option to block until underlying HCI connection encrypted.Differential Revision: https://reviews.freebsd.org/D3981
Fix rfcomm_sppd regression I could reproduced.To reproduce it, Two machine running FreeBSD andrunrfcomm_sppd -c 3 -Srfcomm_sppd -a ${PEER} -c 3on each side.
Initial Bluetooth LE support.Note that sockaddr_l2cap structure is changed , check socket addressto initialize new structure member and define L2CAP_SOCKET_CHECKEDbefore including ng_btsocket.h
Initial Bluetooth LE support.Note that sockaddr_l2cap structure is changed , check socket addressto initialize new structure member and define L2CAP_SOCKET_CHECKEDbefore including ng_btsocket.hDifferential Revision: https://reviews.freebsd.org/D2021Reviewed by:emax
In preparation of merging projects/sendfile, transform bare access tosb_cc member of struct sockbuf to a couple of inline functions:sbavail() and sbused()Right now they are equal, but once notio
In preparation of merging projects/sendfile, transform bare access tosb_cc member of struct sockbuf to a couple of inline functions:sbavail() and sbused()Right now they are equal, but once notion of "not ready socket buffer data",will be checked in, they are going to be different.Sponsored by: NetflixSponsored by: Nginx, Inc.
Use callout(9) instead of timeout(9).Reviewed by: emax
PF_BLUETOOTH protocols: skip initialization of non-virtualized globalsfor non-default VNET instances.This fixes panic on a vnet initialization when ng_btsocket is loaded.MFC after: 1 week
PR: 168520 170096Submitted by: adrian, zecFix multiple kernel panics when VIMAGE is enabled in the kernel.These fixes are based on patches submitted by Adrian Chadd and Marko Zec.(1) Set curth
PR: 168520 170096Submitted by: adrian, zecFix multiple kernel panics when VIMAGE is enabled in the kernel.These fixes are based on patches submitted by Adrian Chadd and Marko Zec.(1) Set curthread->td_vnet to vnet0 in device_probe_and_attach() just before calling device_attach(). This fixes multiple VIMAGE related kernel panics when trying to attach Bluetooth or USB Ethernet devices because curthread->td_vnet is NULL.(2) Set curthread->td_vnet in if_detach(). This fixes kernel panics when detaching networking interfaces, especially USB Ethernet devices.(3) Use VNET_DOMAIN_SET() in ng_btsocket.c(4) In ng_unref_node() set curthread->td_vnet. This fixes kernel panics when detaching Netgraph nodes.
Mechanically substitute flags from historic mbuf allocator withmalloc(9) flags within sys.Exceptions:- sys/contrib not touched- sys/mbuf.h edited manually
Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.The SYSCTL_NODE macro defines a list that stores all child-elements ofthat node. If there's no SYSCTL_DECL macro anywhere else,
Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.The SYSCTL_NODE macro defines a list that stores all child-elements ofthat node. If there's no SYSCTL_DECL macro anywhere else, there's noreason why it shouldn't be static.
Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs.This means that their use is restricted to a single C file.
Fix typos - remove duplicate "the".PR: bin/154928Submitted by: Eitan Adler <lists at eitanadler.com>MFC after: 3 days
Mfp4 CH=177274,177280,177284-177285,177297,177324-177325 VNET socket push back: try to minimize the number of places where we have to switch vnets and narrow down the time we stay switched. A
Mfp4 CH=177274,177280,177284-177285,177297,177324-177325 VNET socket push back: try to minimize the number of places where we have to switch vnets and narrow down the time we stay switched. Add assertions to the socket code to catch possibly unset vnets as seen in r204147. While this reduces the number of vnet recursion in some places like NFS, POSIX local sockets and some netgraph, .. recursions are impossible to fix. The current expectations are documented at the beginning of uipc_socket.c along with the other information there. Sponsored by: The FreeBSD Foundation Sponsored by: CK Software GmbH Reviewed by: jhb Tested by: zecTested by: Mikolaj Golub (to.my.trociny gmail.com)MFC after: 2 weeks
sysctl(9) cleanup checkpoint: amd64 GENERIC builds cleanly.Commit the netgraph piece.
Introduce and use a sysinit-based initialization scheme for virtualnetwork stacks, VNET_SYSINIT:- Add VNET_SYSINIT and VNET_SYSUNINIT macros to declare events that will occur each time a network
Introduce and use a sysinit-based initialization scheme for virtualnetwork stacks, VNET_SYSINIT:- Add VNET_SYSINIT and VNET_SYSUNINIT macros to declare events that will occur each time a network stack is instantiated and destroyed. In the !VIMAGE case, these are simply mapped into regular SYSINIT/SYSUNINIT. For the VIMAGE case, we instead use SYSINIT's to track their order and properties on registration, using them for each vnet when created/ destroyed, or immediately on module load for already-started vnets.- Remove vnet_modinfo mechanism that existed to serve this purpose previously, as well as its dependency scheme: we now just use the SYSINIT ordering scheme.- Implement VNET_DOMAIN_SET() to allow protocol domains to declare that they want init functions to be called for each virtual network stack rather than just once at boot, compiling down to DOMAIN_SET() in the non-VIMAGE case.- Walk all virtualized kernel subsystems and make use of these instead of modinfo or DOMAIN_SET() for init/uninit events. In some cases, convert modular components from using modevent to using sysinit (where appropriate). In some cases, do minor rejuggling of SYSINIT ordering to make room for or better manage events.Portions submitted by: jhb (VNET_SYSINIT), bz (cleanup)Discussed with: jhb, bz, julian, zecReviewed by: bzApproved by: re (VIMAGE blanket)
Rework socket upcalls to close some races with setup/teardown of upcalls.- Each socket upcall is now invoked with the appropriate socket buffer locked. It is not permissible to call soisconnected
Rework socket upcalls to close some races with setup/teardown of upcalls.- Each socket upcall is now invoked with the appropriate socket buffer locked. It is not permissible to call soisconnected() with this lock held; however, so socket upcalls now return an integer value. The two possible values are SU_OK and SU_ISCONNECTED. If an upcall returns SU_ISCONNECTED, then the soisconnected() will be invoked on the socket after the socket buffer lock is dropped.- A new API is provided for setting and clearing socket upcalls. The API consists of soupcall_set() and soupcall_clear().- To simplify locking, each socket buffer now has a separate upcall.- When a socket upcall returns SU_ISCONNECTED, the upcall is cleared from the receive socket buffer automatically. Note that a SO_SND upcall should never return SU_ISCONNECTED.- All this means that accept filters should now return SU_ISCONNECTED instead of calling soisconnected() directly. They also no longer need to explicitly clear the upcall on the new socket.- The HTTP accept filter still uses soupcall_set() to manage its internal state machine, but other accept filters no longer have any explicit knowlege of socket upcall internals aside from their return value.- The various RPC client upcalls currently drop the socket buffer lock while invoking soreceive() as a temporary band-aid. The plan for the future is to add a new flag to allow soreceive() to be called with the socket buffer locked.- The AIO callback for socket I/O is now also invoked with the socket buffer locked. Previously sowakeup() would drop the socket buffer lock only to call aio_swake() which immediately re-acquired the socket buffer lock for the duration of the function call.Discussed with: rwatson, rmacklem
Update comment. soalloc() is no longer performing M_WAITOK memory allocations.Submitted by: ruMFC after: 3 days
Allow unprivileged users to run l2ping(8).MFC after: 1 month
1234