summaryrefslogtreecommitdiffstats
path: root/sys/kern/uipc_sockbuf.c
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Add length check to sbcreatecontrol().shin2000-02-241-0/+2
| | | | | | | | | | | | | | | | | | | Now this check is necessary because IPv6 source routing might use control data bigger than MLEN. (e.g. 16bytes IPv6 addr x 23 hops) Actually mbuf cluster should be used in uipc_socket.c:sbcreatecontrol() and uipc_syscalls.c:sockargs() when data size is bigger then MLEN, and such patches were already in KAME environment and have been confirmed to work well. I just forgot to merge them into 4.0, sorry. For safety, I'll postpone such patches until after 4.0 release. The effect of postponement is followings. -Ping6 source routing hops are limitted to around 6 or so. -If some apps do setsockopt IPV6_RTHDR and try to receive incoming IPv6 source routing info, it can't receive more than 6 hops source routing info. (But currently, no apps seems to be doing it.) Approved by: jkh
* Add aio_waitcomplete(). Make aio work correctly for socket descriptors.jasone2000-01-141-0/+3
| | | | | | | | Make gratuitous style(9) fixes (me, not the submitter) to make the aio code more readable. PR: kern/12053 Submitted by: Chris Sedore <cmsedore@maxwell.syr.edu>
* Implement RLIMIT_SBSIZE in the kernel. This is a per-uid sockbuf totalgreen1999-10-091-5/+21
| | | | usage limit.
* In sbflush(), don't exit the while loop too early: this can causepb1999-09-281-1/+8
| | | | | | | | | | | an empty mbuf to stay in the queue, then causing a needless panic because sb_cc == 0 and sb_mbcnt != 0. But we still need to panic rather than endlessly looping if, for some reason, sb_cc == 0 and there are non-empty mbufs in the queue. PR: kern/11988 Reviewed by: fenner
* Change so_cred's type to a ucred, not a pcred. THis makes more sense, actually.green1999-09-191-7/+16
| | | | | | Make a sonewconn3() which takes an extra argument (proc) so new sockets created with sonewconn() from a user's system call get the correct credentials, not just the parent's credentials.
* $Id$ -> $FreeBSD$peter1999-08-281-1/+1
|
* Move the initialisation/tuning of nmbclusters from param.c/machdep.cmsmith1999-07-051-3/+14
| | | | | | | | | | | | | | | into uipc_mbuf.c. This reduces three sets of identical tunable code to one set, and puts the initialisation with the mbuf code proper. Make NMBUFs tunable as well. Move the nmbclusters sysctl here as well. Move the initialisation of maxsockets from param.c to uipc_socket2.c, next to its corresponding sysctl. Use the new tunable macros for the kern.vm.kmem.size tunable (this should have been in a separate commit, whoops).
* Reviewed by: the cast of thousandsgreen1999-06-171-3/+5
| | | | | | | | | This is the change to struct sockets that gets rid of so_uid and replaces it with a much more useful struct pcred *so_cred. This is here to be able to do socket-level credential checks (i.e. IPFW uid/gid support, to be added to HEAD soon). Along with this comes an update to pidentd which greatly simplifies the code necessary to get a uid from a socket. Soon to come: a sysctl() interface to finding individual sockets' credentials.
* Update one set of comments.. s/so_q0/so_incomp/ and s/so_q/so_comp/ (that'speter1999-05-101-6/+6
| | | | incomplete and complete connections I think)
* Add sysctl descriptions to many SYSCTL_XXXsbillf1999-05-031-5/+8
| | | | | | | PR: kern/11197 Submitted by: Adrian Chadd <adrian@FreeBSD.org> Reviewed by: billf(spelling/style/minor nits) Looked at by: bde(style)
* Port NetBSD's 19990120-accept bug fix. This works around the race conditionfenner1999-01-251-2/+2
| | | | | | | | | | where select(2) can return that a listening socket has a connected socket queued, the connection is broken, and the user calls accept(2), which then blocks because there are no connections queued. Reviewed by: wollman Obtained from: NetBSD (ftp://ftp.NetBSD.ORG/pub/NetBSD/misc/security/patches/19990120-accept)
* The "easy" fixes for compiling the kernel -Wunused: remove unreferenced staticarchie1998-12-071-3/+1
| | | | and local variables, goto labels, and functions declared but not defined.
* We can't call fsetown() from sonewconn() because sonewconn() is be calledtruckman1998-11-231-2/+1
| | | | | | | | | | | | | | | | | | | from an interrupt context and fsetown() wants to peek at curproc, call malloc(..., M_WAITOK), and fiddle with various unprotected data structures. The fix is to move the code that duplicates the F_SETOWN/FIOSETOWN state of the original socket to the new socket from sonewconn() to accept1(), since accept1() runs in the correct context. Deferring this until the process calls accept() is harmless since the process can't do anything useful with SIGIO on the new socket until it has the descriptor for that socket. One could make the case for not bothering to duplicate the F_SETOWN/FIOSETOWN state and requiring the process to explicitly make the fcntl() or ioctl() call on the new socket, but this would be incompatible with the previous implementation and might break programs which rely on the old semantics. This bug was discovered by Andrew Gallatin <gallatin@cs.duke.edu>.
* Installed the second patch attached to kern/7899 with some changes suggestedtruckman1998-11-111-9/+5
| | | | | | | | | | | | | | | | by bde, a few other tweaks to get the patch to apply cleanly again and some improvements to the comments. This change closes some fairly minor security holes associated with F_SETOWN, fixes a few bugs, and removes some limitations that F_SETOWN had on tty devices. For more details, see the description on the PR. Because this patch increases the size of the proc and pgrp structures, it is necessary to re-install the includes and recompile libkvm, the vinum lkm, fstat, gcore, gdb, ipfilter, ps, top, and w. PR: kern/7899 Reviewed by: bde, elvind
* Fix sbcheck() to check all packets on socket buffer.fenner1998-11-041-9/+11
| | | | | | | | | | Also fix data types and printf formats while I'm here. PR: misc/8494 Panic instead of looping forever in sbflush(). If sb_mbcnt counts more mbufs than sb_cc counts bytes, the original code can turn into an infinite loop of removing 0 bytes from the socket buffer until it's empty.
* Fixed recently perpetrated printf format errors.bde1998-09-051-3/+2
|
* make sbflush panic messages more descriptiveache1998-09-041-3/+4
|
* This commit fixes various 64bit portability problems required fordfr1998-06-071-2/+2
| | | | | | | | | | FreeBSD/alpha. The most significant item is to change the command argument to ioctl functions from int to u_long. This change brings us inline with various other BSD versions. Driver writers may like to use (__FreeBSD_version == 300003) to detect this change. The prototype FreeBSD/alpha machdep will follow in a couple of days time.
* Have the wakeup routine do the upcall if needed.peter1998-05-311-1/+3
| | | | Obtained from: NetBSD
* s/nanoruntime/nanouptime/gphk1998-05-171-2/+2
| | | | | | s/microruntime/microuptime/g Reviewed by: bde
* Convert socket structures to be type-stable and add a version number.wollman1998-05-151-4/+55
| | | | | | | | | | | | | | | | | | | Define a parameter which indicates the maximum number of sockets in a system, and use this to size the zone allocators used for sockets and for certain PCBs. Convert PF_LOCAL PCB structures to be type-stable and add a version number. Define an external format for infomation about socket structures and use it in several places. Define a mechanism to get all PF_LOCAL and PF_INET PCB lists through sysctl(3) without blocking network interrupts for an unreasonable length of time. This probably still has some bugs and/or race conditions, but it seems to work well enough on my machines. It is now possible for `netstat' to get almost all of its information via the sysctl(3) interface rather than reading kmem (changes to follow).
* Added kern.ipc.nmbclustersdg1998-04-241-1/+2
|
* Time changes mark 2:phk1998-04-041-5/+6
| | | | | | | | | | | | | | | | | * Figure out UTC relative to boottime. Four new functions provide time relative to boottime. * move "runtime" into struct proc. This helps fix the calcru() problem in SMP. * kill mono_time. * add timespec{add|sub|cmp} macros to time.h. (XXX: These may change!) * nanosleep, select & poll takes long sleeps one day at a time Reviewed by: bde Tested by: ache and others
* Make sure that you can only bind a more specific address when it isguido1998-03-011-1/+2
| | | | | done by the same uid. Obtained from: OpenBSD
* Removed trailing semicolons from the definitions of the sysctlbde1997-09-071-2/+2
| | | | | | | | | declaration macros so that a semicolon can be added when the macros are invoked without giving a (pedantic) syntax error. Invocations need to be followed by a semicolon so that programs like indent and gtags don't get confused. Fixed the one invocation that wasn't followed by a trailing semicolon.
* sonewconn no longer passes curproc to the protocol attach methodtegge1997-09-041-2/+2
| | | | | | since that might cause in_pcballoc to call MALLOC with M_WAITOK during a software interrupt. Reviewed by: Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
* Removed unused #includes.bde1997-09-021-3/+1
|
* Fix all areas of the system (or at least all those in LINT) to avoid storingwollman1997-08-161-144/+21
| | | | | | | | socket addresses in mbufs. (Socket buffers are the one exception.) A number of kernel APIs needed to get fixed in order to make this happen. Also, fix three protocol families which kept PCBs in mbufs to not malloc them instead. Delete some old compatibility cruft while we're at it, and add some new routines in the in_cksum family.
* Remove sonewconn() macro kludge, introduced in 4.3-Reno to catch argumentfenner1997-07-191-5/+2
| | | | | | mismatches. Prototypes do a much better job these days. Noticed by: bde
* Attempt to convert the ip_divert code to use the new-style protocol requestpeter1997-05-241-1/+7
| | | | | | switch. I needed 'LINT' to compile for other reasons so I kinda got the blood on my hands. Note: I don't know how to test this, I don't know if it works correctly.
* The long-awaited mega-massive-network-code- cleanup. Part I.wollman1997-04-271-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* In accept1(), falloc() is called after the process has awoken, but priordg1997-03-311-3/+3
| | | | | | | | | | | to removing the connection from the queue. The problem here is that falloc() may block and this would allow another process to accept the connection instead. If this happens to leave the queue empty, then the system will panic with an "accept: nothing queued". Also changed a wakeup() to a wakeup_one() to avoid the "thundering herd" problem on new connections in Apache (or any other application that has multiple processes blocked in accept() for the same socket).
* Create a new branch of the kernel MIB, kern.ipc, to storewollman1997-02-241-4/+15
| | | | | | | | | | | all of the configurables and instrumentation related to inter-process communication mechanisms. Some variables, like mbuf statistics, are instrumented here for the first time. For mbuf statistics: also keep track of m_copym() and m_pullup() failures, and provide for the user's inspection the compiled-in values of MSIZE, MHLEN, MCLBYTES, and MINCLSIZE.
* Make the operation of sonewconn1() a bit clearer by callingwollman1997-02-191-12/+7
| | | | | pru_attach() before putting the new connection on the connection queue.
* uipc_mbuf.c: do a better job of counting how often we have to waitwollman1997-02-181-0/+35
| | | | | | | for memory, or are denied a cluster. uipc_socket2.c: define some generic ``operation-not-supported'' entry points for pr_usrreqs.
* For large values of sb_max or MCLBYTES, it was possible for the expressionwollman1997-02-131-2/+1
| | | | | | | sb_max * MCLBYTES / (MSIZE + MCLBYTES) used in sbreserve() to overflow, causing all socket creation attempts to fail. Force the calculation to use u_quad_t's, which makes overflow less likely.
* 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.
* Add the IP_RECVIF socket option, which supplies a packet's incoming interfacefenner1996-11-111-1/+27
| | | | | | | | using a sockaddr_dl. Fix the other packet-information socket options (SO_TIMESTAMP, IP_RECVDSTADDR) to work for multicast UDP and raw sockets as well. (They previously only worked for unicast UDP).
* Fix two bugs I accidently put into the syn code at the last minutepst1996-10-111-9/+11
| | | | | | | | | | (yes I had tested the hell out of this). I've also temporarily disabled the code so that it behaves as it previously did (tail drop's the syns) pending discussion with fenner about some socket state flags that I don't fully understand. Submitted by: fenner
OpenPOWER on IntegriCloud