Commit Graph

90 Commits

Author SHA1 Message Date
christos ce9b807645 Coverity CID 1089: Add more KASSERTs to prevent NULL deref. 2006-04-14 23:15:21 +00:00
christos ff57dc92a8 Coverity CID 1088: Add KASSERT to prevent NULL pointer deref. 2006-04-14 23:12:14 +00:00
matt cda5c405e0 Add a KASSERT to document a condition for the PRU_ABORT case. 2006-04-13 04:58:31 +00:00
christos a529c06750 PR/32856: Christian Biere: Don't panic if you send a control message with
SCM_RIGHTS on an unconnected stream socket.
2006-03-01 02:06:11 +00:00
christos 95e1ffb156 merge ktrace-lwp. 2005-12-11 12:16:03 +00:00
simonb a21c456e2e Call nanotime() directly, instead of doing the
microtime()/TIMEVAL_TO_TIMESPEC() dance.
2005-11-11 07:07:42 +00:00
jmmv b077bb7f72 Honor the user's umask while creating local sockets. Several other systems
do already this (such as FreeBSD, OpenBSD and Linux), so it will improve
portability of some third-party programs.  No objections in tech-kern@.
2005-08-30 15:03:04 +00:00
yamt 91fa31b5d2 uipc_usrreq: plug mbuf leak. 2005-06-16 14:36:42 +00:00
christos efb6943313 - add const.
- remove unnecessary casts.
- add __UNCONST casts and mark them with XXXUNCONST as necessary.
2005-05-29 22:24:14 +00:00
christos 761bd09636 PR/30154: YAMAMOTO Takashi: tcp_close locking botch
chgsbsize() as mentioned in the PR can be called from an interrupt context
via tcp_close(). Avoid calling uid_find() in chgsbsize().
- Instead of storing so_uid in struct socketvar, store *so_uidinfo
- Add a simple lock to struct uidinfo.
2005-05-07 17:42:09 +00:00
perry da8abec863 nuke trailing whitespace 2005-02-26 21:34:55 +00:00
darrenr 02c34673a3 add a per-socket counter for dropped UDP packets when the internal buffers
are full.
2004-09-03 18:14:09 +00:00
jonathan 230fb9b8ab Eliminate several uses of `curproc' from the socket-layer code and from NFS.
Add a new explicit `struct proc *p' argument to socreate(), sosend().
Use that argument instead of curproc. Follow-on changes to pass that
argument to socreate(), sosend(), and (*so->so_send)() calls.
These changes reviewed and independently recoded  by Matt Thomas.

