Commit Graph

200 Commits

Author SHA1 Message Date
elad 097059fb23 Don't bother caching egid. It'll be removed soon. 2009-12-30 22:12:12 +00:00
elad 7bbc644a97 Use credentials from the socket. 2009-12-30 06:58:50 +00:00
elad 841ec82ba2 Add credentials to to sockets.
We don't need any deferred free etc. because we no longer free the
credentials in interrupt context.

Tons of help from matt@, thanks!
2009-12-29 04:23:43 +00:00
elad 34ce871d58 Remove commented-out code that should not have gone in. 2009-12-29 03:48:18 +00:00
dsl 2a54322c7b If a multithreaded app closes an fd while another thread is blocked in
read/write/accept, then the expectation is that the blocked thread will
exit and the close complete.
Since only one fd is affected, but many fd can refer to the same file,
the close code can only request the fs code unblock with ERESTART.
Fixed for pipes and sockets, ERESTART will only be generated after such
a close - so there should be no change for other programs.
Also rename fo_abort() to fo_restart() (this used to be fo_drain()).
Fixes PR/26567
2009-12-20 09:36:05 +00:00
dsl 7a42c833db Rename fo_drain() to fo_abort(), 'drain' is used to mean 'wait for output
do drain' in many places, whereas fo_drain() was called in order to force
blocking read()/write() etc calls to return to userspace so that a close()
call from a different thread can complete.
In the sockets code comment out the broken code in the inner function,
it was being called from compat code.
2009-12-09 21:32:58 +00:00
cegger 9480c51b04 Add a flags argument to pmap_kenter_pa(9).
Patch showed on tech-kern@ http://mail-index.netbsd.org/tech-kern/2009/11/04/msg006434.html
No objections.
2009-11-07 07:27:40 +00:00
elad 5b3a96a24d Move KAUTH_NETWORK_BIND::KAUTH_REQ_NETWORK_BIND_PORT policy back to the
subsystem (or close to it).

Note: Revisit KAUTH_REQ_NETWORK_BIND_PRIVPORT.
2009-10-03 03:59:39 +00:00
elad 111de3833c Finish moving socket policy to the subsystem. 2009-10-03 01:41:39 +00:00
elad 510083464f Move some of the socket policy back to the subsystem.
Remove include we don't need in the secmodel code.
2009-10-02 23:50:16 +00:00
dyoung c5d5f7697a Make ifconfig(8) set and display preference numbers for IPv6
addresses.  Make the kernel support SIOC[SG]IFADDRPREF for IPv6
interface addresses.

In in6ifa_ifpforlinklocal(), consult preference numbers before
making an otherwise arbitrary choice of in6_ifaddr.  Otherwise,
preference numbers are *not* consulted by the kernel, but that will
be rather easy for somebody with a little bit of free time to fix.

Please note that setting the preference number for a link-local
IPv6 address does not work right, yet, but that ought to be fixed
soon.

In support of the changes above,

1 Add a method to struct domain for "externalizing" a sockaddr, and
  provide an implementation for IPv6.  Expect more work in this area: it
  may be more proper to say that the IPv6 implementation "internalizes"
  a sockaddr.  Add sockaddr_externalize().

2 Add a subroutine, sofamily(), that returns a struct socket's address
  family or AF_UNSPEC.

3 Make a lot of IPv4-specific code generic, and move it from
  sys/netinet/ to sys/net/ for re-use by IPv6 parts of the kernel and
  ifconfig(8).
2009-09-11 22:06:29 +00:00
ad 922436b4c6 PR kern/41311: Mutex error: mutex_vector_enter: locking against myself 2009-04-30 20:41:33 +00:00
ad c6367674d6 Add fileops::fo_drain(), to be called from fd_close() when there is more
than one active reference to a file descriptor. It should dislodge threads
sleeping while holding a reference to the descriptor. Implemented only for
sockets but should be extended to pipes, fifos, etc.

