summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_socket2.c
Commit message (Collapse)AuthorAgeFilesLines
* Introduce a MAC label reference in 'struct inpcb', which cachesrwatson2003-11-181-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | the MAC label referenced from 'struct socket' in the IPv4 and IPv6-based protocols. This permits MAC labels to be checked during network delivery operations without dereferencing inp->inp_socket to get to so->so_label, which will eventually avoid our having to grab the socket lock during delivery at the network layer. This change introduces 'struct inpcb' as a labeled object to the MAC Framework, along with the normal circus of entry points: initialization, creation from socket, destruction, as well as a delivery access control check. For most policies, the inpcb label will simply be a cache of the socket label, so a new protocol switch method is introduced, pr_sosetlabel() to notify protocols that the socket layer label has been updated so that the cache can be updated while holding appropriate locks. Most protocols implement this using pru_sosetlabel_null(), but IPv4/IPv6 protocols using inpcbs use the the worker function in_pcbsosetlabel(), which calls into the MAC Framework to perform a cache update. Biba, LOMAC, and MLS implement these entry points, as do the stub policy, and test policy. Reviewed by: sam, bms Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
* - Implement selwakeuppri() which allows raising the priority of atanimura2003-11-091-1/+1
| | | | | | | | | | | | | thread being waken up. The thread waken up can run at a priority as high as after tsleep(). - Replace selwakeup()s with selwakeuppri()s and pass appropriate priorities. - Add cv_broadcastpri() which raises the priority of the broadcast threads. Used by selwakeuppri() if collision occurs. Not objected in: -arch, -current
* speedup stream socket recv handling by tracking the tail ofsam2003-10-281-19/+143
| | | | | | | the mbuf chain instead of walking the list for each append Submitted by: ps/jayanth Obtained from: netbsd (jason thorpe)
* Change all SYSCTLS which are readonly and have a related TUNABLEsilby2003-10-211-1/+1
| | | | | from CTLFLAG_RD to CTLFLAG_RDTUN so that sysctl(8) can provide more useful error messages.
* Guard against MLEN growing larger than a uint8_t due to MSIZE grwoing to ascottl2003-07-261-0/+2
| | | | value of 512 in LINT. This keeps gcc from complaining.
* Use __FBSDID().obrien2003-06-111-1/+3
|
* Fix some easy, global, lint warnings. In most cases, this meansmarkm2003-04-301-1/+1
| | | | | making some local variables static. In a couple of cases, this means removing an unused variable.
* Missing M_TRYWAIT from so_upcall third argument.peter2003-02-211-1/+1
|
* Back out M_* changes, per decision of the TRB.imp2003-02-191-5/+5
| | | | Approved by: trb
* Make the variable types, the sysctl macros and the sysctl handler forharti2003-02-031-5/+5
| | | | | | | | kern.ipc.{maxsockbuf,sockbuf_waste_factor} to agree that those variables are of type unsigned long. PR: sparc64/47389 Approved by: jake (mentor)
* Remove M_TRYWAIT/M_WAITOK/M_WAIT. Callers should use 0.alfred2003-01-211-5/+5
| | | | Merge M_NOWAIT/M_DONTWAIT into a single flag M_NOWAIT.
* Don't count mbufs with m_type == MT_HEADER or MT_OOBDATA as control datatjr2003-01-111-2/+5
| | | | | in sballoc(), sbcompress(), sbdrop() and sbfree(). Fixes fstat() st_size reporting and kevent() EVFILT_READ on TCP sockets.
* Spotted a couple of places where the socket buffer's counters were beingkbyanc2002-11-051-0/+4
| | | | | | | manipulated directly (rather than using sballoc()/sbfree()); update them to tweak the new sb_ctl field too. Sponsored by: NTT Multimedia Communications Labs
* Revert the change in revision 1.77 of kern/uipc_socket2.c. It is causingalc2002-11-021-1/+1
| | | | | | a panic because the socket's state isn't as expected by sofree(). Discussed with: dillon, fenner
* 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>
OpenPOWER on IntegriCloud