Commit Graph

74 Commits

Author SHA1 Message Date
pooka 19a57922d0 Add reconnect code to librumpclient. In case the connection to
the kernel server is lost, the client will now automatically attempt
to reconnect.

Among other things, this makes it possible to "reboot" and restart
the TCP/IP stack from under firefox without any perceivable less
of service.  If pages were loading at the time the TCP/IP server
was killed, there may be some broken links, but nothing a ctrl-r
cannot fix.
2011-01-24 17:47:51 +00:00
pooka 112941441d happiness is a quiet lint 2011-01-22 14:22:10 +00:00
pooka 3b79c0eb90 shush lint 2011-01-22 14:18:55 +00:00
pooka 1d9f8678bd In case sys_reboot() was called by a remote client, put the response
in the socket before we shut down.  This way the response to the
syscall travels to the caller and they know things worked correctly
instead of having to just assume.
2011-01-22 13:41:22 +00:00
pooka 3cc5cc6884 include pid of rump server in hostname 2011-01-20 15:00:12 +00:00
pooka 9fba158b8b Add RUMPSP_RAISE: the kernel sends a signal to the client. 2011-01-14 13:12:14 +00:00
pooka 3626eb4b01 call procexit when a connection closes 2011-01-12 12:52:16 +00:00
pooka 5064fa59e6 A bunch of improvements:
* don't hold spc mutex while sending data
* use send() for the banner to avoid SIGPIPE in case a client
  connects and immediately goes away
* fix error path locking
* use kevent() instead of pollts() in the client.  Apparently that
  is the only sensible way for a library to support both multithreading
  and signal-reentrancy in a race-free manner.
  (can I catch all signals with one kevent instead of installing
  NSIG different ones??)
* mark client comm descriptor non-blocking so that clients have
  better signal-interruptibility (we now sleep in signal-accepting
  kevent() instead of signal-masked recvfrom())
2011-01-10 19:49:43 +00:00
pooka 52fffe2163 g/c code which is unused in the server 2011-01-10 11:57:53 +00:00
pooka 55d21df89f Separate rw_data and rw_done. Otherwise we don't get wakeups for
requests which have a 0-length response (such as copyin 0/0).

This change makes links(1) work against a rump kernel which contains
rumpnet_local.  The presence of unix domain sockets caused links
to select() with 0 fds and a timeout, and because copyin never woke
up in the kernel the application blocked indefinitely.
2011-01-09 14:10:03 +00:00
pooka 91aad9bd60 Make rumpclient impervious to LD_PRELOAD syscall hijacking by using
dlsym(RTLD_NEXT) to lookup a host_syscall() function pointer which
is used instead of syscall() to communicate with the kernel server.

WARNING: popular opinion classifies this as "ugly code".  if you
have a weak heart/mind/soul/sole meuniere, read max. 1 line of the
diff per day, preferably with food.
2011-01-07 19:37:51 +00:00
pooka c45d9404c0 Make rumpclient syscalls safe to call from signal handlers. 2011-01-06 06:57:14 +00:00
pooka f4b63a89c1 Release sender lock before zeroing out "wanted" status during
violent disconnect.  Fixes some race conditions (maybe the one
occasionally showing up on tests/rump/rumpkern/t_stress).

thanks to schmonz for some discussion
2011-01-05 22:57:01 +00:00
pooka fd993ea3d0 Support fork() for rumpclient users. 2011-01-05 17:14:50 +00:00
pooka de27b28026 Fix fd leak also in non-NetBSD code path. 2011-01-05 09:43:00 +00:00
wiz aff1729a2c Fix fdleak in error case. Found by cppcheck. 2011-01-05 00:09:43 +00:00
pooka 3daddc031c rump_lwproc_newproc -> rump_lwproc_rfork 2011-01-02 13:01:45 +00:00
pooka 2aa9fbc0b2 Allow rump kernel to call dlsym(RTLD_DEFAULT). 2010-12-30 15:47:30 +00:00
pooka 393eecc12a Have the client and server perform some sort of handshake first.
It's pretty much a placeholder for now.  One plan for the future
is to require some sort of authentication for superuser clients.
The code will need a little massage then, though, to prevent DoS
attacks.
2010-12-16 17:05:44 +00:00
pooka 3c4a27f7cd Print a banner a connecting client. The banner contains rump sp
protocol version, os name, os revision and machine.
2010-12-16 12:38:20 +00:00
pooka 34c8240044 Unlink unix socket as part of server exit.
(whatever happened to the code that was supposed to do it automatically
when the binding process exits?)
2010-12-12 17:58:28 +00:00
pooka c59435eea2 add rumpuser_sp_fini, which surpringly is the opposite of rumpuser_sp_init 2010-12-12 17:10:36 +00:00
pooka 939300d48c outdated comment 2010-12-12 13:48:55 +00:00
pooka 48ac8b3849 implement mutex_owner() 2010-12-01 17:22:51 +00:00
pooka 0f9fe55ba4 Umm, delete recursive mutex interface instead of renaming it. 2010-12-01 15:01:52 +00:00
pooka 5e1b7bf36d Track lwp as the rumpuser mutex owner instead of pthread_t (this
is done in rumpuser for simplicity, since on the kernel side things
we assume we have only one pointer of space).  As a side-effect,
we can no longer know if the current thread is holding on to a
mutex locked without curlwp context (basically all mutexes inited
outside of mutex_init()).  The only thing that called rumpuser_mutex_held()
for a non-kmutex was the giant lock.  So, instead implement recursive
locking for the giant lock in the rump kernel and get rid of the
now-unused recursive pthread mutex in the hypercall interface.
2010-12-01 14:59:37 +00:00
pooka 03f765ec9e lint care 2010-11-30 22:32:01 +00:00
pooka ff46270ebc Hands off of stuff we need to keep hands off of. 2010-11-30 20:33:43 +00:00
pooka 7332ad1515 Require server to be explicitly initialized with rump_init_server(url).
Also, add rump_daemonize_begin() / rump_daemonize_end() to help
with the "can't daemon() after pthread_create()" problem.  Applications
could accomplish the same, but since it's such a common operation,
provide a little help.
2010-11-30 14:23:24 +00:00
pooka 1e3b8bd985 add commented-out -D_DIAGNOSTIC 2010-11-30 14:08:39 +00:00
pooka d402686fe2 Remove remaining panic()s from server-side code. Also, allow to
send an out-of-band error.  Make the client retry syscall requests
if this error is EAGAIN, fail them otherwise.
2010-11-29 16:08:03 +00:00
pooka ea8aecd4f3 Cache syscall worker threads and include some stetson-harrison
limits.  This improves syscall throughput about 2x for non-userio
syscalls (no copyin/out, e.g. getpid()) and almost 1.5x even for
things like __sysctl().
(measured for cases where the remote process is on the local machine)