Fixes the case of a multithreaded process doing something like the
following, which would have hung until the process got a signal.

thr0	accept(fd, ...)
thr1	close(fd)
2009-04-04 10:12:51 +00:00
cegger b8817e4aed ansify function definitions 2009-03-15 17:14:40 +00:00
pooka f6724ea74f solock() in compat code error branch to avoid panic 2009-01-23 15:40:19 +00:00
yamt 812bb0d164 restore the pre socket locking patch signal behaviour.
this fixes a busy-loop in nfs_connect.
2009-01-21 06:59:29 +00:00
christos 14ba6c67a5 Provide compatibility to the old timeval SCM_TIMESTAMP messages. 2009-01-19 02:27:57 +00:00
christos dfcfa95743 check for error in the COMPAT_50 case. 2009-01-15 15:29:10 +00:00
christos a46d2217e9 reverse the polarity of the use of the error variable. Using a different
variable would be cleaner but it would require more ifdefs.
2009-01-15 15:25:37 +00:00
christos 6e8bc6579f correct previous, fix reversed test, remove memset. 2009-01-14 23:28:23 +00:00
cegger 16f884ca6d make this compile: fix gcc warning about uninitialized use of tv.sec and tv.usec. 2009-01-14 20:33:19 +00:00
christos 6d87d90fe9 version get/set send/recv timeout setsockopt. 2009-01-14 18:09:00 +00:00
pooka 54b9426187 Move some sysctl node creations away from linksets and into the
constructors for subsystems.

XXX: CTLFLAG_PERMANENT is non-sensible.
2008-12-07 20:58:46 +00:00
ad 82e3c0b1ac Accept filters:
- Remove remaining #ifdef INET.
- Avoid holding locks so we don't need to do KM_NOSLEEP allocations.
- Use a rwlock to protect the accept filter list.
- Make it safe to unload accept filter modules.
- Minor KNF.
2008-10-14 13:45:26 +00:00
plunky c827b856f4 fix problem pointed out by ad where sockopt may end up sleeping
inappropriately with the socket lock held.

    sockopt_init() may sleep

    sockopt_set() will not sleep

    sockopt_getmbuf() for legacy code will not sleep
