Module Name: src Committed By: pooka Date: Mon Nov 1 13:49:10 UTC 2010
Modified Files: src/lib/librumpuser: rumpuser_sp.c src/sys/rump/include/rump: rumpuser.h src/sys/rump/librump/rumpkern: rump.c Log Message: Make librumpuser linkage once again free of librump. problem pointed out by <he> To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/lib/librumpuser/rumpuser_sp.c cvs rdiff -u -r1.46 -r1.47 src/sys/rump/include/rump/rumpuser.h cvs rdiff -u -r1.193 -r1.194 src/sys/rump/librump/rumpkern/rump.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/librumpuser/rumpuser_sp.c diff -u src/lib/librumpuser/rumpuser_sp.c:1.2 src/lib/librumpuser/rumpuser_sp.c:1.3 --- src/lib/librumpuser/rumpuser_sp.c:1.2 Thu Oct 28 14:37:29 2010 +++ src/lib/librumpuser/rumpuser_sp.c Mon Nov 1 13:49:10 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: rumpuser_sp.c,v 1.2 2010/10/28 14:37:29 pooka Exp $ */ +/* $NetBSD: rumpuser_sp.c,v 1.3 2010/11/01 13:49:10 pooka Exp $ */ /* * Copyright (c) 2010 Antti Kantee. All Rights Reserved. @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: rumpuser_sp.c,v 1.2 2010/10/28 14:37:29 pooka Exp $"); +__RCSID("$NetBSD: rumpuser_sp.c,v 1.3 2010/11/01 13:49:10 pooka Exp $"); #include <sys/types.h> #include <sys/mman.h> @@ -60,6 +60,7 @@ #include <unistd.h> #include <rump/rump.h> +#include <rump/rump_syscalls.h> #include <rump/rumpuser.h> //#define DEBUG @@ -149,6 +150,66 @@ static struct spclient clispc; +static struct rumpuser_sp_ops spops; + +/* + * Manual wrappers, since librump does not have access to the + * user namespace wrapped interfaces. + */ + +static void +lwproc_switch(struct lwp *l) +{ + + rump_schedule(); + spops.spop_lwproc_switch(l); + rump_unschedule(); +} + +static void +lwproc_release(void) +{ + + rump_schedule(); + spops.spop_lwproc_release(); + rump_unschedule(); +} + +static int +lwproc_newproc(void) +{ + int rv; + + rump_schedule(); + rv = spops.spop_lwproc_newproc(); + rump_unschedule(); + + return rv; +} + +static struct lwp * +lwproc_curlwp(void) +{ + struct lwp *l; + + rump_schedule(); + l = spops.spop_lwproc_curlwp(); + rump_unschedule(); + + return l; +} + +static int +rumpsyscall(int sysnum, void *data, register_t *retval) +{ + int rv; + + rump_schedule(); + rv = spops.spop_syscall(sysnum, data, retval); + rump_unschedule(); + + return rv; +} static int dosend(struct spclient *spc, const void *data, size_t dlen) @@ -320,8 +381,8 @@ DPRINTF(("rump_sp: disconnecting [%u]\n", idx)); - rump_pub_lwproc_switch(spc->spc_lwp); - rump_pub_lwproc_releaselwp(); + lwproc_switch(spc->spc_lwp); + lwproc_release(); free(spc->spc_buf); memset(spc, 0, sizeof(*spc)); @@ -373,7 +434,7 @@ return error; } - if ((error = rump_pub_lwproc_newproc()) != 0) { + if ((error = lwproc_newproc()) != 0) { close(newfd); return error; } @@ -389,14 +450,14 @@ pfdlist[i].fd = newfd; spclist[i].spc_fd = newfd; - spclist[i].spc_lwp = rump_pub_lwproc_curlwp(); + spclist[i].spc_lwp = lwproc_curlwp(); if (maxidx < i) maxidx = i; DPRINTF(("rump_sp: added new connection at idx %u, pid %d\n", - i, rump_sys_getpid())); + i, rump_sys_getpid())); /* XXX: getpid not spop */ - rump_pub_lwproc_switch(NULL); + lwproc_switch(NULL); return 0; } @@ -412,9 +473,9 @@ sysnum, 0)); pthread_setspecific(spclient_tls, spc); - rump_pub_lwproc_switch(spc->spc_lwp); - rv = rump_pub_syscall(sysnum, data, retval); - rump_pub_lwproc_switch(NULL); + lwproc_switch(spc->spc_lwp); + rv = rumpsyscall(sysnum, data, retval); + lwproc_switch(NULL); pthread_setspecific(spclient_tls, NULL); send_syscall_resp(spc, rhdr->rsp_reqno, rv, retval); @@ -848,7 +909,7 @@ } int -rumpuser_sp_init(int *typep) +rumpuser_sp_init(const struct rumpuser_sp_ops *spopsp, int *typep) { struct spservarg *sarg; struct sockaddr *sap; @@ -860,6 +921,7 @@ p = NULL; error = 0; + spops = *spopsp; type = RUMP_SP_NONE; if ((p = getenv("RUMP_SP_SERVER")) != NULL) { Index: src/sys/rump/include/rump/rumpuser.h diff -u src/sys/rump/include/rump/rumpuser.h:1.46 src/sys/rump/include/rump/rumpuser.h:1.47 --- src/sys/rump/include/rump/rumpuser.h:1.46 Wed Oct 27 20:44:50 2010 +++ src/sys/rump/include/rump/rumpuser.h Mon Nov 1 13:49:10 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: rumpuser.h,v 1.46 2010/10/27 20:44:50 pooka Exp $ */ +/* $NetBSD: rumpuser.h,v 1.47 2010/11/01 13:49:10 pooka Exp $ */ /* * Copyright (c) 2007 Antti Kantee. All Rights Reserved. @@ -36,7 +36,7 @@ #include <stdint.h> #endif -#define RUMPUSER_VERSION 1 +#define RUMPUSER_VERSION 2 int rumpuser_getversion(void); struct msghdr; @@ -203,13 +203,23 @@ void rumpuser_dl_component_init(int, rump_component_init_fn); /* syscall proxy routines */ -#define RUMP_SP_NONE 0 -#define RUMP_SP_CLIENT 1 -#define RUMP_SP_SERVER 2 -int rumpuser_sp_init(int *); + +struct rumpuser_sp_ops { + void (*spop_lwproc_switch)(struct lwp *); + void (*spop_lwproc_release)(void); + int (*spop_lwproc_newproc)(void); + struct lwp * (*spop_lwproc_curlwp)(void); + int (*spop_syscall)(int, void *, register_t *); +}; + +int rumpuser_sp_init(const struct rumpuser_sp_ops *, int *); int rumpuser_sp_copyin(const void *, void *, size_t); int rumpuser_sp_copyout(const void *, void *, size_t); int rumpuser_sp_syscall(int, const void *, size_t, register_t *); int rumpuser_sp_anonmmap(size_t, void **); +#define RUMP_SP_NONE 0 +#define RUMP_SP_CLIENT 1 +#define RUMP_SP_SERVER 2 + #endif /* _RUMP_RUMPUSER_H_ */ Index: src/sys/rump/librump/rumpkern/rump.c diff -u src/sys/rump/librump/rumpkern/rump.c:1.193 src/sys/rump/librump/rumpkern/rump.c:1.194 --- src/sys/rump/librump/rumpkern/rump.c:1.193 Fri Oct 29 15:32:24 2010 +++ src/sys/rump/librump/rumpkern/rump.c Mon Nov 1 13:49:10 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: rump.c,v 1.193 2010/10/29 15:32:24 pooka Exp $ */ +/* $NetBSD: rump.c,v 1.194 2010/11/01 13:49:10 pooka Exp $ */ /* * Copyright (c) 2007 Antti Kantee. All Rights Reserved. @@ -28,7 +28,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.193 2010/10/29 15:32:24 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.194 2010/11/01 13:49:10 pooka Exp $"); #include <sys/systm.h> #define ELFSIZE ARCH_ELFSIZE @@ -191,6 +191,7 @@ int rump__init(int rump_version) { + struct rumpuser_sp_ops spops; char buf[256]; struct timespec ts; uint64_t sec, nsec; @@ -207,7 +208,12 @@ rump_inited = 1; /* Check our role as a rump proxy */ - if ((error = rumpuser_sp_init(&rumpsp_type)) != 0) + spops.spop_lwproc_switch = rump_lwproc_switch; + spops.spop_lwproc_release = rump_lwproc_releaselwp; + spops.spop_lwproc_newproc = rump_lwproc_newproc; + spops.spop_lwproc_curlwp = rump_lwproc_curlwp; + spops.spop_syscall = rump_syscall; + if ((error = rumpuser_sp_init(&spops, &rumpsp_type)) != 0) return error; /* If we're a client, we can return directly. Otherwise, proceed. */