#
9535efc0 |
| 18-Jun-2004 |
Robert Watson <rwatson@FreeBSD.org> |
Merge additional socket buffer locking from rwatson_netperf:
- Lock down low hanging fruit use of sb_flags with socket buffer lock.
- Lock down low hanging fruit use of so_state with socket lock.
Merge additional socket buffer locking from rwatson_netperf:
- Lock down low hanging fruit use of sb_flags with socket buffer lock.
- Lock down low hanging fruit use of so_state with socket lock.
- Lock down low hanging fruit use of so_options.
- Lock down low-hanging fruit use of sb_lowwat and sb_hiwat with socket buffer lock.
- Annotate situations in which we unlock the socket lock and then grab the receive socket buffer lock, which are currently actually the same lock. Depending on how we want to play our cards, we may want to coallesce these lock uses to reduce overhead.
- Convert a if()->panic() into a KASSERT relating to so_state in soaccept().
- Remove a number of splnet()/splx() references.
More complex merging of socket and socket buffer locking to follow.
show more ...
|
#
c0b99ffa |
| 14-Jun-2004 |
Robert Watson <rwatson@FreeBSD.org> |
The socket field so_state is used to hold a variety of socket related flags relating to several aspects of socket functionality. This change breaks out several bits relating to send and receive oper
The socket field so_state is used to hold a variety of socket related flags relating to several aspects of socket functionality. This change breaks out several bits relating to send and receive operation into a new per-socket buffer field, sb_state, in order to facilitate locking. This is required because, in order to provide more granular locking of sockets, different state fields have different locking properties. The following fields are moved to sb_state:
SS_CANTRCVMORE (so_state) SS_CANTSENDMORE (so_state) SS_RCVATMARK (so_state)
Rename respectively to:
SBS_CANTRCVMORE (so_rcv.sb_state) SBS_CANTSENDMORE (so_snd.sb_state) SBS_RCVATMARK (so_rcv.sb_state)
This facilitates locking by isolating fields to be located with other identically locked fields, and permits greater granularity in socket locking by avoiding storing fields with different locking semantics in the same short (avoiding locking conflicts). In the future, we may wish to coallesce sb_state and sb_flags; for the time being I leave them separate and there is no additional memory overhead due to the packing/alignment of shorts in the socket buffer structure.
show more ...
|
#
395a08c9 |
| 12-Jun-2004 |
Robert Watson <rwatson@FreeBSD.org> |
Extend coverage of SOCK_LOCK(so) to include so_count, the socket reference count:
- Assert SOCK_LOCK(so) macros that directly manipulate so_count: soref(), sorele().
- Assert SOCK_LOCK(so) in mac
Extend coverage of SOCK_LOCK(so) to include so_count, the socket 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
show more ...
|
#
2658b3bb |
| 02-Jun-2004 |
Robert Watson <rwatson@FreeBSD.org> |
Integrate accept locking from rwatson_netperf, introducing a new global mutex, accept_mtx, which serializes access to the following fields across all sockets:
so_qlen so_incqlen
Integrate accept locking from rwatson_netperf, introducing a new global mutex, accept_mtx, which serializes access to the following fields across all sockets:
so_qlen so_incqlen so_qstate so_comp so_incomp so_list so_head
While providing only coarse granularity, this approach avoids lock order issues between sockets by avoiding ownership of the fields by a specific socket and its per-socket mutexes.
While here, rewrite soclose(), sofree(), soaccept(), and sonewconn() to add assertions, close additional races and address lock order concerns. In particular:
- Reorganize the optimistic concurrency behavior in accept1() to always allocate a file descriptor with falloc() so that if we do find a socket, we don't have to encounter the "Oh, there wasn't a socket" race that can occur if falloc() sleeps in the current code, which broke inbound accept() ordering, not to mention requiring backing out socket state changes in a way that raced with the protocol level. We may want to add a lockless read of the queue state if polling of empty queues proves to be important to optimize.
- In accept1(), soref() the socket while holding the accept lock so that the socket cannot be free'd in a race with the protocol layer. Likewise in netgraph equivilents of the accept1() code.
- In sonewconn(), loop waiting for the queue to be small enough to insert our new socket once we've committed to inserting it, or races can occur that cause the incomplete socket queue to overfill. In the previously implementation, it was sufficient to simply tested once since calling soabort() didn't release synchronization permitting another thread to insert a socket as we discard a previous one.
- In soclose()/sofree()/et al, it is the responsibility of the caller to remove a socket from the incomplete connection queue before calling soabort(), which prevents soabort() from having to walk into the accept socket to release the socket from its queue, and avoids races when releasing the accept mutex to enter soabort(), permitting soabort() to avoid lock ordering issues with the caller.
- Generally cluster accept queue related operations together throughout these functions in order to facilitate locking.
Annotate new locking in socketvar.h.
show more ...
|
#
36568179 |
| 01-Jun-2004 |
Robert Watson <rwatson@FreeBSD.org> |
The SS_COMP and SS_INCOMP flags in the so_state field indicate whether the socket is on an accept queue of a listen socket. This change renames the flags to SQ_COMP and SQ_INCOMP, and moves them to
The SS_COMP and SS_INCOMP flags in the so_state field indicate whether the socket is on an accept queue of a listen socket. This change renames the flags to SQ_COMP and SQ_INCOMP, and moves them to a new state field on the socket, so_qstate, as the locking for these flags is substantially different for the locking on the remainder of the flags in so_state.
show more ...
|
#
f8aae777 |
| 29-May-2004 |
Julian Elischer <julian@FreeBSD.org> |
Switch to using C99 sparse initialisers for the type methods array. Should make no binary difference.
Submitted by: Gleb Smirnoff <glebius@cell.sick.ru> Reviewed by: Harti Brandt <harti@freebsd.org>
Switch to using C99 sparse initialisers for the type methods array. Should make no binary difference.
Submitted by: Gleb Smirnoff <glebius@cell.sick.ru> Reviewed by: Harti Brandt <harti@freebsd.org> MFC after: 1 week
show more ...
|
Revision tags: release/4.10.0_cvs, release/4.10.0, release/5.2.1_cvs, release/5.2.1 |
|
#
87e2c66a |
| 26-Jan-2004 |
Hartmut Brandt <harti@FreeBSD.org> |
Get rid of the deprecated *LEN constants in favour of the new *SIZ constants that include the trailing \0 byte.
|
Revision tags: release/5.2.0_cvs, release/5.2.0 |
|
#
7304a833 |
| 17-Dec-2003 |
Ruslan Ermilov <ru@FreeBSD.org> |
Replaced two bzero() calls with the M_ZERO flag to malloc().
Reviewed by: julian
|
Revision tags: release/4.9.0_cvs, release/4.9.0 |
|
#
33583c6f |
| 21-Aug-2003 |
Jeffrey Hsu <hsu@FreeBSD.org> |
Add Protocol Independent Multicast protocol.
Submitted by: Pavlin Radoslavov <pavlin@icir.org>
|
Revision tags: release/5.1.0_cvs, release/5.1.0 |
|
#
7d780740 |
| 28-Apr-2003 |
Archie Cobbs <archie@FreeBSD.org> |
Add missing braces.
Submitted by: Andrew Lankford <arlankfo@141.com>
|
Revision tags: release/4.8.0_cvs, release/4.8.0, release/5.0.0_cvs, release/5.0.0, release/4.7.0_cvs |
|
#
fcfa0b48 |
| 14-Sep-2002 |
Benno Rice <benno@FreeBSD.org> |
Reference the socket we're accepting.
|
#
a7d83226 |
| 11-Sep-2002 |
Benno Rice <benno@FreeBSD.org> |
Remember who asked for a connect or accept operation so we can actually tell them when it's done.
Reviewed by: archie
|
#
facfd889 |
| 22-Aug-2002 |
Archie Cobbs <archie@FreeBSD.org> |
Don't use "NULL" when "0" is really meant.
|
Revision tags: release/4.6.2_cvs, release/4.6.2, release/4.6.1, release/4.6.0_cvs |
|
#
f0184ff8 |
| 01-Jun-2002 |
Archie Cobbs <archie@FreeBSD.org> |
Fix GCC warnings caused by initializing a zero length array. In the process, simply things a bit by getting rid of 'struct ng_parse_struct_info' which was useless because it only contained one field.
Fix GCC warnings caused by initializing a zero length array. In the process, simply things a bit by getting rid of 'struct ng_parse_struct_info' which was useless because it only contained one field.
MFC after: 2 weeks
show more ...
|
#
4cc20ab1 |
| 31-May-2002 |
Seigo Tanimura <tanimura@FreeBSD.org> |
Back out my lats commit of locking down a socket, it conflicts with hsu's work.
Requested by: hsu
|
#
243917fe |
| 20-May-2002 |
Seigo Tanimura <tanimura@FreeBSD.org> |
Lock down a socket, milestone 1.
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
Lock down a socket, milestone 1.
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
show more ...
|
#
a854ed98 |
| 27-Feb-2002 |
John Baldwin <jhb@FreeBSD.org> |
Simple p_ucred -> td_ucred changes to start using the per-thread ucred reference.
|
#
079b7bad |
| 07-Feb-2002 |
Julian Elischer <julian@FreeBSD.org> |
Pre-KSE/M3 commit. this is a low-functionality change that changes the kernel to access the main thread of a process via the linked list of threads rather than assuming that it is embedded in the pro
Pre-KSE/M3 commit. this is a low-functionality change that changes the kernel to access the main thread of a process via the linked list of threads rather than assuming that it is embedded in the process. It IS still embeded there but remove all teh code that assumes that in preparation for the next commit which will actually move it out.
Reviewed by: peter@freebsd.org, gallatin@cs.duke.edu, benno rice,
show more ...
|
Revision tags: release/4.5.0_cvs, release/4.4.0_cvs |
|
#
dc9c2e01 |
| 06-Jan-2002 |
Archie Cobbs <archie@FreeBSD.org> |
Avoid reentrantly sending on the same socket, which causes a kernel panic.
|
#
9c4d63da |
| 31-Dec-2001 |
Robert Watson <rwatson@FreeBSD.org> |
o Make the credential used by socreate() an explicit argument to socreate(), rather than getting it implicitly from the thread argument.
o Make NFS cache the credential provided at mount-time, a
o Make the credential used by socreate() an explicit argument to socreate(), rather than getting it implicitly from the thread argument.
o Make NFS cache the credential provided at mount-time, and use the cached credential (nfsmount->nm_cred) when making calls to socreate() on initially connecting, or reconnecting the socket.
This fixes bugs involving NFS over TCP and ipfw uid/gid rules, as well as bugs involving NFS and mandatory access control implementations.
Reviewed by: freebsd-arch
show more ...
|
#
6e551fb6 |
| 10-Dec-2001 |
David E. O'Brien <obrien@FreeBSD.org> |
Update to C99, s/__FUNCTION__/__func__/, also don't use ANSI string concatenation.
|
#
19ff9e5f |
| 28-Nov-2001 |
Archie Cobbs <archie@FreeBSD.org> |
When a socket is not connected, allow the peer "struct sockaddr" to be included in the meta information that is associated with incoming and outgoing packets.
Reviewed by: julian MFC after: 1 week
|
#
129bc895 |
| 10-Oct-2001 |
Archie Cobbs <archie@FreeBSD.org> |
Let "raw" mean IPPROTO_RAW instead of IPPROTO_IP.
Noticed by: jdp MFC after: 3 days
|
#
b40ce416 |
| 12-Sep-2001 |
Julian Elischer <julian@FreeBSD.org> |
KSE Milestone 2 Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is fu
KSE Milestone 2 Note ALL MODULES MUST BE RECOMPILED make the kernel aware that there are smaller units of scheduling than the process. (but only allow one thread per process at this time). This is functionally equivalent to teh previousl -current except that there is a thread associated with each process.
Sorry john! (your next MFC will be a doosie!)
Reviewed by: peter@freebsd.org, dillon@freebsd.org
X-MFC after: ha ha ha ha
show more ...
|
#
f97e0a07 |
| 07-Sep-2001 |
Julian Elischer <julian@FreeBSD.org> |
First pass at porting John's "accept" changes to allow an in-kernel webserver (or similar) to accept and handle incoming connections using netgraph without ever leaving the kernel. (allows incoming t
First pass at porting John's "accept" changes to allow an in-kernel webserver (or similar) to accept and handle incoming connections using netgraph without ever leaving the kernel. (allows incoming tunnel requests to be handled totally within the kernel for example)
Needs work, but shouldn't break existing functionality.
Submitted by: John Polstra <jdp@polstra.com> MFC after: 2 weeks
show more ...
|