Home | History | Annotate | Download | only in librumpclient
History log of /src/lib/librumpclient/rumpclient.c
RevisionDateAuthorComments
 1.71  31-Jul-2023  rin librump*: Require 10.99.7 or higher for __kevent100
 1.70  28-Jul-2023  christos Add epoll(2) from Theodore Preduta as part of GSoC 2023
 1.69  16-Sep-2021  andvar fix typos in word "successful".
 1.68  11-Sep-2021  christos Ignore failed closes (if for example a closed file descriptor is passed as
a starting point). This is how the kernel behaves.
 1.67  06-Sep-2016  martin Redo previous by avoiding the casts and using PRIxREGISTER instead
 1.66  06-Sep-2016  martin Fix DPRINTF format
 1.65  17-Jan-2015  justin Modern Android SDK does not need special cases
 1.64  13-Dec-2014  justin Always use kqueue for BSDs in librumpclient

Tested now on the others
 1.63  08-Dec-2014  justin Use kqueue in librumpclient for FreeBSD too
 1.62  25-Apr-2014  pooka pretend to handle the poll return value for -Wunused-but-set
 1.61  03-Apr-2014  pooka branches: 1.61.2;
Make sure holyfd is -1 when rumpclient_init() is called for
the first time after fork to prevent fd 0 from being closed.

should fix test failures, thanks to martin for the prod
 1.60  02-Apr-2014  justin Add Android support for rump kernel.

Reviewed by pooka@
 1.59  02-Apr-2014  pooka fix build on NetBSD. also, prevent fd leak in error path
 1.58  02-Apr-2014  pooka On Linux, poll signalfd() when waiting for a kernel response.
This allows the same type of race-free handling of signals as kqueue()
allows on NetBSD. One of the noticeable things is that you can now
interrupt rumprun ping mid-interval on Linux.

per suggestion from Justin Cormack
 1.57  26-Feb-2014  pooka Use MAP_ANON|MAP_PRIVATE for anonymous memory mapping,
e.g. Linux gets upset if just MAP_ANON.
 1.56  20-Feb-2014  pooka Translate signal numbers between rump kernel and (POSIX) host.
 1.55  10-Sep-2013  pooka use <rump/rumpuser_port.h>
 1.54  17-Jan-2013  pooka Solaris 10 fixes
 1.53  17-Jan-2013  pooka If the host doesn't support RTLD_NEXT, don't play the dynamic linking game.
 1.52  12-Sep-2012  pooka attempt to inform user of what the error means
 1.51  29-Aug-2012  msaitoh branches: 1.51.2;
Remove unused variable. Approved by pooka.
 1.50  03-Aug-2012  pooka force-terminate commname
 1.49  03-Aug-2012  pooka Make librumpclient compile and work on Linux. This is accomplished by:

1) avoid "NetBSD'isms" in the rumpclient sources
2) do not require the knowledge of unnecessary weird_t's in syscallargs.h
for rumpclient
 1.48  21-Mar-2012  matt Use C89 function definition
 1.47  12-Dec-2011  joerg branches: 1.47.2;
Mark rumphijack_dlsym explicitly as weak to prevent optimisations based
on pointer (non-)identity of it and rumpclient__dlsym.
 1.46  12-Dec-2011  joerg Don't use K&R syntax
 1.45  30-Apr-2011  alnsn branches: 1.45.4;
Save/restore errno in error path in dupgood. Check that n>0 before
accessing banner[n-1].

Approved a while ago by pooka@
 1.44  15-Mar-2011  pooka don't spam connection errors to stderr by default
 1.43  09-Mar-2011  pooka * use _exit() instead of exit() in retryconn=die: atexit() handlers
may hang if the server is dead
* consistent use of data
 1.42  08-Mar-2011  pooka and for my next trick, i'm going to spell ARGSUSED correctly
 1.41  08-Mar-2011  pooka lint love
 1.40  08-Mar-2011  pooka Since we ~never have a frame waiting on the initial call to waitresp,
call kevent before readframe. Doesn't really affect performance,
but makes ktraces shorter ;)
 1.39  08-Mar-2011  pooka Use sendmsg() instead multiple calls to sendto(). It behaves
slightly better in the multithreaded exec case in terms of partial
frames sent. Plus, it's theoretically a little cheaper.

There's still a gray area with partial transfer from sendmsg(),
but I'm not sure I care enough about some academic scenario to
start fixing it (it basically needs an OOB exec signaller).
 1.38  27-Feb-2011  pooka Take reasonable precautions against init in a parent process
which did a rump-transparent host-only fork().
 1.37  25-Feb-2011  pooka fix __RCSID
 1.36  24-Feb-2011  pooka Fix static fallback path.
 1.35  24-Feb-2011  pooka Make the rumphijack dlsym trampoline call from rumpclient a "real"
function call instead of a call through a function pointer.
Apparently powerpc ld.elf_so gets __hackish_return_address() wrong
if the call is done through a function pointer (digging deeper into
that stuff is beyond my interest).

Thanks to riz for providing access to a macppc for debugging.
Unthanks to the broken toolchain in the default installation which
wasted approximately 4 hours of time last night.
 1.34  24-Feb-2011  pooka Die with a sensible error message if a symbol cannot be found.
 1.33  18-Feb-2011  pooka I think I skipped the class where they taught that multiplication
is done before addition...
 1.32  16-Feb-2011  pooka * set default server connection retry to 0 (no reconnection attempts).
while for some cases attempting retry after server restart works
brilliantly (e.g. firefox), in other cases it's quite disasterous
(sshd doesn't like its file descriptors going missing and does not
attempt to reopen them, leading to a quite catastophic loop of
EBADF once the server does come back)
* rename RUMPHIJACK_RETRY to the slightly more sensible
RUMPHIJACK_RETRYCONNECT
 1.31  16-Feb-2011  pooka Support vfork. Add rumpclient wrapper for daemon(3).
 1.30  16-Feb-2011  pooka Push the fiddly tasks for exec and fork from rumphijack to rumpclient.
This makes it possible easily execute those operations also from
non-hijacked rump clients (plus fixes one memory leak in an error
branch).
 1.29  15-Feb-2011  pooka support HANDSHAKE_EXEC
 1.28  14-Feb-2011  pooka A bunch of changes which essentially make sshd work with a hijacked
rump tcp/ip stack:

