Commit 7bdac1ec authored by Stanislav Kinsbursky's avatar Stanislav Kinsbursky Committed by Greg Kroah-Hartman

nfsd: pass net to __write_ports() and down

commit 08160352 upstream.

Precursor patch. Hard-coded "init_net" will be replaced by proper one in
future.
Signed-off-by: default avatarStanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
[wengmeiling: backport to 3.4:
 - adjust context
 - add net_ns parameter to __write_ports_delxprt()]
Signed-off-by: default avatarWeng Meiling <wengmeiling.weng@huawei.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 044b2114
...@@ -650,11 +650,10 @@ static ssize_t __write_ports_names(char *buf) ...@@ -650,11 +650,10 @@ static ssize_t __write_ports_names(char *buf)
* a socket of a supported family/protocol, and we use it as an * a socket of a supported family/protocol, and we use it as an
* nfsd listener. * nfsd listener.
*/ */
static ssize_t __write_ports_addfd(char *buf) static ssize_t __write_ports_addfd(char *buf, struct net *net)
{ {
char *mesg = buf; char *mesg = buf;
int fd, err; int fd, err;
struct net *net = &init_net;
err = get_int(&mesg, &fd); err = get_int(&mesg, &fd);
if (err != 0 || fd < 0) if (err != 0 || fd < 0)
...@@ -698,12 +697,11 @@ static ssize_t __write_ports_delfd(char *buf) ...@@ -698,12 +697,11 @@ static ssize_t __write_ports_delfd(char *buf)
* A transport listener is added by writing it's transport name and * A transport listener is added by writing it's transport name and
* a port number. * a port number.
*/ */
static ssize_t __write_ports_addxprt(char *buf) static ssize_t __write_ports_addxprt(char *buf, struct net *net)
{ {
char transport[16]; char transport[16];
struct svc_xprt *xprt; struct svc_xprt *xprt;
int port, err; int port, err;
struct net *net = &init_net;
if (sscanf(buf, "%15s %4u", transport, &port) != 2) if (sscanf(buf, "%15s %4u", transport, &port) != 2)
return -EINVAL; return -EINVAL;
...@@ -743,7 +741,7 @@ static ssize_t __write_ports_addxprt(char *buf) ...@@ -743,7 +741,7 @@ static ssize_t __write_ports_addxprt(char *buf)
* A transport listener is removed by writing a "-", it's transport * A transport listener is removed by writing a "-", it's transport
* name, and it's port number. * name, and it's port number.
*/ */
static ssize_t __write_ports_delxprt(char *buf) static ssize_t __write_ports_delxprt(char *buf, struct net *net)
{ {
struct svc_xprt *xprt; struct svc_xprt *xprt;
char transport[16]; char transport[16];
...@@ -755,7 +753,7 @@ static ssize_t __write_ports_delxprt(char *buf) ...@@ -755,7 +753,7 @@ static ssize_t __write_ports_delxprt(char *buf)
if (port < 1 || port > USHRT_MAX || nfsd_serv == NULL) if (port < 1 || port > USHRT_MAX || nfsd_serv == NULL)
return -EINVAL; return -EINVAL;
xprt = svc_find_xprt(nfsd_serv, transport, &init_net, AF_UNSPEC, port); xprt = svc_find_xprt(nfsd_serv, transport, net, AF_UNSPEC, port);
if (xprt == NULL) if (xprt == NULL)
return -ENOTCONN; return -ENOTCONN;
...@@ -764,22 +762,23 @@ static ssize_t __write_ports_delxprt(char *buf) ...@@ -764,22 +762,23 @@ static ssize_t __write_ports_delxprt(char *buf)
return 0; return 0;
} }
static ssize_t __write_ports(struct file *file, char *buf, size_t size) static ssize_t __write_ports(struct file *file, char *buf, size_t size,
struct net *net)
{ {
if (size == 0) if (size == 0)
return __write_ports_names(buf); return __write_ports_names(buf);
if (isdigit(buf[0])) if (isdigit(buf[0]))
return __write_ports_addfd(buf); return __write_ports_addfd(buf, net);
if (buf[0] == '-' && isdigit(buf[1])) if (buf[0] == '-' && isdigit(buf[1]))
return __write_ports_delfd(buf); return __write_ports_delfd(buf);
if (isalpha(buf[0])) if (isalpha(buf[0]))
return __write_ports_addxprt(buf); return __write_ports_addxprt(buf, net);
if (buf[0] == '-' && isalpha(buf[1])) if (buf[0] == '-' && isalpha(buf[1]))
return __write_ports_delxprt(buf); return __write_ports_delxprt(buf, net);
return -EINVAL; return -EINVAL;
} }
...@@ -858,9 +857,10 @@ static ssize_t __write_ports(struct file *file, char *buf, size_t size) ...@@ -858,9 +857,10 @@ static ssize_t __write_ports(struct file *file, char *buf, size_t size)
static ssize_t write_ports(struct file *file, char *buf, size_t size) static ssize_t write_ports(struct file *file, char *buf, size_t size)
{ {
ssize_t rv; ssize_t rv;
struct net *net = &init_net;
mutex_lock(&nfsd_mutex); mutex_lock(&nfsd_mutex);
rv = __write_ports(file, buf, size); rv = __write_ports(file, buf, size, net);
mutex_unlock(&nfsd_mutex); mutex_unlock(&nfsd_mutex);
return rv; return rv;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment