Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

SUNRPC: search for service transports in network namespace context

Service transports are parametrized by network namespace. And thus lookup of
transport instance have to take network namespace into account.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Acked-by: J. Bruce Fields <bfields@redhat.com>

authored by

Stanislav Kinsbursky and committed by
Trond Myklebust
4cb54ca2 babea479

+10 -5
+1 -1
fs/lockd/svc.c
··· 193 193 { 194 194 struct svc_xprt *xprt; 195 195 196 - xprt = svc_find_xprt(serv, name, family, 0); 196 + xprt = svc_find_xprt(serv, name, &init_net, family, 0); 197 197 if (xprt == NULL) 198 198 return svc_create_xprt(serv, name, &init_net, family, port, 199 199 SVC_SOCK_DEFAULTS);
+2 -2
fs/nfsd/nfsctl.c
··· 722 722 nfsd_serv->sv_nrthreads--; 723 723 return 0; 724 724 out_close: 725 - xprt = svc_find_xprt(nfsd_serv, transport, PF_INET, port); 725 + xprt = svc_find_xprt(nfsd_serv, transport, &init_net, PF_INET, port); 726 726 if (xprt != NULL) { 727 727 svc_close_xprt(xprt); 728 728 svc_xprt_put(xprt); ··· 748 748 if (port < 1 || port > USHRT_MAX || nfsd_serv == NULL) 749 749 return -EINVAL; 750 750 751 - xprt = svc_find_xprt(nfsd_serv, transport, AF_UNSPEC, port); 751 + xprt = svc_find_xprt(nfsd_serv, transport, &init_net, AF_UNSPEC, port); 752 752 if (xprt == NULL) 753 753 return -ENOTCONN; 754 754
+2 -1
include/linux/sunrpc/svc_xprt.h
··· 121 121 int svc_port_is_privileged(struct sockaddr *sin); 122 122 int svc_print_xprts(char *buf, int maxlen); 123 123 struct svc_xprt *svc_find_xprt(struct svc_serv *serv, const char *xcl_name, 124 - const sa_family_t af, const unsigned short port); 124 + struct net *net, const sa_family_t af, 125 + const unsigned short port); 125 126 int svc_xprt_names(struct svc_serv *serv, char *buf, const int buflen); 126 127 127 128 static inline void svc_xprt_get(struct svc_xprt *xprt)
+5 -1
net/sunrpc/svc_xprt.c
··· 1089 1089 * svc_find_xprt - find an RPC transport instance 1090 1090 * @serv: pointer to svc_serv to search 1091 1091 * @xcl_name: C string containing transport's class name 1092 + * @net: owner net pointer 1092 1093 * @af: Address family of transport's local address 1093 1094 * @port: transport's IP port number 1094 1095 * ··· 1102 1101 * service's list that has a matching class name. 1103 1102 */ 1104 1103 struct svc_xprt *svc_find_xprt(struct svc_serv *serv, const char *xcl_name, 1105 - const sa_family_t af, const unsigned short port) 1104 + struct net *net, const sa_family_t af, 1105 + const unsigned short port) 1106 1106 { 1107 1107 struct svc_xprt *xprt; 1108 1108 struct svc_xprt *found = NULL; ··· 1114 1112 1115 1113 spin_lock_bh(&serv->sv_lock); 1116 1114 list_for_each_entry(xprt, &serv->sv_permsocks, xpt_list) { 1115 + if (xprt->xpt_net != net) 1116 + continue; 1117 1117 if (strcmp(xprt->xpt_class->xcl_name, xcl_name)) 1118 1118 continue; 1119 1119 if (af != AF_UNSPEC && af != xprt->xpt_local.ss_family)