summaryrefslogtreecommitdiff
path: root/sys/kern/uipc_socket2.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix up indentation.Jonathan Lemon2001-06-291-2/+2
| | | | Notes: svn path=/head/; revision=78945
* "Fix" the previous initial attempt at fixing TUNABLE_INT(). This timePeter Wemm2001-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. Notes: svn path=/head/; revision=77900
* Back out part of my previous commit. This was a last minute changePeter Wemm2001-06-071-1/+1
| | | | | | | | and I botched testing. This is a perfect example of how NOT to do this sort of thing. :-( Notes: svn path=/head/; revision=77853
* Make the TUNABLE_*() macros look and behave more consistantly like thePeter Wemm2001-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. Notes: svn path=/head/; revision=77843
* Revert the last bits of my bogus move of NMBCLUSTERSJesper Skriver2001-06-011-0/+1
| | | | | | | to <sys/param.h> Notes: svn path=/head/; revision=77598
* Move the definition of NMBCLUSTERS from src/sys/kern/uipc_mbuf.cJesper Skriver2001-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 Notes: svn path=/head/; revision=77544
* Undo part of the tangle of having sys/lock.h and sys/mutex.h included inMark Murray2001-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) Notes: svn path=/head/; revision=76166
* Make sbcompress use the new M_WRITABLE macro. Previously sbcompressDavid Malone2000-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 Notes: svn path=/head/; revision=68918
* Remove uidinfo hash table lookup and maintenance out of chgproccnt() andDon Lewis2000-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(). Notes: svn path=/head/; revision=65495
* Fix hangs caused by overzealous code removal.Brian Feldman2000-08-311-2/+2
| | | | | | | | | Thanks, Nickolay, for figuring out this is the problem. Submitted by: Nickolay Dudorov <nnd@mail.nsk.ru> Notes: svn path=/head/; revision=65278
* Remove an extraneous setting of sb_hiwat.Brian Feldman2000-08-301-1/+0
| | | | Notes: svn path=/head/; revision=65229
* Remove any possibility of hiwat-related race conditions by changingBrian Feldman2000-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. Notes: svn path=/head/; revision=65198
* Remove unnecessary call to splnet when setting an accept filterPaul Saab2000-07-311-3/+0
| | | | | | | since we are already at splnet. Notes: svn path=/head/; revision=64046
* fix races in the uidinfo subsystem, several problems existed:Alfred Perlstein2000-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 Notes: svn path=/head/; revision=61976
* return of the accept filter part IIAlfred Perlstein2000-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 Notes: svn path=/head/; revision=61837
* backout accept optimizations.Alfred Perlstein2000-06-181-145/+0
| | | | | | | Requested by: jmg, dcs, jdp, nate Notes: svn path=/head/; revision=61799
* add socketoptions DELAYACCEPT and HTTPACCEPT which will not allow an accept()Alfred Perlstein2000-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. Notes: svn path=/head/; revision=61714
* Introduce kqueue() and kevent(), a kernel event notification facility.Jonathan Lemon2000-04-161-0/+2
| | | | Notes: svn path=/head/; revision=59288
* CMSG_XXX macros alignment fixes to follow RFC2292.Yoshinobu Inoue2000-03-031-4/+3
| | | | | | | | | | Approved by: jkh Submitted by: Partly from tech@openbsd Reviewed by: itojun Notes: svn path=/head/; revision=57719
* Add length check to sbcreatecontrol().Yoshinobu Inoue2000-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 Notes: svn path=/head/; revision=57441
* Add aio_waitcomplete(). Make aio work correctly for socket descriptors.Jason Evans2000-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> Notes: svn path=/head/; revision=55943
* Implement RLIMIT_SBSIZE in the kernel. This is a per-uid sockbuf totalBrian Feldman1999-10-091-5/+21
| | | | | | | usage limit. Notes: svn path=/head/; revision=52070
* In sbflush(), don't exit the while loop too early: this can causePierre Beyssac1999-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 Notes: svn path=/head/; revision=51757
* Change so_cred's type to a ucred, not a pcred. THis makes more sense, actually.Brian Feldman1999-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. Notes: svn path=/head/; revision=51381
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50477
* Move the initialisation/tuning of nmbclusters from param.c/machdep.cMike Smith1999-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). Notes: svn path=/head/; revision=48579
* Reviewed by: the cast of thousandsBrian Feldman1999-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. Notes: svn path=/head/; revision=47992
* Update one set of comments.. s/so_q0/so_incomp/ and s/so_q/so_comp/ (that'sPeter Wemm1999-05-101-6/+6
| | | | | | | incomplete and complete connections I think) Notes: svn path=/head/; revision=46922
* Add sysctl descriptions to many SYSCTL_XXXsBill Fumerola1999-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) Notes: svn path=/head/; revision=46381
* Port NetBSD's 19990120-accept bug fix. This works around the race conditionBill Fenner1999-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) Notes: svn path=/head/; revision=43196
* The "easy" fixes for compiling the kernel -Wunused: remove unreferenced staticArchie Cobbs1998-12-071-3/+1
| | | | | | | and local variables, goto labels, and functions declared but not defined. Notes: svn path=/head/; revision=41591
* We can't call fsetown() from sonewconn() because sonewconn() is be calledDon Lewis1998-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>. Notes: svn path=/head/; revision=41298
* Installed the second patch attached to kern/7899 with some changes suggestedDon Lewis1998-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 Notes: svn path=/head/; revision=41086
* Fix sbcheck() to check all packets on socket buffer.Bill 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. Notes: svn path=/head/; revision=40913
* Fixed recently perpetrated printf format errors.Bruce Evans1998-09-051-3/+2
| | | | Notes: svn path=/head/; revision=38860
* make sbflush panic messages more descriptiveAndrey A. Chernov1998-09-041-3/+4
| | | | Notes: svn path=/head/; revision=38808
* This commit fixes various 64bit portability problems required forDoug Rabson1998-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. Notes: svn path=/head/; revision=36735
* Have the wakeup routine do the upcall if needed.Peter Wemm1998-05-311-1/+3
| | | | | | | Obtained from: NetBSD Notes: svn path=/head/; revision=36528
* s/nanoruntime/nanouptime/gPoul-Henning Kamp1998-05-171-2/+2
| | | | | | | | | s/microruntime/microuptime/g Reviewed by: bde Notes: svn path=/head/; revision=36119
* Convert socket structures to be type-stable and add a version number.Garrett 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). Notes: svn path=/head/; revision=36079
* Added kern.ipc.nmbclustersDavid Greenman1998-04-241-1/+2
| | | | Notes: svn path=/head/; revision=35413
* Time changes mark 2:Poul-Henning Kamp1998-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 Notes: svn path=/head/; revision=35029
* Make sure that you can only bind a more specific address when it isGuido van Rooij1998-03-011-1/+2
| | | | | | | | done by the same uid. Obtained from: OpenBSD Notes: svn path=/head/; revision=33955
* Removed trailing semicolons from the definitions of the sysctlBruce Evans1997-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. Notes: svn path=/head/; revision=29210
* sonewconn no longer passes curproc to the protocol attach methodTor Egge1997-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> Notes: svn path=/head/; revision=29111
* Removed unused #includes.Bruce Evans1997-09-021-3/+1
| | | | Notes: svn path=/head/; revision=29041
* Fix all areas of the system (or at least all those in LINT) to avoid storingGarrett Wollman1997-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. Notes: svn path=/head/; revision=28270
* Remove sonewconn() macro kludge, introduced in 4.3-Reno to catch argumentBill Fenner1997-07-191-5/+2
| | | | | | | | | mismatches. Prototypes do a much better job these days. Noticed by: bde Notes: svn path=/head/; revision=27531
* Attempt to convert the ip_divert code to use the new-style protocol requestPeter Wemm1997-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. Notes: svn path=/head/; revision=26096
* The long-awaited mega-massive-network-code- cleanup. Part I.Garrett 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. Notes: svn path=/head/; revision=25201