aboutsummaryrefslogtreecommitdiff
path: root/sys/netgraph/bluetooth/socket
Commit message (Collapse)AuthorAgeFilesLines
* net: clean up empty lines in .c and .h filesMateusz Guzik2020-09-015-41/+23
| | | | Notes: svn path=/head/; revision=365071
* Allow some Bluetooth LE related HCI request to non-root user.Takanori Watanabe2020-07-011-0/+6
| | | | | | | | | | PR: 247588 Reported by: Greg V (greg@unrelenting.technology) Reviewed by: emax Differential Revision: https://reviews.freebsd.org/D25516 Notes: svn path=/head/; revision=362825
* Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)Pawel Biernacki2020-02-266-18/+27
| | | | | | | | | | | | | | | | | | | r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are still not MPSAFE (or already are but aren’t properly marked). Use it in preparation for a general review of all nodes. This is non-functional change that adds annotations to SYSCTL_NODE and SYSCTL_PROC nodes using one of the soon-to-be-required flags. Mark all obvious cases as MPSAFE. All entries that haven't been marked as MPSAFE before are by default marked as NEEDGIANT Approved by: kib (mentor, blanket) Commented by: kib, gallatin, melifaro Differential Revision: https://reviews.freebsd.org/D23718 Notes: svn path=/head/; revision=358333
* avoid holding PCB mutex during copyin/copyout()Maksim Yevmenkin2019-08-302-89/+154
| | | | | | | | Reported by: imp, mms dot vanbreukelingen at gmail dot com Reviewed by: imp Notes: svn path=/head/; revision=351626
* sys: general adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-276-0/+12
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. No functional change intended. Notes: svn path=/head/; revision=326272
* Listening sockets improvements.Gleb Smirnoff2017-06-083-58/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=319722
* Disconnect LE socket when the HCI connection associated is disconnected.Takanori Watanabe2016-06-071-1/+1
| | | | Notes: svn path=/head/; revision=301558
* sys/netgraph: spelling fixes in comments.Pedro F. Giffuni2016-04-293-7/+7
| | | | | | | No functional change. Notes: svn path=/head/; revision=298813
* Remove slightly used const values that can be replaced with nitems().Pedro F. Giffuni2016-04-211-3/+2
| | | | | | | Suggested by: jhb Notes: svn path=/head/; revision=298411
* Make it possible for sbappend() to preserve M_NOTREADY on mbufs, just likeGleb Smirnoff2016-01-081-2/+2
| | | | | | | | | | | | | sbappendstream() does. Although, M_NOTREADY may appear only on SOCK_STREAM sockets, due to sendfile(2) supporting only the latter, there is a corner case of AF_UNIX/SOCK_STREAM socket, that still uses records for the sake of control data, albeit being stream socket. Provide private version of m_clrprotoflags(), which understands PRUS_NOTREADY, similar to m_demote(). Notes: svn path=/head/; revision=293432
* - grab ng_btsocket_l2cap_sockets_mtx lock inMaksim Yevmenkin2015-12-231-0/+8
| | | | | | | | | | | | | | 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 org MFC after: 1 week Notes: svn path=/head/; revision=292660
* Fix encryption error handling.Takanori Watanabe2015-11-071-0/+4
| | | | | | | Close l2cap connection on encryption error. Notes: svn path=/head/; revision=290491
* Bluetooth LE Security Management channel support.Takanori Watanabe2015-10-271-32/+96
| | | | | | | | | Add a socket option to block until underlying HCI connection encrypted. Differential Revision: https://reviews.freebsd.org/D3981 Notes: svn path=/head/; revision=290038
* Fix rfcomm_sppd regression I could reproduced.Takanori Watanabe2015-07-071-0/+4
| | | | | | | | | | | To reproduce it, Two machine running FreeBSD and run rfcomm_sppd -c 3 -S rfcomm_sppd -a ${PEER} -c 3 on each side. Notes: svn path=/head/; revision=285244
* Initial Bluetooth LE support.Takanori Watanabe2015-04-073-50/+136
| | | | | | | | | | | | Note that sockaddr_l2cap structure is changed , check socket address to initialize new structure member and define L2CAP_SOCKET_CHECKED before including ng_btsocket.h Differential Revision: https://reviews.freebsd.org/D2021 Reviewed by:emax Notes: svn path=/head/; revision=281198
* In preparation of merging projects/sendfile, transform bare access toGleb Smirnoff2014-11-123-6/+5
| | | | | | | | | | | | | | | sb_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: Netflix Sponsored by: Nginx, Inc. Notes: svn path=/head/; revision=274421
* Use callout(9) instead of timeout(9).John Baldwin2014-09-202-15/+10
| | | | | | | Reviewed by: emax Notes: svn path=/head/; revision=271908
* PF_BLUETOOTH protocols: skip initialization of non-virtualized globalsMikolaj Golub2014-06-105-0/+27
| | | | | | | | | | | for non-default VNET instances. This fixes panic on a vnet initialization when ng_btsocket is loaded. MFC after: 1 week Notes: svn path=/head/; revision=267336
* PR: 168520 170096Craig Rodrigues2013-07-151-1/+3
| | | | | | | | | | | | | | | | | | | | | | | Submitted by: adrian, zec Fix 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. Notes: svn path=/head/; revision=253346
* Mechanically substitute flags from historic mbuf allocator withGleb Smirnoff2012-12-054-15/+15
| | | | | | | | | | | | malloc(9) flags within sys. Exceptions: - sys/contrib not touched - sys/mbuf.h edited manually Notes: svn path=/head/; revision=243882
* Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.Ed Schouten2011-11-075-5/+5
| | | | | | | | | The SYSCTL_NODE macro defines a list that stores all child-elements of that node. If there's no SYSCTL_DECL macro anywhere else, there's no reason why it shouldn't be static. Notes: svn path=/head/; revision=227309
* Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs.Ed Schouten2011-11-075-6/+6
| | | | | | | This means that their use is restricted to a single C file. Notes: svn path=/head/; revision=227293
* Fix typos - remove duplicate "the".Rebecca Cran2011-02-211-1/+1
| | | | | | | | | PR: bin/154928 Submitted by: Eitan Adler <lists at eitanadler.com> MFC after: 3 days Notes: svn path=/head/; revision=218909
* Mfp4 CH=177274,177280,177284-177285,177297,177324-177325Bjoern A. Zeeb2011-02-163-3/+21
| | | | | | | | | | | | | | | | | | | | | | | | | 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: zec Tested by: Mikolaj Golub (to.my.trociny gmail.com) MFC after: 2 weeks Notes: svn path=/head/; revision=218757
* sysctl(9) cleanup checkpoint: amd64 GENERIC builds cleanly.Matthew D Fleming2011-01-125-20/+20
| | | | | | | Commit the netgraph piece. Notes: svn path=/head/; revision=217320
* Introduce and use a sysinit-based initialization scheme for virtualRobert Watson2009-07-231-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | network 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, zec Reviewed by: bz Approved by: re (VIMAGE blanket) Notes: svn path=/head/; revision=195837
* Rework socket upcalls to close some races with setup/teardown of upcalls.John Baldwin2009-06-011-14/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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 Notes: svn path=/head/; revision=193272
* Update comment. soalloc() is no longer performing M_WAITOK memory allocations.Maksim Yevmenkin2009-02-101-14/+6
| | | | | | | | Submitted by: ru MFC after: 3 days Notes: svn path=/head/; revision=188452
* Allow unprivileged users to run l2ping(8).Maksim Yevmenkin2009-02-041-5/+0
| | | | | | | MFC after: 1 month Notes: svn path=/head/; revision=188132
* Fix a number of style issues in the MALLOC / FREE commit. I've tried toDag-Erling Smørgrav2008-10-231-1/+1
| | | | | | | | be careful not to fix anything that was already broken; the NFSv4 code is particularly bad in this respect. Notes: svn path=/head/; revision=184214
* Retire the MALLOC and FREE macros. They are an abomination unto style(9).Dag-Erling Smørgrav2008-10-235-27/+22
| | | | | | | MFC after: 3 months Notes: svn path=/head/; revision=184205
* Implement ratelimiting for debug messages. For now, allow at mostMaksim Yevmenkin2008-08-015-20/+50
| | | | | | | | | | one message per second. In the future might add a sysctl knob for each socket family to fine tune this. MFC after: 1 week Notes: svn path=/head/; revision=181093
* Increase maximum input queue size limit for raw Bluetooth HCI sockets.Maksim Yevmenkin2008-08-011-2/+1
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=181089
* Fix locking bug, i.e. lock "wildcard" matched pcb before return.Maksim Yevmenkin2008-08-011-0/+3
| | | | Notes: svn path=/head/; revision=181088
* Introduce support for Bluetooth SCO sockets. This is based on olderMaksim Yevmenkin2008-07-302-1/+2002
| | | | | | | | | code that was revisted. MFC after: 3 months Notes: svn path=/head/; revision=181033
* Fix locking issue in ng_btsocket_l2cap_ctloutput()Maksim Yevmenkin2007-10-311-2/+4
| | | | | | | | Submitted by: Heiko Wundram (Beenic) < wundram at beenic dot net > MFC after: 3 days Notes: svn path=/head/; revision=173231
* Allow RFCOMM servers to bind to a ''wildcard'' RFCOMM channelMaksim Yevmenkin2007-10-291-31/+53
| | | | | | | | | | | | | | zero (0). Actual RFCOMM channel will be assigned after listen(2) call is done on a RFCOMM socket bound to a ''wildcard'' RFCOMM channel zero (0). Address locking issues in ng_btsocket_rfcomm_bind() Submitted by: Heiko Wundram (Beenic) < wundram at beenic dot net > MFC after: 1 week Notes: svn path=/head/; revision=173151
* Return EADDRNOTAVAIL instead of EDESTADDRREQ error whenMaksim Yevmenkin2007-08-232-2/+2
| | | | | | | | | | | listen(2) is called on improperly bound socket. Suggested by: Iain Hibbert Approved by: re (kensmith) MFC after: 3 days Notes: svn path=/head/; revision=171937
* Replace sosend() with direct call to .pru_send method on theMaksim Yevmenkin2007-06-211-2/+2
| | | | | | | | | | | L2CAP socket. This is to avoid LOR with sx(9) lock in sblock() called from sosend_generic(). Approved by: re (kensmith) MFC after: 1 week Notes: svn path=/head/; revision=170972
* Universally adopt most conventional spelling of acquire.Robert Watson2007-05-271-1/+1
| | | | Notes: svn path=/head/; revision=170035
* o Update a comment: sonewconn() lives in uipc_socket.c now.Maxim Konovalov2007-03-261-1/+1
| | | | Notes: svn path=/head/; revision=167907
* Sweep kernel replacing suser(9) calls with priv(9) calls, assigningRobert Watson2006-11-062-2/+4
| | | | | | | | | | | | | | | | specific privilege names to a broad range of privileges. These may require some future tweaking. Sponsored by: nCircle Network Security, Inc. Obtained from: TrustedBSD Project Discussed on: arch@ Reviewed (at least in part) by: mlaier, jmg, pjd, bde, ceri, Alex Lyashkov <umka at sevcity dot net>, Skip Ford <skip dot ford at verizon dot net>, Antoine Brodin <antoine dot brodin at laposte dot net> Notes: svn path=/head/; revision=164033
* - Catch up with ongoing rwatson's socket work;Maksim Yevmenkin2006-08-252-184/+68
| | | | | | | | | | | | | - Fix a couple of LORs and panics; - Temporarily remove the code that tries to cleanup sockets that stuck on accepting queues (both complete and incomplete). I'm taking an ostrich approach here until I find a better way to deal with sockets that were disconnected before accepting (i.e. while socket was on complete or incomplete accept queue). Notes: svn path=/head/; revision=161623
* Define mtu as u_int16_t not as int. This should fix problem with rfcommMaksim Yevmenkin2006-08-241-1/+2
| | | | | | | | | | | on sparc64. Reported by: Andrew Belashov <bel at orel dot ru> Tested by: Andrew Belashov <bel at orel dot ru> MFC after: 3 days Notes: svn path=/head/; revision=161579
* soreceive_generic(), and sopoll_generic(). Add new functions sosend(),Robert Watson2006-07-241-5/+4
| | | | | | | | | | | | | | | | | | | soreceive(), and sopoll(), which are wrappers for pru_sosend, pru_soreceive, and pru_sopoll, and are now used univerally by socket consumers rather than either directly invoking the old so*() functions or directly invoking the protocol switch method (about an even split prior to this commit). This completes an architectural change that was begun in 1996 to permit protocols to provide substitute implementations, as now used by UDP. Consumers now uniformly invoke sosend(), soreceive(), and sopoll() to perform these operations on sockets -- in particular, distributed file systems and socket system calls. Architectural head nod: sam, gnn, wollman Notes: svn path=/head/; revision=160619
* Change semantics of socket close and detach. Add a new protocol switchRobert Watson2006-07-215-5/+35
| | | | | | | | | | | | | | | | | | | | | | function, pru_close, to notify protocols that the file descriptor or other consumer of a socket is closing the socket. pru_abort is now a notification of close also, and no longer detaches. pru_detach is no longer used to notify of close, and will be called during socket tear-down by sofree() when all references to a socket evaporate after an earlier call to abort or close the socket. This means detach is now an unconditional teardown of a socket, whereas previously sockets could persist after detach of the protocol retained a reference. This faciliates sharing mutexes between layers of the network stack as the mutex is required during the checking and removal of references at the head of sofree(). With this change, pru_detach can now assume that the mutex will no longer be required by the socket layer after completion, whereas before this was not necessarily true. Reviewed by: gnn Notes: svn path=/head/; revision=160549
* Add new SIOC_HCI_RAW_NODE_LIST_NAMES ioctl. User-space applications canMaksim Yevmenkin2006-05-171-1/+64
| | | | | | | | | | | | | | | | use this ioctl to obtain the list of HCI nodes. User-space application is expected to preallocate 'ng_btsocket_hci_raw_node_list_names' structure and set limit in 'num_nodes' field. The 'nodes' field should be allocated as well and it should have space for at least 'num_nodes' elements. The SIOC_HCI_RAW_NODE_LIST_NAMES should be issued on bound raw HCI socket. It does not really really matter what HCI name the socket is bound to, as long as it is not empty. MFC after: 1 week Notes: svn path=/head/; revision=158672
* Chance protocol switch method pru_detach() so that it returns voidRobert Watson2006-04-014-35/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | rather than an error. Detaches do not "fail", they other occur or the protocol flags SS_PROTOREF to take ownership of the socket. soclose() no longer looks at so_pcb to see if it's NULL, relying entirely on the protocol to decide whether it's time to free the socket or not using SS_PROTOREF. so_pcb is now entirely owned and managed by the protocol code. Likewise, no longer test so_pcb in other socket functions, such as soreceive(), which have no business digging into protocol internals. Protocol detach routines no longer try to free the socket on detach, this is performed in the socket code if the protocol permits it. In rts_detach(), no longer test for rp != NULL in detach, and likewise in other protocols that don't permit a NULL so_pcb, reduce the incidence of testing for it during detach. netinet and netinet6 are not fully updated to this change, which will be in an upcoming commit. In their current state they may leak memory or panic. MFC after: 3 months Notes: svn path=/head/; revision=157370
* Change protocol switch pru_abort() API so that it returns void ratherRobert Watson2006-04-014-8/+8
| | | | | | | | | | | | | | | | | than an int, as an error here is not meaningful. Modify soabort() to unconditionally free the socket on the return of pru_abort(), and modify most protocols to no longer conditionally free the socket, since the caller will do this. This commit likely leaves parts of netinet and netinet6 in a situation where they may panic or leak memory, as they have not are not fully updated by this commit. This will be corrected shortly in followup commits to these components. MFC after: 3 months Notes: svn path=/head/; revision=157366
* Use sparse initializers for "struct domain" and "struct protosw",Ruslan Ermilov2005-11-091-55/+31
| | | | | | | so they are easier to follow for the human being. Notes: svn path=/head/; revision=152242