aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/uipc_sockbuf.c
Commit message (Collapse)AuthorAgeFilesLines
* 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
* In accept1(), falloc() is called after the process has awoken, but priorDavid Greenman1997-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). Notes: svn path=/head/; revision=24442
* Create a new branch of the kernel MIB, kern.ipc, to storeGarrett Wollman1997-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. Notes: svn path=/head/; revision=23081
* Make the operation of sonewconn1() a bit clearer by callingGarrett Wollman1997-02-191-12/+7
| | | | | | | | pru_attach() before putting the new connection on the connection queue. Notes: svn path=/head/; revision=22936
* uipc_mbuf.c: do a better job of counting how often we have to waitGarrett Wollman1997-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. Notes: svn path=/head/; revision=22899
* For large values of sb_max or MCLBYTES, it was possible for the expressionGarrett Wollman1997-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. Notes: svn path=/head/; revision=22658
* Make the long-awaited change from $Id$ to $FreeBSD$Jordan K. Hubbard1997-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. Notes: svn path=/head/; revision=21673
* Add the IP_RECVIF socket option, which supplies a packet's incoming interfaceBill Fenner1996-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). Notes: svn path=/head/; revision=19622
* Fix two bugs I accidently put into the syn code at the last minutePaul Traina1996-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 Notes: svn path=/head/; revision=18874
* Increase robustness of FreeBSD against high-rate connection attemptPaul Traina1996-10-071-6/+46
| | | | | | | | | | denial of service attacks. Reviewed by: bde,wollman,olah Inspired by: vjs@sgi.com Notes: svn path=/head/; revision=18787
* Add a new sysctl variable kern.sominqueue to override the MINIMUM queuePaul Traina1996-09-191-2/+6
| | | | | | | specified in a listen(2) system call. Notes: svn path=/head/; revision=18365
* for kern_conf.c, start allocating dynamic major numbersJulian Elischer1996-08-191-2/+2
| | | | | | | | | | | | half way through the range rather than possibly colliding with fixed elements. Increase the size of the arrays to take this into account.. remember that each element in the array is now only 1 ponter so this isn't that much.. also note a possible bug in debugging code in uipc_socket2.c (add XXX) Notes: svn path=/head/; revision=17675
* Modify the kernel to use the new pr_usrreqs interface rather than the oldGarrett Wollman1996-07-111-95/+27
| | | | | | | | | | | | | | | | | pr_usrreq mechanism which was poorly designed and error-prone. This commit renames pr_usrreq to pr_ousrreq so that old code which depended on it would break in an obvious manner. This commit also implements the new interface for TCP, although the old function is left as an example (#ifdef'ed out). This commit ALSO fixes a longstanding bug in the TCP timer processing (introduced by davidg on 1995/04/12) which caused timer processing on a TCB to always stop after a single timer had expired (because it misinterpreted the return value from tcp_usrreq() to indicate that the TCB had been deleted). Finally, some code related to polling has been deleted from if.c because it is not relevant t -current and doesn't look at all like my current code. Notes: svn path=/head/; revision=17096
* This is a proposal-in-code for a substantial modification of the wayGarrett Wollman1996-07-091-1/+219
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the high kernel calls into a protocol stack to perform requests on the user's behalf. We replace the pr_usrreq() entry in struct protosw with a pointer to a structure containing pointers to functions which implement the various reuqests; each function is declared with the correct type and number of arguments. (This is unlike the current scheme in which a quarter of the requests take arguments of type other than (struct mbuf *) and the difference is papered over with casts.) There are a few benefits to this new scheme: 1) Arguments are passed with their correct types, and null-pointer dummies are no longer necessary. 2) There should be slightly better caching effects from eliminating the prximity to extraneous code and th switch in pr_usrreq(). 3) It becomes much easier to change the types of the arguments to something other than `struct mbuf *' (e.g.,pushing the work of sosend() into the protocol as advocated by Van Jacobson). There is one principal drawback: existing protocol stacks need to be modified. This is alleviated by compatibility code in uipc_socket2.c and uipc_domain.c which emulates the new interface in terms of the old and vice versa. This idea is not original to me. I read about what Jacobson did in one of his papers and have tried to implement the first steps towards something like that here. Much work remains to be done. Notes: svn path=/head/; revision=17047
* Clean up -Wunused warnings.Gary Palmer1996-06-121-2/+1
| | | | | | | Reviewed by: bde Notes: svn path=/head/; revision=16322
* Changed socket code to use 4.4BSD queue macros. This includes removingDavid Greenman1996-03-111-57/+22
| | | | | | | | | | | | the obsolete soqinsque and soqremque functions as well as collapsing so_q0len and so_qlen into a single queue length of unaccepted connections. Now the queue of unaccepted & complete connections is checked directly for queued sockets. The new code should be functionally equivilent to the old while being substantially faster - especially in cases where large numbers of connections are often queued for accept (e.g. http). Notes: svn path=/head/; revision=14547
* Eliminate the dramatic TCP performance decrease observed for writes inGarrett Wollman1996-01-051-2/+6
| | | | | | | | | | | | | | | | | | | | the range [210:260] by sweeping the problem under the rug. This change has the following effects: 1) A new MIB variable in the kern branch is defined to allow modification of the socket buffer layer's ``wastage factor'' (which determines how much unused-but-allocated space in mbufs and mbuf clusters is allowed in a socket buffer). 2) The default value of the wastage factor is changed from 2 to 8. The original value was chosen when MINCLSIZE was 7*MLEN (!), and is not appropriate for an environment where MINCLSIZE is much less. The real solution to this problem is to scrap both mbufs and sockbufs and completely redesign the buffering mechanism used at both levels. Notes: svn path=/head/; revision=13267
* Nuked ambiguous sleep message strings:Bruce Evans1995-12-141-8/+3
| | | | | | | | | | old: new: netcls[] = "netcls" "soclos" netcon[] = "netcon" "accept", "connec" netio[] = "netio" "sblock", "sbwait" Notes: svn path=/head/; revision=12843
* Make somaxconn (maximum backlog in a listen(2) request) and sb_maxGarrett Wollman1995-11-031-2/+5
| | | | | | | | | | | (maximum size of a socket buffer) tunable. Permit callers of listen(2) to specify a negative backlog, which is translated into somaxconn. Previously, a negative backlog was silently translated into 0. Notes: svn path=/head/; revision=12041
* Remove trailing whitespace.Rodney W. Grimes1995-05-301-5/+5
| | | | Notes: svn path=/head/; revision=8876
* All of this is cosmetic. prototypes, #includes, printfs and so on. MakesPoul-Henning Kamp1994-10-021-18/+20
| | | | | | | GCC a lot more silent. Notes: svn path=/head/; revision=3308
* Added $Id$David Greenman1994-08-021-0/+1
| | | | Notes: svn path=/head/; revision=1817
* The big 4.4BSD Lite to FreeBSD 2.0.0 (Development) patch.Rodney W. Grimes1994-05-251-0/+32
| | | | | | | | Reviewed by: Rodney W. Grimes Submitted by: John Dyson and David Greenman Notes: svn path=/head/; revision=1549
* BSD 4.4 Lite Kernel SourcesRodney W. Grimes1994-05-241-0/+755
Notes: svn path=/head/; revision=1541