XXX: if the pthread deadqueue sucks for anything which cares about
performance, why does it exist?  Nuking it would make supporting
variable stack size easier.
2010-11-29 11:40:54 +00:00
pooka bd26e667a8 Since we are going to handle syscalls in our threads, limit stacksize.
(unfortunately though, pthread_attr_setstacksize() has no effect on NetBSD)
2010-11-27 18:30:51 +00:00
pooka f0d58f7830 Fix a few locking problems with multithreaded clients.
TODO: make server deal graciously with out-of-resources conditions
2010-11-26 18:51:03 +00:00
pooka 6e0e64ab1b Improve reliability in cases where client disconnects mid-operation. 2010-11-26 14:37:08 +00:00
pooka 7ca02bea53 Plug recently introduced memory leak: release lwp after use instead of
just switching away.

Also, make freeing syscall arguments a little more symmetric.
2010-11-26 10:59:14 +00:00
pooka 6b71288c49 *facepalm*, adjust remote copyinstr to work in cases where the end
of the max copyin extends to an unmapped page.

Noticed, as usual, by tests.
2010-11-25 17:59:02 +00:00
pooka 6d4b60f246 create pthread attribute only once 2010-11-24 20:29:13 +00:00
pooka d693e691bf unsnafu previous 2010-11-24 17:20:24 +00:00
pooka 0f9bd961a2 Unschedule from CPU for out-of-kernel blocking ops. Otherwise we
might even deadlock if the thread that wakes us up wants a CPU.
2010-11-24 17:00:10 +00:00
pooka b99a42f8f3 improve threadsafety 2010-11-24 15:17:46 +00:00
pooka adabf68496 missed part of earlier commit 2010-11-24 14:32:42 +00:00
pooka c21ac41b0b Sneeze some locking into connect/disconnect. 2010-11-24 11:40:24 +00:00
pooka 9be034428c Support physio for remote processes.
==> add support for remote vmspace vmapbuf/vunmapbuf
  ==> add proper support for copyin/out_vmspace
    ==> add support for remote vmspace uvm_io
      ==> add support for non-curproc rumpuser_sp_copyin/out
        ==> store remote context in vm_map->pmap instead of
            pthread_specificdata

In short, makes read/write of most (all?) block devices work from
a remote rump client via rump syscalls.
2010-11-22 20:42:19 +00:00
pooka ad5cf5ab43 squelch the compiler whine 2010-11-19 17:47:44 +00:00
pooka a2b42bab81 Support multithreaded clients and fix a few bugs. 2010-11-19 17:09:44 +00:00
pooka b82590c0a3 delint 2010-11-19 15:40:55 +00:00
pooka 52f22b2c6a Start working on making the syscall proxy code threadsafe. The
basics are there, but a few more tweaks are needed.  The reason
I'm committing it now is that the code was mindnumbingly boring to
write (no wonder it took me almost 3 years to get it done), and I
might burn it if it's not in a safe place.
2010-11-19 15:25:49 +00:00
pooka 48257b3e61 free syscall data after use 2010-11-17 17:36:14 +00:00
pooka e9e1ac535f Make int *error and optional parameter (i.e. it can be NULL).
Sometimes the caller just doesn't care which errno close() might
throw.
2010-11-15 15:23:32 +00:00