Commit Graph

69 Commits

Author SHA1 Message Date
itojun 1638da93e1 support setsockopt() with larger data (up to MCLBYTES).
From: Hitoshi Asaeda <Hitoshi.Asaeda@sophia.inria.fr>
2002-05-31 20:33:11 +00:00
jdolecek 5798a9a710 Switch default for pipes to the faster John S. Dyson's implementation.
Old, socketpair-based ones are available with option PIPE_SOCKETPAIR.
2002-02-11 18:11:41 +00:00
lukem adc783d537 add RCSIDs 2001-11-12 15:25:01 +00:00
wiz 456dff6cb8 Spell 'occurred' with two 'r's. 2001-09-16 16:34:23 +00:00
jdolecek 588b94c0a2 Expel MSG_COMPAT/COMPAT_OLDSOCK, make the COMPAT_43 wrappers
arrange things as needed.  Unfortunately, the check in sockargs()
have to stay, since 4.3BSD bind(2), connect(2) and sendto(2) were
not versioned at the time :(

This code was tested to pass regression tests.
2001-07-17 11:49:40 +00:00
matt 54ec2573c9 Use consistent types for len. Limit sockarg length to reasonable values. 2001-07-01 20:42:48 +00:00
jdolecek 26d45c1101 Back off the sendit()/recvit() change, some have problems with it 2001-06-25 20:46:11 +00:00
jdolecek d865180393 sys_connect(): fix the call to FILE_UNUSE() so that it's done on return, rather
than immediatelly after getsock() call
2001-06-25 19:46:50 +00:00
jdolecek 7f7c60e827 Add 'kernsa' parameter for sendit()/recvit(); if nonzero, msg->msg_name
is supposed to point directly to struct mbuf or struct sockaddr in kernel
space as appropriate, rather than being a pointer to memory in userland.

This is to be used by compat/* when emulation needs to wrap
send{to|msg}(2)/recv{from|msg}(2) and modify the passed struct
sockaddr.
2001-06-25 19:24:02 +00:00
jdolecek ee882e3a09 Add port of high performance pipe implementation written by John S. Dyson
for FreeBSD project. Besides huge speed boost compared with socketpair-based
pipes, this implementation also uses pagable kernel memory instead of mbufs.

Significant differences to FreeBSD version:
* uses uvm_loan() facility for direct write
* async/SIGIO handling correct also for sync writer, async reader
* limits settable via sysctl, amountpipekva and nbigpipes available via sysctl
* pipes are unidirectional - this is enforced on file descriptor level
	for now only, the code would be updated to take advantage of it
	eventually
* uses lockmgr(9)-based locks instead of home brew variant
* scatter-gather write is handled correctly for direct write case, data
  is transferred by PIPE_DIRECT_CHUNK bytes maximum, to avoid running out of kva

All FreeBSD/NetBSD specific code is within appropriate #ifdef, in preparation
to feed changes back to FreeBSD tree.

This pipe implementation is optional for now, add 'options NEW_PIPE'
to your kernel config to use it.
2001-06-16 12:00:02 +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
manu 573ce64c6b implement the recently introduced EMUL_BSD_ASYNCIO_PIPE emulation package
flag.

EMUL_BSD_ASYNCIO_PIPE notes that the emulated binaries expect the original
BSD pipe behavior for asynchronous I/O, which is to fire SIGIO on read() and
write(). OSes without this flag do not expect any SIGIO to be fired on
read() and write() for pipes, even when async I/O was requested. As far as
we know, the OSes that need EMUL_BSD_ASYNCIO_PIPE are NetBSD, OSF/1 and
Darwin.
2001-05-06 19:22:32 +00:00
lukem de1c2690b6 convert to ANSI KNF 2001-02-27 05:19:13 +00:00
fvdl 405b695086 Make sobind() take a struct proc *. It already took curproc and
passed it down to the appropriate usrreq function, and this
allows usage for contexts that need to be explicitly different
from curproc (like in the NFS code when binding to a reserved port).
2000-12-10 23:16:28 +00:00
jdolecek d9a0883770 define COMPAT_OLDSOCK unconditionally - the code is used virtually for all
emulations besides NetBSD, and this way it's LKM-safe
2000-11-24 21:38:28 +00:00
thorpej 831865b30e MALLOC()/FREE() are not to be used for variable sized allocations. 2000-08-02 20:53:07 +00:00
mrg 32aa199ccf remove include of <vm/vm.h> 2000-06-27 17:41:07 +00:00
sommerfeld 40339b39f9 Reduce use of curproc in several places:
- Change ktrace interface to pass in the current process, rather than
p->p_tracep, since the various ktr* function need curproc anyway.

 - Add curproc as a parameter to mi_switch() since all callers had it
handy anyway.

 - Add a second proc argument for inferior() since callers all had
curproc handy.

Also, miscellaneous cleanups in ktrace:

 - ktrace now always uses file-based, rather than vnode-based I/O
(simplifies, increases type safety); eliminate KTRFLAG_FD & KTRFAC_FD.
Do non-blocking I/O, and yield a finite number of times when receiving
EWOULDBLOCK before giving up.

 - move code duplicated between sys_fktrace and sys_ktrace into ktrace_common.

 - simplify interface to ktrwrite()
2000-05-27 00:40:29 +00:00
augustss 264f1d27c6 Get rid of register declarations. 2000-03-30 09:27:11 +00:00
thorpej dabbfde70a Implement fdremove() which is used in place of all the code that
did the "fdp->fd_ofiles[fd] = 0" assignment; fdremove() make sure
the fd_freefiles hints stay in sync.

From OpenBSD.
2000-03-23 05:16:12 +00:00
mycroft 895de56d08 Fix recent bug in sys_accept(): we must remove the file descriptor from the
file descriptor table before freeing the file description.
1999-11-05 11:48:57 +00:00
enami 781f26d383 back out unnecessary stylistic changes in recent changes, to keep coding
style closer to NKF.
1999-10-30 12:11:27 +00:00
jdolecek 37c00e7548 minor cleanup of previous - avoid goto and code duplication 1999-10-27 13:17:46 +00:00
darrenr d2c8da2c36 patch from Greg A. Woods to fix panic problems with code that attempts to
recover from failures to accept a socket successfully.  Problem suggested
by this:
> It would appear (from two "panic: closef: count < 0" failures in less
> than 12 hours) that Darren's fix to accept(2) for lost file descriptors
> isn't quite correct.  His fix inserts a call to closef() to handle one
> of several possible error conditions.  However everywhere else in the
> socket code in the same file where falloc() cleanup is necessary the
> function used is ffree().
1999-10-27 11:54:56 +00:00
itojun 118d2b1d4f IPv6 kernel code, based on KAME/NetBSD 1.4, SNAP kit 19990628.
(Sorry for a big commit, I can't separate this into several pieces...)
Pls check sys/netinet6/TODO and sys/netinet6/IMPLEMENTATION for details.

- sys/kern: do not assume single mbuf, accept chained mbuf on passing
  data from userland to kernel (or other way round).
- "midway" ATM card: ATM PVC pseudo device support, like those done in ALTQ
  package (ftp://ftp.csl.sony.co.jp/pub/kjc/).
- sys/netinet/tcp*: IPv4/v6 dual stack tcp support.
- sys/netinet/{ip6,icmp6}.h, sys/net/pfkeyv2.h: IETF document assumes those
  file to be there so we patch it up.
- sys/netinet: IPsec additions are here and there.
- sys/netinet6/*: most of IPv6 code sits here.
- sys/netkey: IPsec key management code
- dev/pci/pcidevs: regen

In my understanding no code here is subject to export control so it
should be safe.
1999-07-01 08:12:45 +00:00
darrenr cd92b615fa fix sys_accept() to return EOPNOTSUPP for protocols which don't support
listen/accept (PR_LISTEN flag in protosw) and detect obvious faults in
parameters passed.  It is still possible for the address used for copying
the socket information to become invalid between that check and the copyout
so close the connection's allocated fd if the copyout fails so that we can
return EFAULT without allocating an fd and the application not knowing about
it.  Ideally we'd be able to queue the connection back up so a later accept
could retrieve it but unfortunately that's not possible.
1999-07-01 05:56:32 +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
cgd ee94a4dacb add checks for COMPAT_OSF1 in the appropriate places 1999-04-30 05:29:20 +00:00
kleink dfffb2f357 * Due to addition and use of socklen_t, make the socket option and address
arguments passed to accept(), bind(), connect(), getpeername(), getsockname(),
getsockopt(), recvfrom(), sendto() and sendmsg() unsigned, which also elimiates
a few casts.
* Reflect the (now) signedness of msg_iovlen, which necessiates the addition
of a few casts.
1999-02-10 18:02:28 +00:00
drochner c22ef79250 solve the COMPAT_OLDSOCK/MSG_COMPAT problem differently:
The source files which need MSG_COMPAT define COMPAT_OLDSOCK.
1998-12-18 13:18:42 +00:00
mycroft 74ad07cef5 Revert the functional change in rev 1.38; permit a msg_iovlen of 0.
There are two reasons for this:
* We should be able to pass file descriptors without sending any data.
* We could send zero-length iovecs anyway (but we shouldn't have to do this).
Also, msg_iovlen is already a u_int, so delete a bunch of casts.
1998-11-26 02:25:20 +00:00
kleink 7b07ad780a Per XNS Issue 5, calling recvmsg(2) or sendmsg(2) with an msg.msg_iovlen less
than or equal to 0 shall fail with EMSGSIZE; the latter condition was not being
checked for.  Also, document the msg.msg_iovlen > {IOV_MAX} case.
1998-08-04 19:48:34 +00:00
kleink c6ef57702d UIO_MAXIOV -> IOV_MAX 1998-08-04 12:19:15 +00:00
perry 275d1554aa Abolition of bcopy, ovbcopy, bcmp, and bzero, phase one.
bcopy(x, y, z) ->  memcpy(y, x, z)
ovbcopy(x, y, z) -> memmove(y, x, z)
   bcmp(x, y, z) ->  memcmp(x, y, z)
  bzero(x, y)    ->  memset(x, 0, y)
1998-08-04 04:03:10 +00:00
kleink 3d9b4a4320 Fix two off-by-one bugs, both present in each recvmsg(2) and sendmsg(2):
* the first one would cause an unnecessary malloc() of iovec storage for
  a msg_iovlen of UIO_SMALLIOV although the required amount of memory has
  been allocated on the stack.
* the second one would cause a recvmsg() or sendmsg() with a msg_iovlen of
  UIO_MAXIOV to fail with EMSGSIZE, which is also a violation of XNS5.
1998-08-03 15:15:58 +00:00
perry 730baa7431 fix sizeofs so they comply with the KNF style guide. yes, it is pedantic. 1998-07-31 22:50:48 +00:00
thorpej 4b039671de When checking for overflow in the residual count, test against SSIZE_MAX.
The read/write system calls return ssize_t because -1 is used to indicate
error, therefore the transfer size MUST be limited to SSIZE_MAX, otherwise
garbage can be returned to the user.

There is NO change from existing behavior here, only a more precise
definition of that the semantics are, except in the Alpha case, where
the full SSIZE_MAX transfer size can now be realized (ssize_t is 64-bit
on the Alpha).
1998-07-29 02:07:19 +00:00
lukem 786b86d71b use AF_LOCAL instead of AF_UNIX 1998-07-18 05:04:35 +00:00
thorpej 808867c7cf defopt KTRACE 1998-06-25 21:17:15 +00:00
matt 754c43dcfc Hook for 0-copy (or other optimized) sends and receives 1998-04-25 17:35:18 +00:00
fvdl e5bc90f40c Merge with Lite2 + local changes 1998-03-01 02:20:01 +00:00
thorpej 6b1ff3c892 When copying out multiple control messages, ensure that the next control
message is aligned.  From David Borman <dab@bsdi.com>.
1998-02-06 23:19:26 +00:00
thorpej cbf3cc6bb8 Make insertion and removal of sockets from the partial and incoming
connections queues O(C) rather than O(N).
1998-01-07 23:47:08 +00:00
thorpej b981fc4d34 Fix bug in recvit() that would cause recvmsg() to only receive one
control message, even if there were multiple control messages on
the queue.  From Jean-Luc Richier <Jean-Luc.Richier@imag.fr>, in
bug report kern/4700.
1998-01-07 05:49:25 +00:00
thorpej 8dd0293cd3 Use UCHAR_MAX rather than "255" when sanity-checking the length of a
sockaddr in sockargs().
1997-06-26 06:13:36 +00:00
thorpej e1fb68eb29 In sockargs():
- Add a comment describing my feelings about this interface, in general.
- Remove the COMPAT_OLDSOCK length hack.  Instead, if the socket argument
  is too long to fit in an mbuf, allocate enough external storage to
  hold it.
- If the socket argument is a sockaddr, don't allow the length to be
  greater than 255, as that would overflow sa_len.
Many thanks to enami tsugutomo <enami@cv.sony.co.jp> for his sanity checking.
1997-06-26 06:01:59 +00:00
cgd c60b7587ab * catch up with system call argument type fixups/const poisoning.
* Fix arguments to various copyin()/copyout() invocations, to avoid
  gratuitous casts.
* Some KNF formatting fixes
* Change sockargs()'s second argument to be a const void *, to help
  with dealing with the syscall argument type fixups/const poisoning.
1996-12-22 10:16:54 +00:00
cgd d73abf41aa avoid unnecessary checks of m_get/MGET/etc.'s return values. When
they're called with M_WAIT, they are defined to never return NULL.
1996-06-14 22:21:12 +00:00
mycroft 49d52c9b1c Pass a proc pointer down to the usrreq and pcbbind functions for PRU_ATTACH, PRU_BIND and
PRU_CONTROL.  The usrreq interface really needs to be split up, but this will have to wait.
Remove SS_PRIV completely.
1996-05-22 13:54:55 +00:00
pk bcc0cb3fa0 Don't touch retval[] in socketpair(); manual page says this system call
return 0 on success (PR#2428).
1996-05-17 22:45:32 +00:00