* sshd likes to fork and then re-exec itself
==> trap execve() and augment the env with the current parameters
essential to a rump kernel (kernel communication fd, information
about dup2'd file descriptors)

* sshd likes to play lots of games with pipes, socketpairs and dup{,2}()
==> make sure we do not close essential rump client descriptors:
dup() them to a safe place, except for F_CLOSEM where we
simply leave them alone. also, partially solved by the above,
make sure the process's set of rump kernel descriptors persists
over exec()

* sshd likes to chdir() before exec
==> for unix-style rump_sp(7) sockets save the full path on the
initial exec and use it afterwards. thread the path through
the environment in execve()
 1.27  09-Feb-2011  pooka The following happens when sending mail with mutt via a rump
TCP/IP stack:

* mutt prepares to exec the smtp client: it forks and closes all
file descriptors
* when the next networking syscall is done, rumpclient detects that
the communication fd returned EBADF and does a reconnect,
gets descriptor 0 for the socket and descriptor 1 for kqueue
* mutt opens the mail file and implicitly assumes it'll get 0-2,
but in fact gets 2-4
* mutt execs the smtp agent which tries to read the mail from
stdin (rumpclient communication socket) and fails

Even if mutt correctly did dup2() things would go south when trying
to communicate with the kernel server the next time, since rumpclient
would actually be talking with some mail body instead (well, it
could work, but in that case you'd need to write *really* weird
mails ;).

Hence, prevent rumpclient from using the special fd's 0-2 for its
purposes.

Should fix mutt problem reported by Alexander Nasonov.
 1.26  07-Feb-2011  pooka malloc/free aren't async-signal-safe, so avoid calling them when
signals aren't blocked.

this bug made tests/rump/rumpkern/t_sp:sigsafe rarely deadlock
 1.25  07-Feb-2011  pooka make sure we don't use "fullset" before we init it
 1.24  06-Feb-2011  pooka Add another connection retry model which simply does exit(1) if
the connection is severed.
(mostly for tests so that everything can be hooked to rump_server's exit)
 1.23  06-Feb-2011  pooka Make sure to close parent's server communication socket after fork.
 1.22  05-Feb-2011  pooka Fix some snafus to allow rumphijack to work on -current.

reported by Alexander Nasonov
 1.21  28-Jan-2011  pooka Pass the value of getprogname() from the client to the server and
record it in p_comm. This is nice for things like sockstat, since
they now display the client command name:

pain-rustique:43:~> rump.sockstat
USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS
root xulrunner- 16 0 tcp 192.168.2.114.65507 204.152.190.12.80
root xulrunner- 16 1 tcp 192.168.2.114.65501 204.152.190.12.80
root xulrunner- 16 2 tcp 192.168.2.114.65500 204.152.190.12.80
root xulrunner- 16 3 tcp 192.168.2.114.65499 204.152.190.12.80
root xulrunner- 16 5 tcp 192.168.2.114.65498 204.152.190.12.80
root xulrunner- 16 6 tcp 192.168.2.114.65497 204.152.190.12.80
root socket 62 0 tcp6 *.http *.*
root socket 62 1 tcp *.http *.*
root socket 63 0 tcp6 *.81 *.*
root socket 63 1 tcp *.81 *.*
 1.20  27-Jan-2011  pooka Allow to set a timeout for how long the client will attempt to
reconnect in case the connection to the server is lost. Default
to exactly one reattempt. This makes sense and additionally fixes
the dev/raidframe/smalldisk test which currently causes a server
panic when a certain raidctl command is run (without this fix the
test would timeout since the client kept attempting to reconnect).
 1.19  26-Jan-2011  pooka plug fd leak in reconnect code
 1.18  24-Jan-2011  pooka 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.
 1.17  21-Jan-2011  pooka Forgot to commit this a few days ago: need to make sure we get the
right kqueue/kevent now that rumphijack hijacks them.
 1.16  14-Jan-2011  pooka branches: 1.16.2;
Add RUMPSP_RAISE: the kernel sends a signal to the client.
 1.15  10-Jan-2011  pooka 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())
 1.14  09-Jan-2011  pooka 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.
 1.13  07-Jan-2011  pooka 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.
 1.12  06-Jan-2011  pooka Make rumpclient syscalls safe to call from signal handlers.
 1.11  05-Jan-2011  pooka Support fork() for rumpclient users.
 1.10  16-Dec-2010  pooka 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.
 1.9  16-Dec-2010  pooka Print a banner a connecting client. The banner contains rump sp
protocol version, os name, os revision and machine.
 1.8  30-Nov-2010  pooka lintsquelch
 1.7  30-Nov-2010  pooka Change RUMP_SP_CLIENT to RUMP_SERVER. The former was, in addition
to being annoying to write, slightly misguiding, since it contains
the server url.
 1.6  29-Nov-2010  pooka 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.
 1.5  25-Nov-2010  pooka *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.
 1.4  24-Nov-2010  pooka update locking proto, use unputwait
 1.3  19-Nov-2010  pooka 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.
 1.2  05-Nov-2010  pooka use -1/errno for failure: it's much more convenient for the users
 1.1  04-Nov-2010  pooka Add library for rump syscall client stubs.
 1.16.2.3  05-Mar-2011  bouyer Sync with HEAD
 1.16.2.2  17-Feb-2011  bouyer Sync with HEAD
 1.16.2.1  08-Feb-2011  bouyer Sync with HEAD
 1.45.4.4  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.45.4.3  23-Jan-2013  yamt sync with head
 1.45.4.2  30-Oct-2012  yamt sync with head
 1.45.4.1  17-Apr-2012  yamt sync with head
 1.47.2.2  23-Apr-2012  riz Back out changes committed as part of ticket #195 which were apparently
not intended as part of the pullup request. Should fix netbsd-6 build.
 1.47.2.1  23-Apr-2012  riz Pull up following revision(s) (requested by manu in ticket #195):
lib/libskey/skeysubr.c: revision 1.27
lib/libkvm/kvm_getloadavg.c: revision 1.11
lib/libwrap/update.c: revision 1.9
lib/liby/yyerror.c: revision 1.9
lib/libpuffs/puffs_ops.3: revision 1.30
lib/libwrap/misc.c: revision 1.10
lib/libwrap/hosts_access.c: revision 1.20
lib/libpuffs/pnode.c: revision 1.11
lib/libperfuse/subr.c: revision 1.17
lib/libpuffs/pnode.c: revision 1.12
lib/libperfuse/subr.c: revision 1.18
lib/libwrap/options.c: revision 1.15
lib/libwrap/fix_options.c: revision 1.11
lib/libperfuse/ops.c: revision 1.52
lib/libperfuse/ops.c: revision 1.53
lib/libperfuse/ops.c: revision 1.54
lib/libwrap/hosts_ctl.c: revision 1.5
lib/libintl/gettext.c: revision 1.27
lib/libwrap/shell_cmd.c: revision 1.6
lib/libpuffs/dispatcher.c: revision 1.39
lib/libperfuse/perfuse_priv.h: revision 1.27
lib/libwrap/socket.c: revision 1.19
lib/libpuffs/puffs.3: revision 1.50
lib/libperfuse/perfuse_priv.h: revision 1.28
lib/libpuffs/puffs_priv.h: revision 1.45
lib/libpuffs/puffs.3: revision 1.51
lib/libperfuse/perfuse_priv.h: revision 1.29
lib/libwrap/percent_x.c: revision 1.5
lib/libpuffs/puffs.3: revision 1.52
lib/libperfuse/debug.c: revision 1.11
sys/fs/puffs/puffs_vnops.c: revision 1.165
lib/libwrap/tcpd.h: revision 1.13
sys/fs/puffs/puffs_vnops.c: revision 1.166
lib/libwrap/eval.c: revision 1.7
sys/fs/puffs/puffs_msgif.h: revision 1.78
sys/fs/puffs/puffs_vfsops.c: revision 1.101
lib/libwrap/rfc931.c: revision 1.9
lib/libwrap/clean_exit.c: revision 1.5
lib/libpuffs/puffs.h: revision 1.120
lib/libc/stdlib/jemalloc.c: revision 1.27
lib/librmt/rmtlib.c: revision 1.26
lib/libpuffs/puffs.h: revision 1.121
sys/fs/puffs/puffs_sys.h: revision 1.79
lib/librumpclient/rumpclient.c: revision 1.48
lib/libwrap/refuse.c: revision 1.5
lib/libperfuse/perfuse.c: revision 1.26
lib/libperfuse/perfuse.c: revision 1.27
tests/fs/puffs/t_fuzz.c: revision 1.5
lib/libperfuse/perfuse.c: revision 1.28
lib/libpuffs/dispatcher.c: revision 1.40
sys/fs/puffs/puffs_node.c: revision 1.24
lib/libwrap/diag.c: revision 1.9
lib/libintl/textdomain.c: revision 1.13
Use C89 function definition
Add name and atttribute cache with filesytem provided TTL.
lookup, create, mknod, mkdir, symlink, getattr and setattr messages
have been extended so that attributes and their TTL can be provided
by the filesytem. lookup, create, mknod, mkdir, and symlink messages
are also extended so that the filesystem can provide name TTL.
Add PUFFS_KFLAG_CACHE_FS_TTL flag to puffs_init(3) to use name and
attribute cache with filesystem provided TTL.
lookup, create, mknod, mkdir, symlink, getattr and setattr messages
have been extended so that attributes and their TTL can be provided
by the filesytem. lookup, create, mknod, mkdir, and symlink messages
are also extended so that the filesystem can provide name TTL.
The filesystem updates attributes and TTL using
puffs_pn_getvap(3), puffs_pn_getvattl(3), and puffs_pn_getcnttl(3)
Use new PUFFS_KFLAG_CACHE_FS_TTL option to puffs_init(3) so that
FUSE TTL on name and attributes are used. This save many PUFFS
operations and improves performances.
PUFFS_KFLAG_CACHE_FS_TTL is #ifdef'ed in many places for now so that
libperfuse can still be used on netbsd-5.
Split file system.
Comma fixes.
Remove dangling &quot;and&quot;.
Bump date for previous.
- Makesure update_va does not change vnode size when it should not. For
instance when doing a fault-issued VOP_GETPAGES within VOP_WRITE, changing
size leads to panic: genfs_getpages: past eof.
-Handle ticks wrap around for vnode name andattribute timeout
- When using PUFFS_KFLAG_CACHE_FS_TTL, do not use puffs_node to carry
attribute and TTL fora newly created node. Instead extend puffs_newinfo
and add puffs_newinfo_setva() and puffs_newinfo_setttl()
- Remove node_mk_common_final in libperfuse. It used to set uid/gid for
a newly created vnode but has been made redundant along time ago since
uid and gid are properly set in FUSE header.
- In libperfuse, check for corner case where opc = 0 on INACTIVE and RECLAIM
(how is it possible? Check for it to avoid a crash anyway)
- In libperfuse, make sure we unlimit RLIMIT_AS and RLIMIT_DATA so that
we do notrun out of memory because the kernel is lazy at reclaiming vnodes.
- In libperfuse, cleanup style of perfuse_destroy_pn()
Do not set PUFFS_KFLAG_CACHE_FS_TTL for PUFFS tests
 1.51.2.3  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.51.2.2  25-Feb-2013  tls resync with head
 1.51.2.1  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.61.2.1  10-Aug-2014  tls Rebase.

RSS XML Feed