2008-10-12 09:26:50 +00:00
tls cef30423d3 Address problems with accept filters noted by ad in his source-changes
mail: http://mail-index.netbsd.org/source-changes/2008/10/10/msg211109.html

	* Scary-looking socket locking stubs (changed to KASSERT of locked)

	* depends on INET inappropriately (though now you must add new
	  accept filter names to the uipc_accf.c line in conf/files if
	  you aren't using dataready or httpready)

	* New code uses MALLOC/FREE -- changed to kmem_alloc/kmem_free;
	  could be pool_cache, these are all fixed-size allocations.

We need to verify that this works as expected with protocols with per-socket
locking, like PF_LOCAL.  I'm a little concerned about the case where the
lock on the listen socket isn't the same lock as on the eventual connected
socket.
2008-10-11 16:39:07 +00:00
pooka 7e5aba5af0 Move uidinfo to its own module in kern_uidinfo.c and include in rump.
No functional change to uidinfo.
2008-10-11 13:40:57 +00:00
plunky d56f5b8302 use kmem_alloc/kmem_free rather than malloc() for sockokpt 2008-10-10 19:49:49 +00:00
ad fbc0e2e6d3 Redo 1.169 correctly (dsl's fix doesn't do what I intended, either!). 2008-10-10 11:20:15 +00:00
plunky fd7356a917 Convert socket options code to use a sockopt structure
instead of laying everything into an mbuf.

approved by core
2008-08-06 15:01:23 +00:00
tls 717f903a98 Add accept filters, ported from FreeBSD by Coyote Point Systems. Add inetd
support for specifying an accept filter for a service (mostly as a usage
example, but it can be handy for other things).  Manual pages to follow
in a day or so.

OK core@.
2008-08-04 03:55:47 +00:00
dsl c43281ec80 Remove all the pending connections in soclose().
'continue' in 'do .. while (0)' doesn't do what ad@ intended.
2008-07-25 22:45:58 +00:00
yamt fff57c5525 merge yamt-pf42 branch.
(import newer pf from OpenBSD 4.2)

ok'ed by peter@.  requested by core@
2008-06-18 09:06:25 +00:00
ad 79d0501e52 Disable zero copy if MULTIPROCESSOR, until it is fixed:
- The TLB coherency overhead on MP systems is really expensive.
- It triggers a race in the VM system (grep kpause uvm/*).
2008-05-28 21:01:42 +00:00
ad c9ac92b592 Use pool_cache for sockets. 2008-05-26 17:21:18 +00:00
christos 934b677fde Coverity CID 5015: Remove unnecessary test; if l was null we would have
crashed before when p = l->l_proc.
2008-05-24 18:43:02 +00:00
drochner d41cbd880a fix soabort(): sofree() wants to be called with the lock held
approved by ad
2008-05-01 09:21:56 +00:00
ad 322906d197 solisten: don't leak lock if the socket is busy. 2008-04-29 17:35:31 +00:00
martin ce099b4099 Remove clause 3 and 4 from TNF licenses 2008-04-28 20:22:51 +00:00
ad 12e587a1a3 Fix a use-after-free in soabort(). It would be better to kill SS_NOFDREF
and maintain a per-socket reference count, but SS_NOFDREF is slightly
more than a simple reference count and I don't want to break anything.
2008-04-27 14:26:58 +00:00
ad 15e29e981b Merge the socket locking patch:
- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.
2008-04-24 11:38:36 +00:00
ad acc82f8808 soreceive: dom_externalize/dom_dispose can block. If new messages are
appended while the receiver is blocked, the sockbuf will be corrupted.
Dequeue control messages from the sockbuf and sync its state in one
pass. Only then process the control messages. From FreeBSD.
2008-04-14 15:42:20 +00:00
ad c2f3592995 Prevent listen() on a socket that is already connected - we already prevent
connect() on a listening socket.
2008-03-28 12:12:20 +00:00
ad be04ac4896 Make rusage collection per-LWP and collate in the appropriate places.
cloned threads need a little bit more work but the locking needs to
be fixed first.
2008-03-27 19:06:51 +00:00
yamt 9a4b7dd279 merge yamt-lazymbuf branch. 2008-03-24 12:24:37 +00:00
ad a9ca7a3734 Catch up with descriptor handling changes. See kern_descrip.c revision
1.173 for details.
2008-03-21 21:54:58 +00:00
ad 5e7d890908 - Extract the guts of soo_poll() into sopoll(), which takes a struct socket *.
This is for netsmb which wants to poll sockets directly.
- When polling a socket, first check for pending I/O without acquring any
  locks. If no I/O seems to be pending, acquire locks/spl and check again
  doing selrecord() if necessary.
2008-03-20 19:23:15 +00:00
rmind c6186face4 Welcome to 4.99.55:
- Add a lot of missing selinit() and seldestroy() calls.

- Merge selwakeup() and selnotify() calls into a single selnotify().

- Add an additional 'events' argument to selnotify() call.  It will
  indicate which event (POLL_IN, POLL_OUT, etc) happen.  If unknown,
  zero may be used.

Note: please pass appropriate value of 'events' where possible.
Proposed on: <tech-kern>
2008-03-01 14:16:49 +00:00
matt a918cf0e3a Convert stragglers to ansi definitions from old-style definitons.
Remember that func() is not ansi, func(void) is.
2008-02-27 19:55:59 +00:00
ad d7f6ec471c Don't lock the socket to set/clear FNONBLOCK. Just set it atomically. 2008-02-06 21:57:53 +00:00