sunrpc: Start making sunrpc work in containers
Subsystems (3)
cover sunrpc: Start making sunrpc work in containers
Hello everyone!
I would like to prepare the sunrpc layer for working in a containerized environments. The ultimate goal is to make both nfs client and server work in containers. Hopefully you won't object :)
Not to look like an idle talker I've prepared this set which makes the /proc/net/rpc appear in net namespaces and made the ip_map_cache be per-net.
I do not have any plans about when this patches appear at Linus tree and thus do not know which git tree to hack on. That said I prepared the patches against the net-next tree (I have some custom netns debugging code in it and don't want to port it around in vain).
Looking forward to your feedback.
Thanks,
Pavel
PATCH 1/9 sunrpc: Pass the ip_map_parse's cd to lower calls
The target is to have many ip_map_cache-s in the system. This particular patch handles its usage by the ip_map_parse callback.
--- net/sunrpc/svcauth_unix.c | 31 +++++++++++++++++++++---------- 1 files changed, 21 insertions(+), 10 deletions(-)
net/sunrpc/svcauth_unix.c +21 -10
@@ -178,8 +178,8 @@ static int ip_map_upcall(struct cache_detail *cd, struct cache_head *h)return sunrpc_cache_pipe_upcall (cd, h, ip_map_request); } -static struct ip_map *ip_map_lookup (char *class,struct in6_addr *addr); -static int ip_map_update (struct ip_map *ipm,struct unix_domain *udom,time_t expiry); +static struct ip_map *__ip_map_lookup (struct cache_detail *cd,char *class,struct in6_addr *addr); +static int __ip_map_update (struct cache_detail *cd,struct ip_map *ipm,struct unix_domain *udom,time_t expiry);static int ip_map_parse (struct cache_detail *cd,char *mesg,int mlen)
@@ -249,9 +249,9 @@ static int ip_map_parse(struct cache_detail *cd, dom =NULL ;/* IPv6 scope IDs are ignored for now */ - ipmp =ip_map_lookup (class, &sin6.sin6_addr); + ipmp =__ip_map_lookup (cd, class, &sin6.sin6_addr);if (ipmp) { - err =ip_map_update (ipmp, + err =__ip_map_update (cd, ipmp, container_of(dom, struct unix_domain, h), expiry); }else
@@ -309,14 +309,15 @@ struct cache_detail ip_map_cache = { .alloc = ip_map_alloc, }; -static struct ip_map *ip_map_lookup (char *class,struct in6_addr *addr) +static struct ip_map *__ip_map_lookup (struct cache_detail *cd,char *class, +struct in6_addr *addr) {struct ip_map ip;struct cache_head *ch;strcpy (ip.m_class, class);ipv6_addr_copy (&ip.m_addr, addr); - ch =sunrpc_cache_lookup (&ip_map_cache, &ip.h, + ch =sunrpc_cache_lookup (cd, &ip.h,hash_str (class,IP_HASHBITS ) ^hash_ip6 (*addr));
@@ -326,7 +327,13 @@ static struct ip_map *ip_map_lookup(char *class, struct in6_addr *addr)return NULL ; } -static int ip_map_update (struct ip_map *ipm,struct unix_domain *udom,time_t expiry) +static inline struct ip_map *ip_map_lookup (char *class,struct in6_addr *addr) +{ +return __ip_map_lookup (&ip_map_cache, class, addr); +} + +static int __ip_map_update (struct cache_detail *cd,struct ip_map *ipm, +struct unix_domain *udom,time_t expiry) {struct ip_map ip;struct cache_head *ch;
@@ -344,16 +351,20 @@ static int ip_map_update(struct ip_map *ipm, struct unix_domain *udom, time_t ex ip.m_add_change++; } ip.h.expiry_time = expiry; - ch =sunrpc_cache_update (&ip_map_cache, - &ip.h, &ipm->h, + ch =sunrpc_cache_update (cd, &ip.h, &ipm->h,hash_str (ipm->m_class,IP_HASHBITS ) ^hash_ip6 (ipm->m_addr));if (!ch)return -ENOMEM ; -cache_put (ch, &ip_map_cache); +cache_put (ch, cd);return 0 ; } +static inline int ip_map_update (struct ip_map *ipm,struct unix_domain *udom,time_t expiry) +{ +return __ip_map_update (&ip_map_cache, ipm, udom, expiry); +} +int auth_unix_add_addr (struct in6_addr *addr,struct auth_domain *dom) {struct unix_domain *udom;
Signature · 1 line
1.5.5.6
PATCH 2/9 sunrpc: Make xprt auth cache release work with the xprt
In reply to Pavel EmelyanovThis is done in order to facilitate getting the ip_map_cache from which to put the ip_map.
--- include/linux/sunrpc/svcauth.h | 3 ++- net/sunrpc/svc_xprt.c | 5 ++--- net/sunrpc/svcauth_unix.c | 9 ++++++--- 3 files changed, 10 insertions(+), 7 deletions(-)
include/linux/sunrpc/svcauth.h +2 -1
@@ -112,6 +112,7 @@ struct auth_ops {#define SVC_PENDING 8#define SVC_COMPLETE 9 +struct svc_xprt ;extern int svc_authenticate (struct svc_rqst *rqstp,__be32 *authp);extern int svc_authorise (struct svc_rqst *rqstp);
@@ -127,7 +128,7 @@ extern struct auth_domain *auth_domain_find(char *name);extern struct auth_domain *auth_unix_lookup (struct in6_addr *addr);extern int auth_unix_forget_old (struct auth_domain *dom);extern void svcauth_unix_purge (void ); -extern void svcauth_unix_info_release (void *); +extern void svcauth_unix_info_release (struct svc_xprt *xpt);extern int svcauth_unix_set_client (struct svc_rqst *rqstp);static inline unsigned long hash_str (char *name,int bits)
net/sunrpc/svc_xprt.c +2 -3
@@ -128,9 +128,8 @@ static void svc_xprt_free(struct kref *kref)struct svc_xprt *xprt = container_of(kref, struct svc_xprt, xpt_ref);struct module *owner = xprt->xpt_class->xcl_owner; -if (test_bit (XPT_CACHE_AUTH , &xprt->xpt_flags) && - xprt->xpt_auth_cache !=NULL ) -svcauth_unix_info_release (xprt->xpt_auth_cache); +if (test_bit (XPT_CACHE_AUTH , &xprt->xpt_flags)) +svcauth_unix_info_release (xprt); xprt->xpt_ops->xpo_free (xprt);module_put (owner); }
net/sunrpc/svcauth_unix.c +6 -3
@@ -472,10 +472,13 @@ ip_map_cached_put(struct svc_rqst *rqstp, struct ip_map *ipm) }void -svcauth_unix_info_release (void *info) +svcauth_unix_info_release (struct svc_xprt *xpt) { -struct ip_map *ipm = info; -cache_put (&ipm->h, &ip_map_cache); +struct ip_map *ipm; + + ipm = xpt->xpt_auth_cache; +if (ipm !=NULL ) +cache_put (&ipm->h, &ip_map_cache); }/****************************************************************************
Signature · 1 line
1.5.5.6
PATCH 3/9 sunrpc: Pass xprt to cached get/put routines
In reply to Pavel EmelyanovThey do not require the rqst actually and having the xprt simplifies further patching.
--- net/sunrpc/svcauth_unix.c | 12 +++++------- 1 files changed, 5 insertions(+), 7 deletions(-)
net/sunrpc/svcauth_unix.c +5 -7
@@ -426,10 +426,9 @@ void svcauth_unix_purge(void)EXPORT_SYMBOL_GPL (svcauth_unix_purge);static inline struct ip_map * -ip_map_cached_get (struct svc_rqst *rqstp) +ip_map_cached_get (struct svc_xprt *xprt) {struct ip_map *ipm =NULL ; -struct svc_xprt *xprt = rqstp->rq_xprt;if (test_bit (XPT_CACHE_AUTH , &xprt->xpt_flags)) {spin_lock (&xprt->xpt_lock);
@@ -454,10 +453,8 @@ ip_map_cached_get(struct svc_rqst *rqstp) }static inline void -ip_map_cached_put (struct svc_rqst *rqstp,struct ip_map *ipm) +ip_map_cached_put (struct svc_xprt *xprt,struct ip_map *ipm) { -struct svc_xprt *xprt = rqstp->rq_xprt; -if (test_bit (XPT_CACHE_AUTH , &xprt->xpt_flags)) {spin_lock (&xprt->xpt_lock);if (xprt->xpt_auth_cache ==NULL ) {
@@ -705,6 +702,7 @@ svcauth_unix_set_client(struct svc_rqst *rqstp)struct ip_map *ipm;struct group_info *gi;struct svc_cred *cred = &rqstp->rq_cred; +struct svc_xprt *xprt = rqstp->rq_xprt;switch (rqstp->rq_addr.ss_family) {case AF_INET :
@@ -723,7 +721,7 @@ svcauth_unix_set_client(struct svc_rqst *rqstp)if (rqstp->rq_proc ==0 )return SVC_OK ; - ipm =ip_map_cached_get (rqstp); + ipm =ip_map_cached_get (xprt);if (ipm ==NULL ) ipm =ip_map_lookup (rqstp->rq_server->sv_program->pg_class, &sin6->sin6_addr);
@@ -742,7 +740,7 @@ svcauth_unix_set_client(struct svc_rqst *rqstp)case 0 : rqstp->rq_client = &ipm->m_client->h;kref_get (&rqstp->rq_client->ref); -ip_map_cached_put (rqstp, ipm); +ip_map_cached_put (xprt, ipm);break ; }
Signature · 1 line
1.5.5.6
PATCH 4/9 sunrpc: Add net to pure API calls
In reply to Pavel EmelyanovThere are two calls that operate on ip_map_cache and are directly called from the nfsd code. Other places will be handled in a different way.
--- fs/nfsd/export.c | 2 +- fs/nfsd/nfsctl.c | 4 ++-- include/linux/sunrpc/svcauth.h | 4 ++-- net/sunrpc/svcauth_unix.c | 18 ++++++++++-------- 4 files changed, 15 insertions(+), 13 deletions(-)
fs/nfsd/export.c +1 -1
@@ -1563,7 +1563,7 @@ exp_addclient(struct nfsctl_client *ncp)/* Insert client into hashtable. */ for (i =0 ; i < ncp->cl_naddr; i++) {ipv6_addr_set_v4mapped (ncp->cl_addrlist[i].s_addr, &addr6); -auth_unix_add_addr (&addr6, dom); +auth_unix_add_addr (&init_net, &addr6, dom); }auth_unix_forget_old (dom);auth_domain_put (dom);
fs/nfsd/nfsctl.c +2 -2
@@ -401,7 +401,7 @@ static ssize_t write_getfs(struct file *file, char *buf, size_t size)ipv6_addr_set_v4mapped (sin->sin_addr.s_addr, &in6); - clp =auth_unix_lookup (&in6); + clp =auth_unix_lookup (&init_net, &in6);if (!clp) err = -EPERM ;else {
@@ -464,7 +464,7 @@ static ssize_t write_getfd(struct file *file, char *buf, size_t size)ipv6_addr_set_v4mapped (sin->sin_addr.s_addr, &in6); - clp =auth_unix_lookup (&in6); + clp =auth_unix_lookup (&init_net, &in6);if (!clp) err = -EPERM ;else {
include/linux/sunrpc/svcauth.h +2 -2
@@ -122,10 +122,10 @@ extern void svc_auth_unregister(rpc_authflavor_t flavor);extern struct auth_domain *unix_domain_find (char *name);extern void auth_domain_put (struct auth_domain *item); -extern int auth_unix_add_addr (struct in6_addr *addr,struct auth_domain *dom); +extern int auth_unix_add_addr (struct net *net,struct in6_addr *addr,struct auth_domain *dom);extern struct auth_domain *auth_domain_lookup (char *name,struct auth_domain *new);extern struct auth_domain *auth_domain_find (char *name); -extern struct auth_domain *auth_unix_lookup (struct in6_addr *addr); +extern struct auth_domain *auth_unix_lookup (struct net *net,struct in6_addr *addr);extern int auth_unix_forget_old (struct auth_domain *dom);extern void svcauth_unix_purge (void );extern void svcauth_unix_info_release (struct svc_xprt *xpt);
net/sunrpc/svcauth_unix.c +10 -8
@@ -327,7 +327,8 @@ static struct ip_map *__ip_map_lookup(struct cache_detail *cd, char *class,return NULL ; } -static inline struct ip_map *ip_map_lookup (char *class,struct in6_addr *addr) +static inline struct ip_map *ip_map_lookup (struct net *net,char *class, +struct in6_addr *addr) {return __ip_map_lookup (&ip_map_cache, class, addr); }
@@ -360,12 +361,13 @@ static int __ip_map_update(struct cache_detail *cd, struct ip_map *ipm,return 0 ; } -static inline int ip_map_update (struct ip_map *ipm,struct unix_domain *udom,time_t expiry) +static inline int ip_map_update (struct net *net,struct ip_map *ipm, +struct unix_domain *udom,time_t expiry) {return __ip_map_update (&ip_map_cache, ipm, udom, expiry); } -int auth_unix_add_addr (struct in6_addr *addr,struct auth_domain *dom) +int auth_unix_add_addr (struct net *net,struct in6_addr *addr,struct auth_domain *dom) {struct unix_domain *udom;struct ip_map *ipmp;
@@ -373,10 +375,10 @@ int auth_unix_add_addr(struct in6_addr *addr, struct auth_domain *dom)if (dom->flavour != &svcauth_unix)return -EINVAL ; udom = container_of(dom, struct unix_domain, h); - ipmp =ip_map_lookup ("nfsd" , addr); + ipmp =ip_map_lookup (net,"nfsd" , addr);if (ipmp) -return ip_map_update (ipmp, udom,NEVER ); +return ip_map_update (net, ipmp, udom,NEVER );else return -ENOMEM ; }
@@ -394,12 +396,12 @@ int auth_unix_forget_old(struct auth_domain *dom) }EXPORT_SYMBOL_GPL (auth_unix_forget_old); -struct auth_domain *auth_unix_lookup (struct in6_addr *addr) +struct auth_domain *auth_unix_lookup (struct net *net,struct in6_addr *addr) {struct ip_map *ipm;struct auth_domain *rv; - ipm =ip_map_lookup ("nfsd" , addr); + ipm =ip_map_lookup (net,"nfsd" , addr);if (!ipm)return NULL ;
@@ -723,7 +725,7 @@ svcauth_unix_set_client(struct svc_rqst *rqstp) ipm =ip_map_cached_get (xprt);if (ipm ==NULL ) - ipm =ip_map_lookup (rqstp->rq_server->sv_program->pg_class, + ipm =ip_map_lookup (&init_net, rqstp->rq_server->sv_program->pg_class, &sin6->sin6_addr);if (ipm ==NULL )
Signature · 1 line
1.5.5.6
PATCH 5/9 sunrpc: Add routines that allow registering per-net caches
In reply to Pavel EmelyanovExisting calls do the same, but for the init_net.
--- include/linux/sunrpc/cache.h | 2 ++ net/sunrpc/cache.c | 26 ++++++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-)
include/linux/sunrpc/cache.h +2 -0
@@ -194,7 +194,9 @@ extern void cache_purge(struct cache_detail *detail);#define NEVER (0x7FFFFFFF)extern void __init cache_initialize (void );extern int cache_register (struct cache_detail *cd); +extern int cache_register_net (struct cache_detail *cd,struct net *net);extern void cache_unregister (struct cache_detail *cd); +extern void cache_unregister_net (struct cache_detail *cd,struct net *net);extern int sunrpc_cache_register_pipefs (struct dentry *parent,const char *,mode_t ,struct cache_detail *);
net/sunrpc/cache.c +18 -8
@@ -1443,7 +1443,7 @@ static const struct file_operations cache_flush_operations_procfs = { .release = release_flush_procfs, }; -static void remove_cache_proc_entries (struct cache_detail *cd) +static void remove_cache_proc_entries (struct cache_detail *cd,struct net *net) {if (cd->u.procfs.proc_ent ==NULL )return ;
@@ -1458,7 +1458,7 @@ static void remove_cache_proc_entries(struct cache_detail *cd) }#ifdef CONFIG_PROC_FS -static int create_cache_proc_entries (struct cache_detail *cd) +static int create_cache_proc_entries (struct cache_detail *cd,struct net *net) {struct proc_dir_entry *p;
@@ -1493,11 +1493,11 @@ static int create_cache_proc_entries(struct cache_detail *cd) }return 0 ; out_nomem: -remove_cache_proc_entries (cd); +remove_cache_proc_entries (cd, net);return -ENOMEM ; }#else /* CONFIG_PROC_FS */ -static int create_cache_proc_entries (struct cache_detail *cd) +static int create_cache_proc_entries (struct cache_detail *cd,struct net *net) {return 0 ; }
@@ -1508,23 +1508,33 @@ void __init cache_initialize(void)INIT_DELAYED_WORK_DEFERRABLE (&cache_cleaner, do_cache_clean); } -int cache_register (struct cache_detail *cd) +int cache_register_net (struct cache_detail *cd,struct net *net) {int ret;sunrpc_init_cache_detail (cd); - ret =create_cache_proc_entries (cd); + ret =create_cache_proc_entries (cd, net);if (ret)sunrpc_destroy_cache_detail (cd);return ret; } + +int cache_register (struct cache_detail *cd) +{ +return cache_register_net (cd, &init_net); +}EXPORT_SYMBOL_GPL (cache_register); -void cache_unregister (struct cache_detail *cd) +void cache_unregister_net (struct cache_detail *cd,struct net *net) { -remove_cache_proc_entries (cd); +remove_cache_proc_entries (cd, net);sunrpc_destroy_cache_detail (cd); } + +void cache_unregister (struct cache_detail *cd) +{ +cache_unregister_net (cd, &init_net); +}EXPORT_SYMBOL_GPL (cache_unregister); static ssize_t cache_read_pipefs(struct file *filp, char __user *buf,
Signature · 1 line
1.5.5.6
PATCH 6/9 sunrpc: Tag svc_xprt with net
In reply to Pavel EmelyanovThe transport representation should be per-net of course.
--- include/linux/sunrpc/svc_xprt.h | 2 ++ net/sunrpc/svc_xprt.c | 2 ++ 2 files changed, 4 insertions(+), 0 deletions(-)
include/linux/sunrpc/svc_xprt.h +2 -0
@@ -66,6 +66,8 @@ struct svc_xprt {struct sockaddr_storage xpt_remote;/* remote peer's address */ size_t xpt_remotelen;/* length of address */ struct rpc_wait_queue xpt_bc_pending;/* backchannel wait queue */ + +struct net *xpt_net; };int svc_reg_xprt_class (struct svc_xprt_class *);
net/sunrpc/svc_xprt.c +2 -0
@@ -130,6 +130,7 @@ static void svc_xprt_free(struct kref *kref)struct module *owner = xprt->xpt_class->xcl_owner;if (test_bit (XPT_CACHE_AUTH , &xprt->xpt_flags))svcauth_unix_info_release (xprt); +put_net (xprt->xpt_net); xprt->xpt_ops->xpo_free (xprt);module_put (owner); }
@@ -159,6 +160,7 @@ void svc_xprt_init(struct svc_xprt_class *xcl, struct svc_xprt *xprt,spin_lock_init (&xprt->xpt_lock);set_bit (XPT_BUSY , &xprt->xpt_flags);rpc_init_wait_queue (&xprt->xpt_bc_pending,"xpt_bc_pending" ); + xprt->xpt_net =get_net (&init_net); }EXPORT_SYMBOL_GPL (svc_xprt_init);
Signature · 1 line
1.5.5.6
PATCH 7/9 sunrpc: The per-net skeleton
In reply to Pavel EmelyanovRegister empty per-net operations for the sunrpc layer.
--- net/sunrpc/netns.h | 12 ++++++++++++ net/sunrpc/sunrpc_syms.c | 31 ++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletions(-) create mode 100644 net/sunrpc/netns.h
net/sunrpc/netns.h new file +12 -0
@@ -0,0 +1,12 @@ +#ifndef __SUNRPC_NETNS_H__ +#define __SUNRPC_NETNS_H__ + +#include <net/net_namespace.h> +#include <net/netns/generic.h> + +struct sunrpc_net { +}; + +extern int sunrpc_net_id; + +#endif
net/sunrpc/sunrpc_syms.c +30 -1
@@ -22,6 +22,26 @@#include <linux/sunrpc/rpc_pipe_fs.h> #include <linux/sunrpc/xprtsock.h> +#include "netns.h" + +int sunrpc_net_id; + +static __net_init int sunrpc_init_net (struct net *net) +{ +return 0 ; +} + +static __net_exit void sunrpc_exit_net(struct net *net) +{ +} + +static struct pernet_operations sunrpc_net_ops = { + .init = sunrpc_init_net, + .exit = sunrpc_exit_net, + .id = &sunrpc_net_id, + .size =sizeof (struct sunrpc_net ), +}; +extern struct cache_detail ip_map_cache, unix_gid_cache;extern void cleanup_rpcb_clnt (void );
@@ -38,18 +58,26 @@ init_sunrpc(void) err =rpcauth_init_module ();if (err) goto out3; + +cache_initialize (); + + err =register_pernet_subsys (&sunrpc_net_ops); +if (err) + goto out4;#ifdef RPC_DEBUG rpc_register_sysctl ();#endif #ifdef CONFIG_PROC_FS rpc_proc_init ();#endif -cache_initialize ();cache_register (&ip_map_cache);cache_register (&unix_gid_cache);svc_init_xprt_sock ();/* svc sock transport */ init_socket_xprt ();/* clnt sock transport */ return 0 ; + +out4: +unregister_pernet_subsys (&sunrpc_net_ops); out3:rpc_destroy_mempool (); out2:
@@ -69,6 +97,7 @@ cleanup_sunrpc(void)rpc_destroy_mempool ();cache_unregister (&ip_map_cache);cache_unregister (&unix_gid_cache); +unregister_pernet_subsys (&sunrpc_net_ops);#ifdef RPC_DEBUG rpc_unregister_sysctl ();#endif
Signature · 1 line
1.5.5.6
Re: [PATCH 7/9] sunrpc: The per-net skeleton
Quoted 15 lines · Pavel Emelyanov
net/sunrpc/sunrpc_syms.c +6
-0@@ -38,18 +58,26 @@ init_sunrpc(void) err =rpcauth_init_module ();if (err) goto out3; + +cache_initialize (); + + err =register_pernet_subsys (&sunrpc_net_ops); +if (err) + goto out4;#ifdef RPC_DEBUG rpc_register_sysctl ();#endif #ifdef CONFIG_PROC_FS rpc_proc_init ();
net/sunrpc/sunrpc_syms.c init_sunrpc(void) · line 80
Quoted 10 lines
net/sunrpc/sunrpc_syms.c +3
-1#endif -cache_initialize ();cache_register (&ip_map_cache);cache_register (&unix_gid_cache);svc_init_xprt_sock ();/* svc sock transport */ init_socket_xprt ();/* clnt sock transport */ return 0 ; + +out4: +unregister_pernet_subsys (&sunrpc_net_ops);
If register_pernet_subsys() failed, then shouldn't this be unnecessary? Maybe this should be rpcauth_remove_module()?
--b.
Quoted 14 lines
net/sunrpc/sunrpc_syms.c +1
-0out3:rpc_destroy_mempool (); out2:@@ -69,6 +97,7 @@ cleanup_sunrpc(void)rpc_destroy_mempool ();cache_unregister (&ip_map_cache);cache_unregister (&unix_gid_cache); +unregister_pernet_subsys (&sunrpc_net_ops);#ifdef RPC_DEBUG rpc_unregister_sysctl ();#endif Signature · 1 line
1.5.5.6
Re: [PATCH 7/9] sunrpc: The per-net skeleton
Quoted 21 lines · J. Bruce Fields
Quoted 20 lines · Pavel Emelyanov
net/sunrpc/sunrpc_syms.c +6
-1@@ -38,18 +58,26 @@ init_sunrpc(void) err =rpcauth_init_module ();if (err) goto out3; + +cache_initialize (); + + err =register_pernet_subsys (&sunrpc_net_ops); +if (err) + goto out4;#ifdef RPC_DEBUG rpc_register_sysctl ();#endif #ifdef CONFIG_PROC_FS rpc_proc_init ();#endif -cache_initialize ();cache_register (&ip_map_cache);cache_register (&unix_gid_cache);svc_init_xprt_sock ();/* svc sock transport */
Quoted 8 lines
net/sunrpc/sunrpc_syms.c init_sunrpc(void) · line 80
Quoted 5 lines
net/sunrpc/sunrpc_syms.c +3
-0init_socket_xprt ();/* clnt sock transport */ return 0 ; + +out4: +unregister_pernet_subsys (&sunrpc_net_ops);If
register_pernet_subsys()failed, then shouldn't this be unnecessary? Maybe this should berpcauth_remove_module()?
Ouch! Of course you're right here... Will fix.
Quoted 1 line
--b.
PATCH 8/9 sunrpc: Make the /proc/net/rpc appear in net namespaces
In reply to Pavel Emelyanov--- include/linux/sunrpc/stats.h | 23 ++++++++++++++------- net/sunrpc/cache.c | 10 +++++++- net/sunrpc/netns.h | 1 + net/sunrpc/stats.c | 43 ++++++++++++++++++++++++----------------- net/sunrpc/sunrpc_syms.c | 16 +++++++++----- 5 files changed, 59 insertions(+), 34 deletions(-)
include/linux/sunrpc/stats.h +15 -8
@@ -38,8 +38,21 @@ struct svc_stat { rpcbadclnt; }; -void rpc_proc_init (void ); -void rpc_proc_exit (void ); +struct net ; +#ifdef CONFIG_PROC_FS +int rpc_proc_init (struct net *); +void rpc_proc_exit (struct net *); +#else +static inline int rpc_proc_init (struct net *net) +{ +return 0 ; +} + +static inline void rpc_proc_exit (struct net *net) +{ +} +#endif +#ifdef MODULE void rpc_modcount (struct inode *,int );#endif
@@ -54,9 +67,6 @@ void svc_proc_unregister(const char *);void svc_seq_show (struct seq_file *,const struct svc_stat *); - -extern struct proc_dir_entry *proc_net_rpc; -#else static inline struct proc_dir_entry *rpc_proc_register (struct rpc_stat *s) {return NULL ; }
@@ -69,9 +79,6 @@ static inline void svc_proc_unregister(const char *p) {}static inline void svc_seq_show (struct seq_file *seq,const struct svc_stat *st) {} - -#define proc_net_rpc NULL -#endif #endif /* _LINUX_SUNRPC_STATS_H */
net/sunrpc/cache.c +8 -2
@@ -34,6 +34,7 @@#include <linux/sunrpc/cache.h> #include <linux/sunrpc/stats.h> #include <linux/sunrpc/rpc_pipe_fs.h> +#include "netns.h" #define RPCDBG_FACILITY RPCDBG_CACHE
@@ -1445,6 +1446,8 @@ static const struct file_operations cache_flush_operations_procfs = {static void remove_cache_proc_entries (struct cache_detail *cd,struct net *net) { +struct sunrpc_net *sn; +if (cd->u.procfs.proc_ent ==NULL )return ;if (cd->u.procfs.flush_ent)
@@ -1454,15 +1457,18 @@ static void remove_cache_proc_entries(struct cache_detail *cd, struct net *net)if (cd->u.procfs.content_ent)remove_proc_entry ("content" , cd->u.procfs.proc_ent); cd->u.procfs.proc_ent =NULL ; -remove_proc_entry (cd->name, proc_net_rpc); + sn =net_generic (net, sunrpc_net_id); +remove_proc_entry (cd->name, sn->proc_net_rpc); }#ifdef CONFIG_PROC_FS static int create_cache_proc_entries (struct cache_detail *cd,struct net *net) {struct proc_dir_entry *p; +struct sunrpc_net *sn; - cd->u.procfs.proc_ent =proc_mkdir (cd->name, proc_net_rpc); + sn =net_generic (net, sunrpc_net_id); + cd->u.procfs.proc_ent =proc_mkdir (cd->name, sn->proc_net_rpc);if (cd->u.procfs.proc_ent ==NULL ) goto out_nomem; cd->u.procfs.channel_ent =NULL ;
net/sunrpc/netns.h +1 -0
@@ -5,6 +5,7 @@#include <net/netns/generic.h> struct sunrpc_net { +struct proc_dir_entry *proc_net_rpc; };extern int sunrpc_net_id;
net/sunrpc/stats.c +25 -18
78 lines not on this page · raw message
net/sunrpc/sunrpc_syms.c +10 -6
@@ -28,11 +28,21 @@ int sunrpc_net_id;static __net_init int sunrpc_init_net (struct net *net) { +int err; + + err =rpc_proc_init (net); +if (err) + goto err_proc; +return 0 ; + +err_proc: +return err; } static __net_exit void sunrpc_exit_net(struct net *net) { +rpc_proc_exit (net); }static struct pernet_operations sunrpc_net_ops = {
@@ -67,9 +77,6 @@ init_sunrpc(void)#ifdef RPC_DEBUG rpc_register_sysctl ();#endif -#ifdef CONFIG_PROC_FS -rpc_proc_init (); -#endif cache_register (&ip_map_cache);cache_register (&unix_gid_cache);svc_init_xprt_sock ();/* svc sock transport */
@@ -101,9 +108,6 @@ cleanup_sunrpc(void)#ifdef RPC_DEBUG rpc_unregister_sysctl ();#endif -#ifdef CONFIG_PROC_FS -rpc_proc_exit (); -#endif rcu_barrier ();/* Wait for completion of call_rcu()'s */ }MODULE_LICENSE ("GPL" );
Signature · 1 line
1.5.5.6
PATCH 9/9 sunrpc: Make the ip_map_cache be per-net
In reply to Pavel EmelyanovEverything that is required for that already exists:
* the per-net cache registration with respective proc entries
* the context (struct net) is available in all the users
--- net/sunrpc/netns.h | 6 ++ net/sunrpc/sunrpc_syms.c | 11 +++- net/sunrpc/svcauth_unix.c | 122 ++++++++++++++++++++++++++++++++++---------- 3 files changed, 108 insertions(+), 31 deletions(-)
net/sunrpc/netns.h +6 -0
@@ -4,10 +4,16 @@#include <net/net_namespace.h> #include <net/netns/generic.h> +struct cache_detail ; +struct sunrpc_net {struct proc_dir_entry *proc_net_rpc; +struct cache_detail *ip_map_cache; };extern int sunrpc_net_id; +int ip_map_cache_create (struct net *); +void ip_map_cache_destroy (struct net *); +#endif
net/sunrpc/sunrpc_syms.c +8 -3
@@ -34,14 +34,21 @@ static __net_init int sunrpc_init_net(struct net *net)if (err) goto err_proc; + err =ip_map_cache_create (net); +if (err) + goto err_ipmap; +return 0 ; +err_ipmap: +rpc_proc_exit (net); err_proc:return err; } static __net_exit void sunrpc_exit_net(struct net *net) { +ip_map_cache_destroy (net);rpc_proc_exit (net); }
@@ -52,7 +59,7 @@ static struct pernet_operations sunrpc_net_ops = { .size = sizeof(struct sunrpc_net), }; -extern struct cache_detail ip_map_cache, unix_gid_cache; +extern struct cache_detail unix_gid_cache;extern void cleanup_rpcb_clnt (void );
@@ -77,7 +84,6 @@ init_sunrpc(void)#ifdef RPC_DEBUG rpc_register_sysctl ();#endif -cache_register (&ip_map_cache);cache_register (&unix_gid_cache);svc_init_xprt_sock ();/* svc sock transport */ init_socket_xprt ();/* clnt sock transport */
@@ -102,7 +108,6 @@ cleanup_sunrpc(void)svc_cleanup_xprt_sock ();unregister_rpc_pipefs ();rpc_destroy_mempool (); -cache_unregister (&ip_map_cache);cache_unregister (&unix_gid_cache);unregister_pernet_subsys (&sunrpc_net_ops);#ifdef RPC_DEBUG
net/sunrpc/svcauth_unix.c +94 -28
221 lines not on this page · raw message
Signature · 1 line
1.5.5.6
Quoted 9 lines · Pavel Emelyanov
Hello everyone!
I would like to prepare the sunrpc layer for working in a containerized environments. The ultimate goal is to make both nfs client and server work in containers. Hopefully you won't object :)
Not to look like an idle talker I've prepared this set which makes the
/proc/net/rpcappear in net namespaces and made theip_map_cachebe per-net.
Quoted 7 lines
I do not have any plans about when this patches appear at Linus tree and thus do not know which git tree to hack on. That said I prepared the patches against the net-next tree (I have some custom netns debugging code in it and don't want to port it around in vain).
Looking forward to your feedback.
We are very curios people and would like to know more.
What does it mean to work in containers? Why is it better for the client why is it better for the server? who and how to enjoy this benefits. Does it have any effects on the operation of nfs/nfsd? What problem does it solve?
Thanks
Boaz
Quoted 2 lines
Thanks,
Pavel
Quoted 15 lines · Boaz Harrosh
Quoted 14 lines · Pavel Emelyanov
Hello everyone!
I would like to prepare the sunrpc layer for working in a containerized environments. The ultimate goal is to make both nfs client and server work in containers. Hopefully you won't object :)
Not to look like an idle talker I've prepared this set which makes the
/proc/net/rpcappear in net namespaces and made theip_map_cachebe per-net.I do not have any plans about when this patches appear at Linus tree and thus do not know which git tree to hack on. That said I prepared the patches against the net-next tree (I have some custom netns debugging code in it and don't want to port it around in vain).
Quoted 4 lines
Quoted 2 lines
Looking forward to your feedback.
We are very curios people and would like to know more.
Sure.
Quoted 4 lines
What does it mean to work in containers? Why is it better for the client why is it better for the server? who and how to enjoy this benefits. Does it have any effects on the operation of nfs/nfsd? What problem does it solve?
That's an old question actually. What does it mean, why is it better, who and how to enjoy etc. were answered years ago. Do you want me to google these articles for you?
If I misunderstood your question, please rephrase.
Thanks
Pavel
Quoted 6 lines
Thanks
BoazQuoted 2 lines
Thanks,
Pavel
Quoted 5 lines · Pavel Emelyanov
Hello everyone!
I would like to prepare the sunrpc layer for working in a containerized environments. The ultimate goal is to make both nfs client and server work in containers. Hopefully you won't object :)
Neat, thanks.
Quoted 9 lines
Not to look like an idle talker I've prepared this set which makes the
/proc/net/rpcappear in net namespaces and made theip_map_cachebe per-net.I do not have any plans about when this patches appear at Linus tree and thus do not know which git tree to hack on. That said I prepared the patches against the net-next tree (I have some custom netns debugging code in it and don't want to port it around in vain).
Looking forward to your feedback.
What are you thinking of as a use-case for this?
I think it would be useful to able to run what appear to be multiple NFS servers on a single host; and for that, we would want to vary more than just the ip_map_cache. The export-related caches (nfsd.fh and nfsd.export), at least.
--b.
Quoted 3 lines
Quoted 1 line
Looking forward to your feedback.
What are you thinking of as a use-case for this?
To make it possible run both NFS server and client in containers. I know, that the NFS client is already a filesystem, but such things as its internal servers and clients abstraction require isolation from each other in containers terms.
Quoted 2 lines
I think it would be useful to able to run what appear to be multiple NFS servers on a single host;
Yup, this is one of the goals.
Quoted 3 lines
and for that, we would want to vary more than
just theip_map_cache. The export-related caches (nfsd.fh and nfsd.export), at least.
Sure! The thing is that the full containerization of that stuff is too many patches and I'm not sure that you and other maintainers wish to review the 100-patch set in one go ;)
I want to find out what git tree to hack on and prepare small patch sets making things step-by-step. This one is just the first in a row.
Quoted 2 lines
--b.
Thanks,
Pavel
Quoted 5 lines · Pavel Emelyanov
Quoted 3 lines
Quoted 1 line
Looking forward to your feedback.
What are you thinking of as a use-case for this?
To make it possible run both NFS server and client in containers.
Could you describe that in user-visible terms? (Currently if I create a new network namespace, what happens, and what will happen differently afterwards?)
Quoted 8 lines
I know, that the NFS client is already a filesystem, but such things as its internal servers and clients abstraction require isolation from each other in containers terms.
Quoted 2 lines
I think it would be useful to able to run what appear to be multiple NFS servers on a single host;
Yup, this is one of the goals.
OK, good.
Quoted 7 lines
Quoted 3 lines
and for that, we would want to vary more than
just theip_map_cache. The export-related caches (nfsd.fh and nfsd.export), at least.Sure! The thing is that the full containerization of that stuff is too many patches and I'm not sure that you and other maintainers wish to review the 100-patch set in one go ;)
Well, if it's really all ready....
Better, though, would be an outline of the work to be done and what you expect to be working at the end.
Quoted 2 lines
I want to find out what git tree to hack on and prepare small patch sets making things step-by-step. This one is just the first in a row.
For the server side you can use
git://linux-nfs.org/~bfields/linux.git nfsd-next
though generally the latest upstream will likely work as well.
On a quick skim, those patches look fine (and brokenly up nicely for review, thanks). My main concern is just being sure I understand where this all ends up.
--b.
Quoted 10 lines · J. Bruce Fields
Quoted 5 lines · Pavel Emelyanov
Quoted 3 lines
Quoted 1 line
Looking forward to your feedback.
What are you thinking of as a use-case for this?
To make it possible run both NFS server and client in containers.
Could you describe that in user-visible terms? (Currently if I create a new network namespace, what happens, and what will happen differently afterwards?)
This is not about the network namespace only I believe. E.g. the nfsd filesystem is a filesystem already and shouldn't be tied to any task-driven context.
E.g. as far as the net namespace part is concerned. First of all the TCP/UDP socket used by transport will be per-namespace. User will "feel" this for example by different routing and netfilter rules applied to connections. Besides the rpc service sockets will be per namespace as well.
Quoted 8 lines
Quoted 3 lines
Sure! The thing is that the full containerization of that stuff is too many patches and I'm not sure that you and other maintainers wish to review the 100-patch set in one go ;)
Well, if it's really all ready....
Better, though, would be an outline of the work to be done and what you expect to be working at the end.
The nearest plan is
1. Prepare the sunrpc layer to work in net namespaces
2. Make rpcpipefs and nfsd filesystems be mountable multiple times
3. Make support for multiple instances of the nfsd caches
4. Make suuport for multiple instances of the nfsd_serv
After this several NFSd-s can be used in containers (hopefully I didn't miss anything).
Plans about the nfs client are much more obscure for now.
Quoted 8 lines
Quoted 2 lines
I want to find out what git tree to hack on and prepare small patch sets making things step-by-step. This one is just the first in a row.
For the server side you can use
git://linux-nfs.org/~bfields/linux.gitnfsd-nextthough generally the latest upstream will likely work as well.
OK, I will re-base the set onto the nfsd-next then.
Quoted 3 lines
On a quick skim, those patches look fine (and brokenly up nicely for review, thanks). My main concern is just being sure I understand where this all ends up.
Well, as far as I know the nfsd and sunrpc code the plan described above should give us most of the work needed to containerize nfsd.
Quoted 1 line
--b.
Quoted 33 lines · Pavel Emelyanov
Quoted 10 lines · J. Bruce Fields
Quoted 5 lines · Pavel Emelyanov
Quoted 3 lines
Quoted 1 line
Looking forward to your feedback.
What are you thinking of as a use-case for this?
To make it possible run both NFS server and client in containers.
Could you describe that in user-visible terms? (Currently if I create a new network namespace, what happens, and what will happen differently afterwards?)
This is not about the network namespace only I believe. E.g. the nfsd filesystem is a filesystem already and shouldn't be tied to any task-driven context.
E.g. as far as the net namespace part is concerned. First of all the TCP/UDP socket used by transport will be per-namespace. User will "feel" this for example by different routing and netfilter rules applied to connections. Besides the rpc service sockets will be per namespace as well.
Quoted 8 lines
Quoted 3 lines
Sure! The thing is that the full containerization of that stuff is too many patches and I'm not sure that you and other maintainers wish to review the 100-patch set in one go ;)
Well, if it's really all ready....
Better, though, would be an outline of the work to be done and what you expect to be working at the end.
The nearest plan is
Quoted 7 lines
1. Prepare the sunrpc layer to work in net namespaces
2. Make rpcpipefs and nfsd filesystems be mountable multiple times
3. Make support for multiple instances of the nfsd caches
4. Make suuport for multiple instances of thenfsd_servAfter this several NFSd-s can be used in containers (hopefully I didn't miss anything).
Are you assuming NFSv4 only? Something needs to be done about NLM and NSM to make this work right.
Is there an issue for idmapper and svcgssd? Probably not, but worth exploring.
And, how about AUTH_SYS certs? These contain the host's name in them, and that depends on the net namespace. NLM uses AUTH_SYS, and I believe the NFS server can make NLM calls to the client.
Quoted 25 lines
Plans about the nfs client are much more obscure for now.
Quoted 8 lines
Quoted 2 lines
I want to find out what git tree to hack on and prepare small patch sets making things step-by-step. This one is just the first in a row.
For the server side you can use
git://linux-nfs.org/~bfields/linux.gitnfsd-nextthough generally the latest upstream will likely work as well.
OK, I will re-base the set onto the nfsd-next then.
Quoted 3 lines
On a quick skim, those patches look fine (and brokenly up nicely for review, thanks). My main concern is just being sure I understand where this all ends up.
Well, as far as I know the nfsd and sunrpc code the plan described above should give us most of the work needed to containerize nfsd.
Quoted 1 line
--b.
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
chuck[dot]lever[at]oracle[dot]com
Quoted 15 lines · Chuck Lever
Quoted 9 lines · Pavel Emelyanov
The nearest plan is
1. Prepare the sunrpc layer to work in net namespaces 2. Make rpcpipefs and nfsd filesystems be mountable multiple times 3. Make support for multiple instances of the nfsd caches 4. Make suuport for multiple instances of the
nfsd_servAfter this several NFSd-s can be used in containers (hopefully I didn't miss anything).
Are you assuming NFSv4 only? Something needs to be done about NLM and NSM to make this work right.
Quoted 6 lines
Is there an issue for idmapper and svcgssd? Probably not, but worth exploring.
And, how about
AUTH_SYScerts? These contain the host's name in them, and that depends on the net namespace. NLM usesAUTH_SYS, and I believe the NFS server can make NLM calls to the client.
The client probably can't use the auth_sys cred on nlm callbacks in any sensible way, so this may not be a big deal.
But, yes, there are probably a lot more details like this; we'll need a list.
--b.
Quoted 19 lines · J. Bruce Fields
Quoted 18 lines · Chuck Lever
Quoted 9 lines · Pavel Emelyanov
The nearest plan is
1. Prepare the sunrpc layer to work in net namespaces 2. Make rpcpipefs and nfsd filesystems be mountable multiple times 3. Make support for multiple instances of the nfsd caches 4. Make suuport for multiple instances of the
nfsd_servAfter this several NFSd-s can be used in containers (hopefully I didn't miss anything).
Are you assuming NFSv4 only? Something needs to be done about NLM and NSM to make this work right.
Is there an issue for idmapper and svcgssd? Probably not, but worth exploring.
Quoted 6 lines
Quoted 3 lines
And, how about
AUTH_SYScerts? These contain the host's name in them, and that depends on the net namespace. NLM usesAUTH_SYS, and I believe the NFS server can make NLM calls to the client.The client probably can't use the
auth_syscred on nlm callbacks in any sensible way, so this may not be a big deal.
If clients are per-net namespace, then the cl_nodename can and should be converted to reflect the utsname()->nodename. We currently force it to be the init_utsname()->nodename, precisely because we don't support namespaces.
Cheers
Trond
Quoted 19 lines · J. Bruce Fields
Quoted 18 lines · Chuck Lever
Quoted 9 lines · Pavel Emelyanov
The nearest plan is
1. Prepare the sunrpc layer to work in net namespaces 2. Make rpcpipefs and nfsd filesystems be mountable multiple times 3. Make support for multiple instances of the nfsd caches 4. Make suuport for multiple instances of the
nfsd_servAfter this several NFSd-s can be used in containers (hopefully I didn't miss anything).
Are you assuming NFSv4 only? Something needs to be done about NLM and NSM to make this work right.
Is there an issue for idmapper and svcgssd? Probably not, but worth exploring.
Quoted 6 lines
Quoted 3 lines
And, how about
AUTH_SYScerts? These contain the host's name in them, and that depends on the net namespace. NLM usesAUTH_SYS, and I believe the NFS server can make NLM calls to the client.The client probably can't use the
auth_syscred on nlm callbacks in any sensible way, so this may not be a big deal.
I doubt anything looks at that hostname, really. My worry is that it could leak information (like the wrong hostname) onto the network.
Signature · 1 line
chuck[dot]lever[at]oracle[dot]com
Quoted 21 lines · Chuck Lever
Quoted 19 lines · J. Bruce Fields
Quoted 18 lines · Chuck Lever
Quoted 9 lines · Pavel Emelyanov
The nearest plan is
1. Prepare the sunrpc layer to work in net namespaces 2. Make rpcpipefs and nfsd filesystems be mountable multiple times 3. Make support for multiple instances of the nfsd caches 4. Make suuport for multiple instances of the
nfsd_servAfter this several NFSd-s can be used in containers (hopefully I didn't miss anything).
Are you assuming NFSv4 only? Something needs to be done about NLM and NSM to make this work right.
Is there an issue for idmapper and svcgssd? Probably not, but worth exploring.
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
And, how about
AUTH_SYScerts? These contain the host's name in them, and that depends on the net namespace. NLM usesAUTH_SYS, and I believe the NFS server can make NLM calls to the client.The client probably can't use the
auth_syscred on nlm callbacks in any sensible way, so this may not be a big deal.I doubt anything looks at that hostname, really. My worry is that it could leak information (like the wrong hostname) onto the network.
Which is one reason why using the utsname()->nodename at the time of mount is the correct thing to do.
Trond
Quoted 38 lines · Pavel Emelyanov
Quoted 10 lines · J. Bruce Fields
Quoted 5 lines · Pavel Emelyanov
Quoted 3 lines
Quoted 1 line
Looking forward to your feedback.
What are you thinking of as a use-case for this?
To make it possible run both NFS server and client in containers.
Could you describe that in user-visible terms? (Currently if I create a new network namespace, what happens, and what will happen differently afterwards?)
This is not about the network namespace only I believe. E.g. the nfsd filesystem is a filesystem already and shouldn't be tied to any task-driven context.
E.g. as far as the net namespace part is concerned. First of all the TCP/UDP socket used by transport will be per-namespace. User will "feel" this for example by different routing and netfilter rules applied to connections. Besides the rpc service sockets will be per namespace as well.
Quoted 8 lines
Quoted 3 lines
Sure! The thing is that the full containerization of that stuff is too many patches and I'm not sure that you and other maintainers wish to review the 100-patch set in one go ;)
Well, if it's really all ready....
Better, though, would be an outline of the work to be done and what you expect to be working at the end.
The nearest plan is
1. Prepare the sunrpc layer to work in net namespaces
2. Make rpcpipefs and nfsd filesystems be mountable multiple times
3. Make support for multiple instances of the nfsd caches
4. Make suuport for multiple instances of thenfsd_serv
Quoted 4 lines
After this several NFSd-s can be used in containers (hopefully I didn't miss anything).
Plans about the nfs client are much more obscure for now.
The client should be something like the following:
1) Ensure sunrpc sockets are created using the correct net namespace
2) Convert rpc_pipefs to be per-net namespace.
3) Convert the nfs_client and superblock to be per-net namespace
4) Convert lockd's struct host to be per-net namespace
Cheers
Trond
Quoted 39 lines · Trond Myklebust
Quoted 38 lines · Pavel Emelyanov
Quoted 10 lines · J. Bruce Fields
Quoted 5 lines · Pavel Emelyanov
Quoted 3 lines
Quoted 1 line
Looking forward to your feedback.
What are you thinking of as a use-case for this?
To make it possible run both NFS server and client in containers.
Could you describe that in user-visible terms? (Currently if I create a new network namespace, what happens, and what will happen differently afterwards?)
This is not about the network namespace only I believe. E.g. the nfsd filesystem is a filesystem already and shouldn't be tied to any task-driven context.
E.g. as far as the net namespace part is concerned. First of all the TCP/UDP socket used by transport will be per-namespace. User will "feel" this for example by different routing and netfilter rules applied to connections. Besides the rpc service sockets will be per namespace as well.
Quoted 8 lines
Quoted 3 lines
Sure! The thing is that the full containerization of that stuff is too many patches and I'm not sure that you and other maintainers wish to review the 100-patch set in one go ;)
Well, if it's really all ready....
Better, though, would be an outline of the work to be done and what you expect to be working at the end.
The nearest plan is
1. Prepare the sunrpc layer to work in net namespaces
2. Make rpcpipefs and nfsd filesystems be mountable multiple times
3. Make support for multiple instances of the nfsd caches
4. Make suuport for multiple instances of thenfsd_serv
Quoted 8 lines
Quoted 4 lines
After this several NFSd-s can be used in containers (hopefully I didn't miss anything).
Plans about the nfs client are much more obscure for now.
The client should be something like the following:
1) Ensure sunrpc sockets are created using the correct net namespace
For the client, that's initially the net namespace of the mount? (What about submounts?)
Quoted 3 lines
2) Convert
rpc_pipefsto be per-net namespace.
3) Convert thenfs_clientand superblock to be per-net namespace
4) Convert lockd's struct host to be per-net namespace
What do we expect behavior to actually look like from the point of view of somebody on the client?
I'd like to see someone write some kind of spec for how this should all work. That worries me a lot more than the code.....
--b.
Quoted 43 lines · J. Bruce Fields
Quoted 42 lines · Trond Myklebust
Quoted 41 lines · Pavel Emelyanov
Quoted 10 lines · J. Bruce Fields
Quoted 5 lines · Pavel Emelyanov
Quoted 3 lines
Quoted 1 line
Looking forward to your feedback.
What are you thinking of as a use-case for this?
To make it possible run both NFS server and client in containers.
Could you describe that in user-visible terms? (Currently if I create a new network namespace, what happens, and what will happen differently afterwards?)
This is not about the network namespace only I believe. E.g. the nfsd filesystem is a filesystem already and shouldn't be tied to any task-driven context.
E.g. as far as the net namespace part is concerned. First of all the TCP/UDP socket used by transport will be per-namespace. User will "feel" this for example by different routing and netfilter rules applied to connections. Besides the rpc service sockets will be per namespace as well.
Quoted 8 lines
Quoted 3 lines
Sure! The thing is that the full containerization of that stuff is too many patches and I'm not sure that you and other maintainers wish to review the 100-patch set in one go ;)
Well, if it's really all ready....
Better, though, would be an outline of the work to be done and what you expect to be working at the end.
The nearest plan is
1. Prepare the sunrpc layer to work in net namespaces
2. Make rpcpipefs and nfsd filesystems be mountable multiple times
3. Make support for multiple instances of the nfsd caches
4. Make suuport for multiple instances of thenfsd_servAfter this several NFSd-s can be used in containers (hopefully I didn't miss anything).
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Plans about the nfs client are much more obscure for now.
The client should be something like the following:
1) Ensure sunrpc sockets are created using the correct net namespace
For the client, that's initially the net namespace of the mount? (What about submounts?)
It is the net namespace of the process that does the mount, yes.
Quoted 9 lines
Quoted 3 lines
2) Convert
rpc_pipefsto be per-net namespace.
3) Convert thenfs_clientand superblock to be per-net namespace
4) Convert lockd's struct host to be per-net namespaceWhat do we expect behavior to actually look like from the point of view of somebody on the client?
I'd like to see someone write some kind of spec for how this should all work. That worries me a lot more than the code.....
I think it is fairly obvious what should happen once you are in a net namespace jail: you want all future NFS mounts to confine themselves to that private net namespace. i.e. they must talk to the portmapper, rpc.statd, and rpc.gssd that are defined on that net namespace, and they must confine themselves to that net namespace when talking to servers.
The problem is dealing with clone() and unshare() (i.e. the process of changing net namespaces).
If the resulting container inherits an NFS mountpoint from its parent process, then I cannot see how we could sanely migrate that to a new net namespace, since the super block etc remains shared between the two containers as part of the mount namespaces. To avoid confusion, I believe we need to ensure that under-the-cover mounts etc inherit the same net namespace as the original mount, and they should talk to the portmapper, rpc.statd and rpc.gssd that the original mount uses. If those die, then too bad - that's operator error.
Cheers
Trond
A message that is not in the archive (sent off-list or not yet received): 1285018566.2851.159.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org
Quoted 22 lines · Trond Myklebust
Quoted 2 lines · J. Bruce Fields
For the client, that's initially the net namespace of the mount? (What about submounts?)
It is the net namespace of the process that does the mount, yes.
Quoted 9 lines
Quoted 3 lines
2) Convert
rpc_pipefsto be per-net namespace.
3) Convert thenfs_clientand superblock to be per-net namespace
4) Convert lockd's struct host to be per-net namespaceWhat do we expect behavior to actually look like from the point of view of somebody on the client?
I'd like to see someone write some kind of spec for how this should all work. That worries me a lot more than the code.....
I think it is fairly obvious what should happen once you are in a net namespace jail: you want all future NFS mounts to confine themselves to that private net namespace. i.e. they must talk to the portmapper, rpc.statd, and rpc.gssd that are defined on that net namespace, and they must confine themselves to that net namespace when talking to servers.
Quoted 9 lines
The problem is dealing with
clone()andunshare()(i.e. the process of changing net namespaces).
If the resulting container inherits an NFS mountpoint from its parent process, then I cannot see how we could sanely migrate that to a new net namespace, since the super block etc remains shared between the two containers as part of the mount namespaces. To avoid confusion, I believe we need to ensure that under-the-cover mounts etc inherit the same net namespace as the original mount, and they should talk to the portmapper, rpc.statd and rpc.gssd that the original mount uses.
OK, that sounds right to me.
--b.
Quoted 2 lines
If
those die, then too bad - that's operator error.
Quoted 3 lines
The client should be something like the following:
1) Ensure sunrpc sockets are created using the correct net namespace
Ack
Quoted 1 line
2) Convert
rpc_pipefsto be per-net namespace.
Trond, I think this part should be done the other way.
You see, the rpc_pipefs is a filesystem already and we shouldn't make it bound to any task-driven context. What I was thinking about in that direction is make it mountable multiple times.
The central issue of this is - the way we say the rpc_get_mount() which vfsmount we need. Userspace will just use the per-container (i.e. per-chroot) instance of it and the kernel users will work with the vfsmount obtained by the rpc_get_mount() call.
Now, how do I plan to solve the rpc_get_mount problem. Some time ago there was similar problem with the devpts filesystem - people making ptys work per-container tried to solve the same problem and they ended up (with Al's help) with a yet another devpts mount option which explicitly stated that a new instance should be created. How do you think if we do the same for rpc_pipefs (a newinstance mount option) and add yet another mount option for its only client (nfs) telling it where to look for the rpc mount for (e.g. rpcmount=/var/...) ?
Quoted 1 line
3) Convert the
nfs_clientand superblock to be per-net namespace
Ack about the nfs_client, but as far as the superblock is concerned - I think we should tag only the nfs_server with net for the same reasons as in the item 2) above.
Quoted 1 line
4) Convert lockd's struct host to be per-net namespace
Ack
Quoted 4 lines
Cheers
Trond
Quoted 19 lines · Pavel Emelyanov
Quoted 3 lines
The client should be something like the following:
1) Ensure sunrpc sockets are created using the correct net namespace
Ack
Quoted 1 line
2) Convert
rpc_pipefsto be per-net namespace.Trond, I think this part should be done the other way.
You see, the
rpc_pipefsis a filesystem already and we shouldn't make it bound to any task-driven context. What I was thinking about in that direction is make it mountable multiple times.The central issue of this is - the way we say the
rpc_get_mount()which vfsmount we need. Userspace will just use the per-container (i.e. per-chroot) instance of it and the kernel users will work with the vfsmount obtained by therpc_get_mount()call.
Quoted 8 lines
Now, how do I plan to solve the
rpc_get_mountproblem. Some time ago there was similar problem with the devpts filesystem - people making ptys work per-container tried to solve the same problem and they ended up (with Al's help) with a yet another devpts mount option which explicitly stated that a new instance should be created. How do you think if we do the same forrpc_pipefs(a newinstance mount option) and add yet another mount option for its only client (nfs) telling it where to look for the rpc mount for (e.g. rpcmount=/var/...) ?
As long as we have some mechanism to ensure that rpc.gssd from one net namespace doesn't try to establish a kerberos security context on behalf of a NFS mount that resides in a different net namespace.
My point is if the rpc.gssd resides in a different net namespace, then we have no guarantee that the IP address we pass in the upcall even points to the same server, so we must ensure that the namespaces match.
Quoted 5 lines
Quoted 1 line
3) Convert the
nfs_clientand superblock to be per-net namespaceAck about the
nfs_client, but as far as the superblock is concerned - I think we should tag only thenfs_serverwith net for the same reasons as in the item 2) above.
You should tag the nfs_server, and then make sure that nfs_compare_super does not match something that is tagged with a different net namespace than the current one. Otherwise, you can end up mounting the wrong NFS server (for the same reason as above).
Quoted 1 line
Quoted 1 line
4) Convert lockd's struct host to be per-net namespace
Cheers
Trond
Quoted 9 lines
Quoted 8 lines
Now, how do I plan to solve the
rpc_get_mountproblem. Some time ago there was similar problem with the devpts filesystem - people making ptys work per-container tried to solve the same problem and they ended up (with Al's help) with a yet another devpts mount option which explicitly stated that a new instance should be created. How do you think if we do the same forrpc_pipefs(a newinstance mount option) and add yet another mount option for its only client (nfs) telling it where to look for the rpc mount for (e.g. rpcmount=/var/...) ?
Quoted 6 lines
As long as we have some mechanism to ensure that rpc.gssd from one net namespace doesn't try to establish a kerberos security context on behalf of a NFS mount that resides in a different net namespace.
My point is if the rpc.gssd resides in a different net namespace, then we have no guarantee that the IP address we pass in the upcall even points to the same server, so we must ensure that the namespaces match.
Sure, but for doing so there's no need in strict aliasing rpcpipefs-s super blocks with struct net. By strict I mean, that not only the superblock knows which struct net it works with, but also a struct net references rpcpipefs-s supers.
Quoted 10 lines
Quoted 5 lines
Quoted 1 line
3) Convert the
nfs_clientand superblock to be per-net namespaceAck about the
nfs_client, but as far as the superblock is concerned - I think we should tag only thenfs_serverwith net for the same reasons as in the item 2) above.You should tag the
nfs_server, and then make sure thatnfs_compare_superdoes not match something that is tagged with a different net namespace than the current one. Otherwise, you can end up mounting the wrong NFS server (for the same reason as above).
Yes, of course.
Quoted 6 lines
Quoted 1 line
Quoted 1 line
4) Convert lockd's struct host to be per-net namespace
Cheers
Trond
Quoted 42 lines · Trond Myklebust
Quoted 41 lines · Pavel Emelyanov
Quoted 10 lines · J. Bruce Fields
Quoted 5 lines · Pavel Emelyanov
Quoted 3 lines
Quoted 1 line
Looking forward to your feedback.
What are you thinking of as a use-case for this?
To make it possible run both NFS server and client in containers.
Could you describe that in user-visible terms? (Currently if I create a new network namespace, what happens, and what will happen differently afterwards?)
This is not about the network namespace only I believe. E.g. the nfsd filesystem is a filesystem already and shouldn't be tied to any task-driven context.
E.g. as far as the net namespace part is concerned. First of all the TCP/UDP socket used by transport will be per-namespace. User will "feel" this for example by different routing and netfilter rules applied to connections. Besides the rpc service sockets will be per namespace as well.
Quoted 8 lines
Quoted 3 lines
Sure! The thing is that the full containerization of that stuff is too many patches and I'm not sure that you and other maintainers wish to review the 100-patch set in one go ;)
Well, if it's really all ready....
Better, though, would be an outline of the work to be done and what you expect to be working at the end.
The nearest plan is
1. Prepare the sunrpc layer to work in net namespaces
2. Make rpcpipefs and nfsd filesystems be mountable multiple times
3. Make support for multiple instances of the nfsd caches
4. Make suuport for multiple instances of thenfsd_servAfter this several NFSd-s can be used in containers (hopefully I didn't miss anything).
Quoted 8 lines
Quoted 1 line
Plans about the nfs client are much more obscure for now.
The client should be something like the following:
1) Ensure sunrpc sockets are created using the correct net namespace
2) Convertrpc_pipefsto be per-net namespace.
3) Convert thenfs_clientand superblock to be per-net namespace
4) Convert lockd's struct host to be per-net namespace
Actually, there is one more task that needs to be added to the above list. We need to figure out what to do with the keyring upcalls.
The keyring upcalls are currently initiated through the same mechanism as module_request and therefore get started with the init_nsproxy namespace. We'd really like them to run inside the same container as the process.
As part of the same problem, there is the issue of what to do with the dns resolver and Bryan's new keyring based idmapper code.
Cheers
Trond