aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/nfsd/nfsctl.c53
1 files changed, 29 insertions, 24 deletions
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index af16849d243a..2c1dce8e9a06 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -910,6 +910,31 @@ static ssize_t write_versions(struct file *file, char *buf, size_t size)
910 return rv; 910 return rv;
911} 911}
912 912
913/*
914 * A transport listener is removed by writing a "-", it's transport
915 * name, and it's port number.
916 */
917static ssize_t __write_ports_delxprt(char *buf)
918{
919 struct svc_xprt *xprt;
920 char transport[16];
921 int port;
922
923 if (sscanf(&buf[1], "%15s %4u", transport, &port) != 2)
924 return -EINVAL;
925
926 if (port < 1 || port > USHORT_MAX || nfsd_serv == NULL)
927 return -EINVAL;
928
929 xprt = svc_find_xprt(nfsd_serv, transport, AF_UNSPEC, port);
930 if (xprt == NULL)
931 return -ENOTCONN;
932
933 svc_close_xprt(xprt);
934 svc_xprt_put(xprt);
935 return 0;
936}
937
913static ssize_t __write_ports(struct file *file, char *buf, size_t size) 938static ssize_t __write_ports(struct file *file, char *buf, size_t size)
914{ 939{
915 if (size == 0) { 940 if (size == 0) {
@@ -984,30 +1009,10 @@ static ssize_t __write_ports(struct file *file, char *buf, size_t size)
984 return err < 0 ? err : 0; 1009 return err < 0 ? err : 0;
985 } 1010 }
986 } 1011 }
987 /* 1012
988 * Remove a transport by writing it's transport name and port number 1013 if (buf[0] == '-' && isalpha(buf[1]))
989 */ 1014 return __write_ports_delxprt(buf);
990 if (buf[0] == '-' && isalpha(buf[1])) { 1015
991 struct svc_xprt *xprt;
992 int err = -EINVAL;
993 char transport[16];
994 int port;
995 if (sscanf(&buf[1], "%15s %4d", transport, &port) == 2) {
996 if (port < 1 || port > 65535)
997 return -EINVAL;
998 if (nfsd_serv) {
999 xprt = svc_find_xprt(nfsd_serv, transport,
1000 AF_UNSPEC, port);
1001 if (xprt) {
1002 svc_close_xprt(xprt);
1003 svc_xprt_put(xprt);
1004 err = 0;
1005 } else
1006 err = -ENOTCONN;
1007 }
1008 return err < 0 ? err : 0;
1009 }
1010 }
1011 return -EINVAL; 1016 return -EINVAL;
1012} 1017}
1013 1018