summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_sockbuf.c
Commit message (Collapse)AuthorAgeFilesLines
* Use m_length() instead of home-rolled versions.phk2002-09-181-21/+10
|
* Further improved the performance of sbreserve() by moving the calculationdg2002-08-161-5/+26
| | | | | | of the adjusted sb_max into a sysctl handler for sb_max and assigning it to a variable that is used instead. This eliminates the 32bit multiply and divide from the fast path that was being done previously.
* Rewrote the space check algorithm in sbreserve() so that the extremelydg2002-08-161-1/+1
| | | | | | | | | | | | | | expensive (!) 64bit multiply, divide, and comparison aren't necessary (this came in originally from rev 1.19 to fix an overflow with large sb_max or MCLBYTES). The 64bit math in this function was measured in some kernel profiles as being as much as 5-8% of the total overhead of the TCP/IP stack and is eliminated with this commit. There is a harmless rounding error (of about .4% with the standard values) introduced with this change, however this is in the conservative direction (downward toward a slightly smaller maximum socket buffer size). MFC after: 3 days
* Include file cleanup; mac.h and malloc.h at one point had orderingrwatson2002-08-011-1/+1
| | | | | | relationship requirements, and no longer do. Reminded by: bde
* Introduce support for Mandatory Access Control and extensiblerwatson2002-07-311-0/+6
| | | | | | | | | | | | | | | kernel access control. Invoke the necessary MAC entry points to maintain labels on sockets. In particular, invoke entry points during socket allocation and destruction, as well as creation by a process or during an accept-scenario (sonewconn). For UNIX domain sockets, also assign a peer label. As the socket code isn't locked down yet, locking interactions are not yet clear. Various protocol stack socket operations (such as peer label assignment for IPv4) will follow. Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs
* If a socket is disconnected for some reason (like a TCP connectiondwmalone2002-07-271-0/+1
| | | | | | | | | | not responding) then drop any data on the outgoing queue in soisdisconnected because there is no way to get it to its destination any longer. The only objection to this patch I got on -net was from Terry, who wasn't sure that the condition in question could arise, so I provided some example code.
* Fix -Werror build for sparc64: Use the appropriate conversionrobert2002-07-261-1/+1
| | | | specifier for an 'unsigned int' argument.
* More caddr_t removal.alfred2002-06-291-7/+7
| | | | Change struct knote's kn_hook from caddr_t to void *.
* Remove so*_locked(), which were backed out by mistake.tanimura2002-06-181-51/+11
|
* Back out my lats commit of locking down a socket, it conflicts with hsu's work.tanimura2002-05-311-68/+59
| | | | Requested by: hsu
* Subtle fix to the accept filter LRU code. In some cases, a newlysilby2002-05-201-1/+1
| | | | | | | | | | initialized socket with no qlimit was being passed in. In order to handle this case properly, we must not use >= when comparing queue sizes to qlimit. As a result of this improper handling, a panic could result in certain cases. PR: 38325 MFC after: 3 days
* Lock down a socket, milestone 1.tanimura2002-05-201-59/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Do not forget to increase the number of completely connected sockets intanimura2002-05-071-0/+1
| | | | | | soisconnected_locked(). Forgotten by: tanimura
* Redo the sigio locking.alfred2002-05-011-20/+1
| | | | | | | | | | | Turn the sigio sx into a mutex. Sigio lock is really only needed to protect interrupts from dereferencing the sigio pointer in an object when the sigio itself is being destroyed. In order to do this in the most unintrusive manner change pgsigio's sigio * argument into a **, that way we can lock internally to the function.
* Revert the change of #includes in sys/filedesc.h and sys/socketvar.h.tanimura2002-04-301-6/+7
| | | | | | | | | | Requested by: bde Since locking sigio_lock is usually followed by calling pgsigio(), move the declaration of sigio_lock and the definitions of SIGIO_*() to sys/signalvar.h. While I am here, sort include files alphabetically, where possible.
* Fix the code fragment clobbered in my last commit.tanimura2002-04-271-0/+2
|
* Add a global sx sigio_lock to protect the pointer to the sigio objecttanimura2002-04-271-13/+69
| | | | | | | | | | of a socket. This avoids lock order reversal caused by locking a process in pgsigio(). sowakeup() and the callers of it (sowwakeup, soisconnected, etc.) now require sigio_lock to be locked. Provide sowwakeup_locked(), soisconnected_locked(), and so on in case where we have to modify a socket and wake up a process atomically.
* Make sure that sockets undergoing accept filtering are aborted in asilby2002-04-261-1/+7
| | | | | | | | | LRU fashion when the listen queue fills up. Previously, there was no mechanism to kick out old sockets, leading to an easy DoS of daemons using accept filtering. Reviewed by: alfred MFC after: 3 days
* Remove sodropablereq - this function hasn't been used since thesilby2002-04-241-44/+0
| | | | | | syncache went in. MFC after: 3 days
* Backout part of my previous commit; I was wrong about vm_zone's handling ofjeff2002-03-201-0/+14
| | | | limits on zones w/o objects.
* Remove references to vm_zone.h and switch over to the new uma API.jeff2002-03-201-14/+0
| | | | | Also, remove maxsockets. If you look carefully you'll notice that the old zone allocator never honored this anyway.
* Get rid of the twisted MFREE() macro entirely.dillon2002-02-051-8/+5
| | | | | Reviewed by: dg, bmilekic MFC after: 3 days
* Revert 1.81; 1.19 fixed this already in a different way.silby2002-01-091-3/+1
|
* Reorder a calculation in sbreserve so that it does not overflowsilby2002-01-061-1/+3
| | | | | | | with multi-megabyte socket buffer sizes. PR: 7420 MFC after: 3 weeks
* Make AIO a loadable module.alfred2001-12-291-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | Remove the explicit call to aio_proc_rundown() from exit1(), instead AIO will use at_exit(9). Add functions at_exec(9), rm_at_exec(9) which function nearly the same as at_exec(9) and rm_at_exec(9), these functions are called on behalf of modules at the time of execve(2) after the image activator has run. Use a modified version of tegge's suggestion via at_exec(9) to close an exploitable race in AIO. Fix SYSCALL_MODULE_HELPER such that it's archetecuterally neutral, the problem was that one had to pass it a paramater indicating the number of arguments which were actually the number of "int". Fix it by using an inline version of the AS macro against the syscall arguments. (AS should be available globally but we'll get to that later.) Add a primative system for dynamically adding kqueue ops, it's really not as sophisticated as it should be, but I'll discuss with jlemon when he's around.
* Avoid an interaction between syncache and accept filters. The syncachepeter2001-12-211-0/+2
| | | | | | | | code only passed up the connection to the tcp stack when it was complete, so it went directly into the so_comp (complete) queue. However, with accept filters, there is an additional phase before calling it "complete". Reviewed by: jlemon
* o Back out portions of 1.50 and 1.47, eliminating sonewconn3() andrwatson2001-12-131-14/+1
| | | | | | | | | | | | always deriving the credential for a newly accepted connection from the listen socket. Previously, the selection of the credential depended on the protocol: UNIX domain sockets would use the connecting process's credential, and protocols supporting a creation of the socket before the receiving end called accept() would use the listening socket. After this change, it is always the listening credential. Reviewed by: green
* Give struct socket structures a ref counting interface similar todillon2001-11-171-1/+3
| | | | | | | 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.
* Change the kernel's ucred API as follows:jhb2001-10-111-2/+4
| | | | | | | | - crhold() returns a reference to the ucred whose refcount it bumps. - crcopy() now simply copies the credentials from one credential to another and has no return value. - a new crshared() primitive is added which returns true if a ucred's refcount is > 1 and false (0) otherwise.
* Allow sbcreatecontrol to make cluster sized control messages.dwmalone2001-10-041-3/+13
|
* KSE Milestone 2julian2001-09-121-13/+13
| | | | | | | | | | | | | | 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
* Fix up indentation.jlemon2001-06-291-2/+2
|
* "Fix" the previous initial attempt at fixing TUNABLE_INT(). This timepeter2001-06-081-1/+1
| | | | | | | around, use a common function for looking up and extracting the tunables from the kernel environment. This saves duplicating the same function over and over again. This way typically has an overhead of 8 bytes + the path string, versus about 26 bytes + the path string.
* Back out part of my previous commit. This was a last minute changepeter2001-06-071-1/+1
| | | | | and I botched testing. This is a perfect example of how NOT to do this sort of thing. :-(
* Make the TUNABLE_*() macros look and behave more consistantly like thepeter2001-06-061-2/+2
| | | | | SYSCTL_*() macros. TUNABLE_INT_DECL() was an odd name because it didn't actually declare the int, which is what the name suggests it would do.
* Revert the last bits of my bogus move of NMBCLUSTERSjesper2001-06-011-0/+1
| | | | to <sys/param.h>
* Move the definition of NMBCLUSTERS from src/sys/kern/uipc_mbuf.cjesper2001-05-311-1/+0
| | | | | | | to <sys/param.h>, so it's available to src/sys/netinet/ip_input.c, and remove the now unneeded includes of "opt_param.h". MFC after: 1 week
* Undo part of the tangle of having sys/lock.h and sys/mutex.h included inmarkm2001-05-011-1/+3
| | | | | | | | | | | other "system" header files. Also help the deprecation of lockmgr.h by making it a sub-include of sys/lock.h and removing sys/lockmgr.h form kernel .c files. Sort sys/*.h includes where possible in affected files. OK'ed by: bde (with reservations)
* Make sbcompress use the new M_WRITABLE macro. Previously sbcompressdwmalone2000-11-191-2/+4
| | | | | | | | | | | | | | could not compress into clusters. This could result in lots of wasted clusters while recieving small packets from an interface that uses clusters for all it's packets. Patch is partially from BSDi (limiting the size of the copy) and based on a patch for 4.1 by Ian Dowse <iedowse@maths.tcd.ie> and myself. Reviewed by: bmilekic Obtained From: BSDi Submitted by: iedowse
* Remove uidinfo hash table lookup and maintenance out of chgproccnt() andtruckman2000-09-051-2/+3
| | | | | | | | | | | | | | chgsbsize(), which are called rather frequently and may be called from an interrupt context in the case of chgsbsize(). Instead, do the hash table lookup and maintenance when credentials are changed, which is a lot less frequent. Add pointers to the uidinfo structures to the ucred and pcred structures for fast access. Pass a pointer to the credential to chgproccnt() and chgsbsize() instead of passing the uid. Add a reference count to the uidinfo structure and use it to decide when to free the structure rather than freeing the structure when the resource consumption drops to zero. Move the resource tracking code from kern_proc.c to kern_resource.c. Move some duplicate code sequences in kern_prot.c to separate helper functions. Change KASSERTs in this code to unconditional tests and calls to panic().
* Fix hangs caused by overzealous code removal.green2000-08-311-2/+2
| | | | | | Thanks, Nickolay, for figuring out this is the problem. Submitted by: Nickolay Dudorov <nnd@mail.nsk.ru>
* Remove an extraneous setting of sb_hiwat.green2000-08-301-1/+0
|
* Remove any possibility of hiwat-related race conditions by changinggreen2000-08-291-5/+3
| | | | | | | the chgsbsize() call to use a "subject" pointer (&sb.sb_hiwat) and a u_long target to set it to. The whole thing is splnet(). This fixes a problem that jdp has been able to provoke.
* Remove unnecessary call to splnet when setting an accept filterps2000-07-311-3/+0
| | | | since we are already at splnet.
* fix races in the uidinfo subsystem, several problems existed:alfred2000-06-221-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | 1) while allocating a uidinfo struct malloc is called with M_WAITOK, it's possible that while asleep another process by the same user could have woken up earlier and inserted an entry into the uid hash table. Having redundant entries causes inconsistancies that we can't handle. fix: do a non-waiting malloc, and if that fails then do a blocking malloc, after waking up check that no one else has inserted an entry for us already. 2) Because many checks for sbsize were done as "test then set" in a non atomic manner it was possible to exceed the limits put up via races. fix: instead of querying the count then setting, we just attempt to set the count and leave it up to the function to return success or failure. 3) The uidinfo code was inlining and repeating, lookups and insertions and deletions needed to be in their own functions for clarity. Reviewed by: green
* return of the accept filter part IIalfred2000-06-201-0/+11
| | | | | | | | | | | accept filters are now loadable as well as able to be compiled into the kernel. two accept filters are provided, one that returns sockets when data arrives the other when an http request is completed (doesn't work with 0.9 requests) Reviewed by: jmg
* backout accept optimizations.alfred2000-06-181-145/+0
| | | | Requested by: jmg, dcs, jdp, nate
* add socketoptions DELAYACCEPT and HTTPACCEPT which will not allow an accept()alfred2000-06-151-2/+147
| | | | | | | | | | | | until the incoming connection has either data waiting or what looks like a HTTP request header already in the socketbuffer. This ought to reduce the context switch time and overhead for processing requests. The initial idea and code for HTTPACCEPT came from Yahoo engineers and has been cleaned up and a more lightweight DELAYACCEPT for non-http servers has been added Reviewed by: silence on hackers.
* Introduce kqueue() and kevent(), a kernel event notification facility.jlemon2000-04-161-0/+2
|
* CMSG_XXX macros alignment fixes to follow RFC2292.shin2000-03-031-4/+3
| | | | | | | Approved by: jkh Submitted by: Partly from tech@openbsd Reviewed by: itojun
OpenPOWER on IntegriCloud