diff options
| author | Tom Tucker <tom@opengridcomputing.com> | 2007-12-30 22:08:35 -0500 |
|---|---|---|
| committer | J. Bruce Fields <bfields@citi.umich.edu> | 2008-02-01 16:42:13 -0500 |
| commit | a217813f9067b785241cb7f31956e51d2071703a (patch) | |
| tree | 5bda9ab6a461562975506d2100b16db19e3e628b | |
| parent | 7fcb98d58cb4d18af6386f71025fc5192f25fbca (diff) | |
knfsd: Support adding transports by writing portlist file
Update the write handler for the portlist file to allow creating new
listening endpoints on a transport. The general form of the string is:
<transport_name><space><port number>
For example:
echo "tcp 2049" > /proc/fs/nfsd/portlist
This is intended to support the creation of a listening endpoint for
RDMA transports without adding #ifdef code to the nfssvc.c file.
Transports can also be removed as follows:
'-'<transport_name><space><port number>
For example:
echo "-tcp 2049" > /proc/fs/nfsd/portlist
Attempting to add a listener with an invalid transport string results
in EPROTONOSUPPORT and a perror string of "Protocol not supported".
Attempting to remove an non-existent listener (.e.g. bad proto or port)
results in ENOTCONN and a perror string of
"Transport endpoint is not connected"
Signed-off-by: Tom Tucker <tom@opengridcomputing.com>
Acked-by: Neil Brown <neilb@suse.de>
Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
Reviewed-by: Greg Banks <gnb@sgi.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
| -rw-r--r-- | fs/lockd/svc.c | 18 | ||||
| -rw-r--r-- | fs/nfsd/nfsctl.c | 49 | ||||
| -rw-r--r-- | net/sunrpc/svc_xprt.c | 2 |
3 files changed, 63 insertions, 6 deletions
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c index 470af0138bb5..08226464e563 100644 --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c | |||
| @@ -227,17 +227,25 @@ lockd(struct svc_rqst *rqstp) | |||
| 227 | static int make_socks(struct svc_serv *serv, int proto) | 227 | static int make_socks(struct svc_serv *serv, int proto) |
| 228 | { | 228 | { |
| 229 | static int warned; | 229 | static int warned; |
| 230 | struct svc_xprt *xprt; | ||
| 230 | int err = 0; | 231 | int err = 0; |
| 231 | 232 | ||
| 232 | if (proto == IPPROTO_UDP || nlm_udpport) | 233 | if (proto == IPPROTO_UDP || nlm_udpport) { |
| 233 | if (!svc_find_xprt(serv, "udp", 0, 0)) | 234 | xprt = svc_find_xprt(serv, "udp", 0, 0); |
| 235 | if (!xprt) | ||
| 234 | err = svc_create_xprt(serv, "udp", nlm_udpport, | 236 | err = svc_create_xprt(serv, "udp", nlm_udpport, |
| 235 | SVC_SOCK_DEFAULTS); | 237 | SVC_SOCK_DEFAULTS); |
| 236 | if (err >= 0 && (proto == IPPROTO_TCP || nlm_tcpport)) | 238 | else |
| 237 | if (!svc_find_xprt(serv, "tcp", 0, 0)) | 239 | svc_xprt_put(xprt); |
| 240 | } | ||
| 241 | if (err >= 0 && (proto == IPPROTO_TCP || nlm_tcpport)) { | ||
| 242 | xprt = svc_find_xprt(serv, "tcp", 0, 0); | ||
| 243 | if (!xprt) | ||
| 238 | err = svc_create_xprt(serv, "tcp", nlm_tcpport, | 244 | err = svc_create_xprt(serv, "tcp", nlm_tcpport, |
| 239 | SVC_SOCK_DEFAULTS); | 245 | SVC_SOCK_DEFAULTS); |
| 240 | 246 | else | |
| 247 | svc_xprt_put(xprt); | ||
| 248 | } | ||
| 241 | if (err >= 0) { | 249 | if (err >= 0) { |
| 242 | warned = 0; | 250 | warned = 0; |
| 243 | err = 0; | 251 | err = 0; |
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 4aba92698581..eff6a6b4c2f6 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c | |||
| @@ -540,7 +540,7 @@ static ssize_t write_ports(struct file *file, char *buf, size_t size) | |||
| 540 | } | 540 | } |
| 541 | return err < 0 ? err : 0; | 541 | return err < 0 ? err : 0; |
| 542 | } | 542 | } |
| 543 | if (buf[0] == '-') { | 543 | if (buf[0] == '-' && isdigit(buf[1])) { |
| 544 | char *toclose = kstrdup(buf+1, GFP_KERNEL); | 544 | char *toclose = kstrdup(buf+1, GFP_KERNEL); |
| 545 | int len = 0; | 545 | int len = 0; |
| 546 | if (!toclose) | 546 | if (!toclose) |
| @@ -554,6 +554,53 @@ static ssize_t write_ports(struct file *file, char *buf, size_t size) | |||
| 554 | kfree(toclose); | 554 | kfree(toclose); |
| 555 | return len; | 555 | return len; |
| 556 | } | 556 | } |
| 557 | /* | ||
| 558 | * Add a transport listener by writing it's transport name | ||
| 559 | */ | ||
| 560 | if (isalpha(buf[0])) { | ||
| 561 | int err; | ||
| 562 | char transport[16]; | ||
| 563 | int port; | ||
| 564 | if (sscanf(buf, "%15s %4d", transport, &port) == 2) { | ||
| 565 | err = nfsd_create_serv(); | ||
| 566 | if (!err) { | ||
| 567 | err = svc_create_xprt(nfsd_serv, | ||
| 568 | transport, port, | ||
| 569 | SVC_SOCK_ANONYMOUS); | ||
| 570 | if (err == -ENOENT) | ||
| 571 | /* Give a reasonable perror msg for | ||
| 572 | * bad transport string */ | ||
| 573 | err = -EPROTONOSUPPORT; | ||
| 574 | } | ||
| 575 | return err < 0 ? err : 0; | ||
| 576 | } | ||
| 577 | } | ||
| 578 | /* | ||
| 579 | * Remove a transport by writing it's transport name and port number | ||
| 580 | */ | ||
| 581 | if (buf[0] == '-' && isalpha(buf[1])) { | ||
| 582 | struct svc_xprt *xprt; | ||
| 583 | int err = -EINVAL; | ||
| 584 | char transport[16]; | ||
| 585 | int port; | ||
| 586 | if (sscanf(&buf[1], "%15s %4d", transport, &port) == 2) { | ||
| 587 | if (port == 0) | ||
| 588 | return -EINVAL; | ||
| 589 | lock_kernel(); | ||
| 590 | if (nfsd_serv) { | ||
| 591 | xprt = svc_find_xprt(nfsd_serv, transport, | ||
| 592 | AF_UNSPEC, port); | ||
| 593 | if (xprt) { | ||
| 594 | svc_close_xprt(xprt); | ||
| 595 | svc_xprt_put(xprt); | ||
| 596 | err = 0; | ||
| 597 | } else | ||
| 598 | err = -ENOTCONN; | ||
| 599 | } | ||
| 600 | unlock_kernel(); | ||
| 601 | return err < 0 ? err : 0; | ||
| 602 | } | ||
| 603 | } | ||
| 557 | return -EINVAL; | 604 | return -EINVAL; |
| 558 | } | 605 | } |
| 559 | 606 | ||
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c index 512c10fc1a9f..783597343877 100644 --- a/net/sunrpc/svc_xprt.c +++ b/net/sunrpc/svc_xprt.c | |||
| @@ -842,6 +842,7 @@ void svc_close_xprt(struct svc_xprt *xprt) | |||
| 842 | clear_bit(XPT_BUSY, &xprt->xpt_flags); | 842 | clear_bit(XPT_BUSY, &xprt->xpt_flags); |
| 843 | svc_xprt_put(xprt); | 843 | svc_xprt_put(xprt); |
| 844 | } | 844 | } |
| 845 | EXPORT_SYMBOL_GPL(svc_close_xprt); | ||
| 845 | 846 | ||
| 846 | void svc_close_all(struct list_head *xprt_list) | 847 | void svc_close_all(struct list_head *xprt_list) |
| 847 | { | 848 | { |
| @@ -1006,6 +1007,7 @@ struct svc_xprt *svc_find_xprt(struct svc_serv *serv, char *xcl_name, | |||
| 1006 | if (port && port != svc_xprt_local_port(xprt)) | 1007 | if (port && port != svc_xprt_local_port(xprt)) |
| 1007 | continue; | 1008 | continue; |
| 1008 | found = xprt; | 1009 | found = xprt; |
| 1010 | svc_xprt_get(xprt); | ||
| 1009 | break; | 1011 | break; |
| 1010 | } | 1012 | } |
| 1011 | spin_unlock_bh(&serv->sv_lock); | 1013 | spin_unlock_bh(&serv->sv_lock); |
