summaryrefslogtreecommitdiffstats
path: root/sys/net/raw_cb.c
Commit message (Collapse)AuthorAgeFilesLines
* raw_disconnect() now disconnects but does not detach the raw pcb. As arwatson2006-06-021-3/+1
| | | | | | | | | | result, raw_uabort() now needs to call raw_detach() directly. As raw_uabort() is never called, and raw_disconnect() is probably not ever actually called in practice, this is likely not a functional change, but improves congruence between protocols, and avoids a NULL raw cb pointer after disconnect, which could result in a panic. MFC after: 1 month
* Chance protocol switch method pru_detach() so that it returns voidrwatson2006-04-011-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* Acquire the raw_cb mutex around LIST_REMOVE() of a raw socket controlrwatson2005-01-241-0/+2
| | | | | | | block from the global raw socket list. Submitted by: Roselyn Lee <rosel at verniernetworks dot com> MFC after: 1 week
* /* -> /*- for license, minor formatting changesimp2005-01-071-1/+1
|
* Push acquisition of the accept mutex out of sofree() into the callerrwatson2004-10-181-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (sorele()/sotryfree()): - This permits the caller to acquire the accept mutex before the socket mutex, avoiding sofree() having to drop the socket mutex and re-order, which could lead to races permitting more than one thread to enter sofree() after a socket is ready to be free'd. - This also covers clearing of the so_pcb weak socket reference from the protocol to the socket, preventing races in clearing and evaluation of the reference such that sofree() might be called more than once on the same socket. This appears to close a race I was able to easily trigger by repeatedly opening and resetting TCP connections to a host, in which the tcp_close() code called as a result of the RST raced with the close() of the accepted socket in the user process resulting in simultaneous attempts to de-allocate the same socket. The new locking increases the overhead for operations that may potentially free the socket, so we will want to revise the synchronization strategy here as we normalize the reference counting model for sockets. The use of the accept mutex in freeing of sockets that are not listen sockets is primarily motivated by the potential need to remove the socket from the incomplete connection queue on its parent (listen) socket, so cleaning up the reference model here may allow us to substantially weaken the synchronization requirements. RELENG_5_3 candidate. MFC after: 3 days Reviewed by: dwhite Discussed with: gnn, dwhite, green Reported by: Marc UBM Bocklet <ubm at u-boot-man dot de> Reported by: Vlad <marchenko at gmail dot com>
* Lock down rawcb_list, a global list of control blocks for raw sockets,rwatson2004-06-151-0/+3
| | | | | | | | | | | using rawcb_mtx. Hold this mutex while modifying or iterating over the control list; this means that the mutex is held over calls into socket delivery code, which no longer causes a lock order reversal as the routing socket code uses a netisr to avoid recursing socket -> routing -> socket. Note: Locking of IPsec consumers of rawcb_list is not included in this commit.
* Extend coverage of SOCK_LOCK(so) to include so_count, the socketrwatson2004-06-121-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | reference count: - Assert SOCK_LOCK(so) macros that directly manipulate so_count: soref(), sorele(). - Assert SOCK_LOCK(so) in macros/functions that rely on the state of so_count: sofree(), sotryfree(). - Acquire SOCK_LOCK(so) before calling these functions or macros in various contexts in the stack, both at the socket and protocol layers. - In some cases, perform soisdisconnected() before sotryfree(), as this could result in frobbing of a non-present socket if sotryfree() actually frees the socket. - Note that sofree()/sotryfree() will release the socket lock even if they don't free the socket. Submitted by: sam Sponsored by: FreeBSD Foundation Obtained from: BSD/OS
* Constify raw_sendspace and raw_recvspace, as they're not mutable.rwatson2004-06-111-2/+2
|
* Remove advertising clause from University of California Regent'simp2004-04-071-4/+0
| | | | | | | license, per letter dated July 22, 1999 and email from Peter Wemm, Alan Cox and Robert Watson. Approved by: core, peter, alc, rwatson
* Back out M_* changes, per decision of the TRB.imp2003-02-191-1/+1
| | | | Approved by: trb
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.alfred2003-01-211-1/+1
| | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
* o Untangle the confusion with the malloc flags {M_WAITOK, M_NOWAIT} andbmilekic2002-12-191-1/+1
| | | | | | | | | | the mbuf allocator flags {M_TRYWAIT, M_DONTWAIT}. o Fix a bpf_compat issue where malloc() was defined to just call bpf_alloc() and pass the 'canwait' flag(s) along. It's been changed to call bpf_alloc() but pass the corresponding M_TRYWAIT or M_DONTWAIT flag (and only one of those two). Submitted by: Hiten Pandya <hiten@unixdaemons.com> (hiten->commit_count++)
* Back out some style changes. They are not urgent,luigi2002-11-201-5/+11
| | | | | | | I will put them back in after 5.0 is out. Requested by: sam Approved by: re
* Fix function headers, remove 'register' from variable declarations.luigi2002-11-171-11/+5
|
* Back out my lats commit of locking down a socket, it conflicts with hsu's work.tanimura2002-05-311-8/+1
| | | | Requested by: hsu
* Include <sys.systm.h> for the declaration of some atomic functions -- don'tbde2002-05-221-0/+1
| | | | depend on namespace pollution in <sys/mutex.h>.
* Lock down a socket, milestone 1.tanimura2002-05-201-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | o Add a mutex (sb_mtx) to struct sockbuf. This protects the data in a socket buffer. The mutex in the receive buffer also protects the data in struct socket. o Determine the lock strategy for each members in struct socket. o Lock down the following members: - so_count - so_options - so_linger - so_state o Remove *_locked() socket APIs. Make the following socket APIs touching the members above now require a locked socket: - sodisconnect() - soisconnected() - soisconnecting() - soisdisconnected() - soisdisconnecting() - sofree() - soref() - sorele() - sorwakeup() - sotryfree() - sowakeup() - sowwakeup() Reviewed by: alfred
* Give struct socket structures a ref counting interface similar todillon2001-11-171-1/+1
| | | | | | | vnodes. This will hopefully serve as a base from which we can expand the MP code. We currently do not attempt to obtain any mutex or SX locks, but the door is open to add them when we nail down exactly how that part of it is going to work.
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Added a used include (in ifdefed code).bde1998-06-071-1/+3
|
* Removed unused #includes.bde1997-10-281-8/+1
|
* Added used #include - don't depend on <sys/mbuf.h> includingbde1997-09-021-1/+2
| | | | <sys/malloc.h> (unless we only use the bogusly shared M*WAIT flags).
* The long-awaited mega-massive-network-code- cleanup. Part I.wollman1997-04-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | This commit includes the following changes: 1) Old-style (pr_usrreq()) protocols are no longer supported, the compatibility glue for them is deleted, and the kernel will panic on boot if any are compiled in. 2) Certain protocol entry points are modified to take a process structure, so they they can easily tell whether or not it is possible to sleep, and also to access credentials. 3) SS_PRIV is no more, and with it goes the SO_PRIVSTATE setsockopt() call. Protocols should use the process pointer they are now passed. 4) The PF_LOCAL and PF_ROUTE families have been updated to use the new style, as has the `raw' skeleton family. 5) PF_LOCAL sockets now obey the process's umask when creating a socket in the filesystem. As a result, LINT is now broken. I'm hoping that some enterprising hacker with a bit more time will either make the broken bits work (should be easy for netipx) or dike them out.
* Use LIST macros instead of insque/remquephk1997-04-141-4/+5
|
* Back out part 1 of the MCFH that changed $Id$ to $FreeBSD$. We are notpeter1997-02-221-1/+1
| | | | ready for it yet.
* Make the long-awaited change from $Id$ to $FreeBSD$jkh1997-01-141-1/+1
| | | | | | | | This will make a number of things easier in the future, as well as (finally!) avoiding the Id-smashing problem which has plagued developers for so long. Boy, I'm glad we're not using sup anymore. This update would have been insane otherwise.
* Move or add #include <queue.h> in preparation for upcoming struct socketdg1996-03-111-2/+2
| | | | changes.
* Another mega commit to staticize things.phk1995-12-141-3/+3
|
* Moved inline functions for insque() and remque() to <sys/queue.h>.bde1995-12-031-1/+2
| | | | | | | Protected them with `#ifdef KERNEL' so that <sys/queue.h> is valid C++. Added the necessary #includes of <sys/queue.h>. These functions are bogus and should be replaced by the queue macros.
* Eliminate sloppy common-style declarations. There should be none left forbde1995-07-291-1/+2
| | | | the LINT configuation.
* Remove trailing whitespace.rgrimes1995-05-301-2/+2
|
* Cosmetics: to silence gcc -wall.phk1994-10-081-2/+3
|
* Added $Id$dg1994-08-021-0/+1
|
* BSD 4.4 Lite Kernel Sourcesrgrimes1994-05-241-0/+144
OpenPOWER on IntegriCloud