Changes to soreceive() and (*dom->dom_exernalize() from Matt Thomas:
pass soreceive()'s struct uio* uio->uio_procp to unp_externalize().
Eliminate curproc from unp_externalize.   Also, now soreceive() uses
its uio->uio_procp value, pass that same value downward to
((pr->pru_usrreq)() calls for consistency, instead of (struct proc * )0.

Similar changes in sys/nfs to eliminate (most) uses of curproc,
either via the req-> r_procp field of a struct nfsreq *req argument,
or by passing down new explicit struct proc * arguments.

Reviewed by: Matt Thomas, posted to tech-kern.
NB: The (*pr->pru_usrreq)() change should be tested on more (all!) protocols.
2004-05-22 22:52:13 +00:00
matt ac57eb9d5b Constify sun_noname. 2004-04-18 22:20:32 +00:00
matt 70e1f0d3ac ANSI'fy. 2004-04-18 21:48:15 +00:00
christos f13a3d0852 PR/9347: Eric E. Fair: socket buffer pool exhaustion leads to system deadlock
and unkillable processes.
1. Introduce new SBSIZE resource limit from FreeBSD to limit socket buffer
   size resource.
2. make sokvareserve interruptible, so processes ltsleeping on it can be
   killed.
2004-04-17 15:15:29 +00:00
junyoung a222c81884 Nuke __P(). 2004-03-23 13:22:03 +00:00
martin 44b17951f2 Avoid using m_clget() on a mbuf already in use, especially when we
need the data in the mbuf later and m_clget() changes some fields
overlaid to regular mbuf data. Instead, rearange code a bit, create
data into a new allocated buffer and and use MEXTADD to attach it to
the mbuf, if the mbuf internal space is not sufficient.

This fixes a crash on sparc64 (and probably all other archs where
sizeof(int) != sizeof(struct file *)) when running
regress/sys/kern/unfdpass.

Idea for solution from Matt Thomas, with additional input from YAMAMOTO
Takashi.
2003-12-29 22:08:02 +00:00
matt 7bf0959ab7 Restore a change that made AF_LOCAL sockets block on connect(2) until
accepted.  However, this time this behavor is not the default.  Instead
it must enabled by using the LOCAL_CONNWAIT socket option on either the
connecting or accepting socket.
2003-11-29 10:02:42 +00:00
perry 6032efb56d Revert a change that altered the semantics of AF_LOCAL sockets. Sadly
this made us API incompatible with other Unixes.
2003-11-29 06:08:29 +00:00
hannken a3a898ff0f Add the gating of system calls that cause modifications to the underlying
file system.
The function vfs_write_suspend stops all new write operations to a file
system, allows any file system modifying system calls already in progress
to complete, then sync's the file system to disk and returns. The
function vfs_write_resume allows the suspended write operations to
complete.

From FreeBSD with slight modifications.

Approved by: Frank van der Linden <fvdl@netbsd.org>
2003-10-15 11:28:59 +00:00
matt d7506a7151 Fix typo. 2003-09-03 22:20:34 +00:00
matt ecf95073f1 Change the behavor of AF_LOCAL connect() to sleep until the server has
accepted the connection.  This can prevent a client from overwhelming a
server.
2003-09-03 21:30:12 +00:00
agc aad01611e7 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22364, verified by myself.
2003-08-07 16:26:28 +00:00
jdolecek b178c0d519 back rev 1.63 (the linux hack) off - no compat specific code
in generic code, please

we need to massage the passed linux cmsg anyway, linux uses different
alignment for CMSG_DATA on at least some architectures
2003-07-24 07:30:48 +00:00
itojun f874ab05b3 backout previous, there was a comment on LINUX_SOL_SOCKET=1 2003-07-23 22:17:54 +00:00
itojun 8e4006214d #define LINUX_SOL_SOCKET 1, so that we can answer "what the hell is this 1?"
at ease.
2003-07-23 21:42:31 +00:00
christos 8c26e4c591 From Todd Vierling: Accept level == 1 for linux compat. 2003-07-23 19:24:48 +00:00
fvdl d5aece61d6 Back out the lwp/ktrace changes. They contained a lot of colateral damage,
and need to be examined and discussed more.
2003-06-29 22:28:00 +00:00
darrenr 960df3c8d1 Pass lwp pointers throughtout the kernel, as required, so that the lwpid can
be inserted into ktrace records.  The general change has been to replace
"struct proc *" with "struct lwp *" in various function prototypes, pass
the lwp through and use l_proc to get the process pointer when needed.

Bump the kernel rev up to 1.6V
2003-06-28 14:20:43 +00:00
christos 6dbb5081d5 RP/21088: Jesse Off: Return ENOBUFS instead of EINVAL when sbappend fails. 2003-04-10 18:55:11 +00:00
matt 65e5548a17 Add MBUFTRACE kernel option.
Do a little mbuf rework while here.  Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *).  These are not performance critical and making them
call m_get saves considerable space.  Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.
2003-02-26 06:31:08 +00:00
pk f82deea4bf Fix a simple_lock() mismatch in unp_internalize().
We may need to merge the passes over the files contained in the message
as noted by enami tsugutomo on tech-smp.
2003-02-25 09:56:15 +00:00
pk 2931081a79 Make updating a file's reference and use count MP-safe. 2003-02-23 14:37:32 +00:00
itojun a1a2fcda1e no need for error check after MEXTMALLOC - jdolecek 2002-11-25 08:31:58 +00:00
itojun 387ba53bc6 MEXTMALLOC() can fail even if M_WAITOK, if arg is too big for malloc(). 2002-11-25 06:32:37 +00:00
matt 48bbf5f234 Use the queue macros from <sys/queue.h> instead of referring to the queue
members directly.  Use *_FOREACH whenever possible.
2002-09-04 01:32:31 +00:00
lukem adc783d537 add RCSIDs 2001-11-12 15:25:01 +00:00
thorpej e45efd967f Deprecate the "m_act" alias of "m_nextpkt" (m_act is a historical
name), and just use m_nextpkt everywhere.
2001-10-18 20:17:24 +00:00
thorpej 80cc38a1af Fix a partial construction problem that can cause race conditions
between creation of a file descriptor and close(2) when using kernel
assisted threads.  What we do is stick descriptors in the table, but
mark them as "larval".  This causes essentially everything to treat
it as a non-existent descriptor, except for fdalloc(), which sees a
filled slot so that it won't (incorrectly) allocate it again.  When
a descriptor is fully constructed, the code that has constructed it
marks it as "mature" (which actually clears the "larval" flag), and
things continue to work as normal.

While here, gather all the code that gets a descriptor from the table
into a fd_getfile() function, and call it, rather than having the
same (sometimes incorrect) code copied all over the place.
2001-06-14 20:32:41 +00:00
thorpej d9b3317e3e Rework fdalloc() even further: split fdalloc() into fdalloc() and
fdexpand().  The former will return ENOSPC if there is not space
in the current filedesc table.  The latter performs the expansion
of the filedesc table.  This means that fdalloc() won't ever block,
and it gives callers an opportunity to clean up before the
potentially-blocking fdexpand() call.

Update all fdalloc() callers to deal with the need-to-fdexpand() case.

Rewrite unp_externalize() to use fdalloc() and fdexpand() in a
safe way, using an algorithm suggested by Bill Sommerfeld:
- Use a temporary array of integers to hold the new filedesc table
  indexes.  This allows us to repeat the loop if necessary.
- Loop through the array of file *'s, assigning them to filedesc table
  slots.  If fdalloc() indicates expansion is necessary, undo the
  assignments we've done so far, expand, and retry the whole process.
- Once all file *'s have been assigned to slots, update the f_msgcount
  and unp_rights counters.
- Right before we return, copy the temporary integer array to the message
  buffer, and trim the length as before.
Note that once locking is added to the filedesc array, this entire
operation will be `atomic', in that the lock will be held while
file *'s are assigned to embryonic table slots, thus preventing anything
else from using them.
2001-06-07 01:29:16 +00:00
thorpej c55795d055 Change fdalloc() to return ERESTART if we had to reallocate the
descriptor array, which may have blocked.  Change callers of
fdalloc() to restart whatever they\'re doing if this condition
happens.  (XXX unp_externalize() needs some work, but that will
be tackled later.)

Change finishdup() to close the descriptor in the `new\' slot if
one exists, and change sys_dup2() accordingly.

Closes a race condition when using kernel-assisted user threads.

While here, garbage-collect UF_MAPPED -- it is not used anywhere.
2001-06-06 17:00:00 +00:00
thorpej 0a3a6e34f8 Oops, missed a couple of places where CMSG_*() should be used. No
functional change in this case, but the code is now correct.
2000-06-05 16:29:45 +00:00
thorpej 724a90318e - Fix file descriptor passing AGAIN. This has apparently been broken
on LP64 systems (and probably the SPARC) since the __cmsg_alignbytes()
  changes went in.
- Change file descriptor passing to use CMSG_DATA(), not (cm + 1).  This
  pretty much has to be done in order to make it work properly on LP64,
  and considering that it's been broken this long...
- Use CMSG_SPACE() to determine the mbuf length needed for a given
  control message, and CMSG_LEN() to stash in the cmsg_len member.
2000-06-05 06:06:07 +00:00
augustss 264f1d27c6 Get rid of register declarations. 2000-03-30 09:27:11 +00:00
thorpej bbf19ba181 Um, hi, let's initialize pointers before we use them. 1999-06-17 23:17:45 +00:00
thorpej e3669c3393 Add "use counting" to file entries. When closing a file, and it's reference
count is 0, wait for use count to drain before finishing the close.

This is necessary in order for multiple processes to safely share file
descriptor tables.
1999-05-05 20:01:01 +00:00
thorpej 4913e22a19 Fix alignment problem in the garbage-collection code path. 1999-05-05 19:05:43 +00:00
thorpej 16936c9565 Break cdir/rdir/cmask info out of struct filedesc, and put it in a new
substructure, `cwdinfo'.  Implement optional sharing of this substructure.

This is required for clone(2).
1999-04-30 18:42:58 +00:00
mrg 48c12bfeed revert previous. oops. 1999-04-21 02:37:07 +00:00