Skip to content

Commit eccf50c

Browse files
author
J. Bruce Fields
committed
nfsd: remove unused listener-removal interfaces
You can use nfsd/portlist to give nfsd additional sockets to listen on. In theory you can also remove listening sockets this way. But nobody's ever done that as far as I can tell. Also this was partially broken in 2.6.25, by a217813 "knfsd: Support adding transports by writing portlist file". (Note that we decide whether to take the "delfd" case by checking for a digit--but what's actually expected in that case is something made by svc_one_sock_name(), which won't begin with a digit.) So, let's just rip out this stuff. Acked-by: NeilBrown <neilb@suse.de> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
1 parent cf9182e commit eccf50c

3 files changed

Lines changed: 0 additions & 132 deletions

File tree

‎fs/nfsd/nfsctl.c‎

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -682,25 +682,6 @@ static ssize_t __write_ports_addfd(char *buf)
682682
return err;
683683
}
684684

685-
/*
686-
* A '-' followed by the 'name' of a socket means we close the socket.
687-
*/
688-
static ssize_t __write_ports_delfd(char *buf)
689-
{
690-
char *toclose;
691-
int len = 0;
692-
693-
toclose = kstrdup(buf + 1, GFP_KERNEL);
694-
if (toclose == NULL)
695-
return -ENOMEM;
696-
697-
if (nfsd_serv != NULL)
698-
len = svc_sock_names(nfsd_serv, buf,
699-
SIMPLE_TRANSACTION_LIMIT, toclose);
700-
kfree(toclose);
701-
return len;
702-
}
703-
704685
/*
705686
* A transport listener is added by writing it's transport name and
706687
* a port number.
@@ -746,31 +727,6 @@ static ssize_t __write_ports_addxprt(char *buf)
746727
return err;
747728
}
748729

749-
/*
750-
* A transport listener is removed by writing a "-", it's transport
751-
* name, and it's port number.
752-
*/
753-
static ssize_t __write_ports_delxprt(char *buf)
754-
{
755-
struct svc_xprt *xprt;
756-
char transport[16];
757-
int port;
758-
759-
if (sscanf(&buf[1], "%15s %4u", transport, &port) != 2)
760-
return -EINVAL;
761-
762-
if (port < 1 || port > USHRT_MAX || nfsd_serv == NULL)
763-
return -EINVAL;
764-
765-
xprt = svc_find_xprt(nfsd_serv, transport, &init_net, AF_UNSPEC, port);
766-
if (xprt == NULL)
767-
return -ENOTCONN;
768-
769-
svc_close_xprt(xprt);
770-
svc_xprt_put(xprt);
771-
return 0;
772-
}
773-
774730
static ssize_t __write_ports(struct file *file, char *buf, size_t size)
775731
{
776732
if (size == 0)
@@ -779,15 +735,9 @@ static ssize_t __write_ports(struct file *file, char *buf, size_t size)
779735
if (isdigit(buf[0]))
780736
return __write_ports_addfd(buf);
781737

782-
if (buf[0] == '-' && isdigit(buf[1]))
783-
return __write_ports_delfd(buf);
784-
785738
if (isalpha(buf[0]))
786739
return __write_ports_addxprt(buf);
787740

788-
if (buf[0] == '-' && isalpha(buf[1]))
789-
return __write_ports_delxprt(buf);
790-
791741
return -EINVAL;
792742
}
793743

@@ -825,21 +775,6 @@ static ssize_t __write_ports(struct file *file, char *buf, size_t size)
825775
* OR
826776
*
827777
* Input:
828-
* buf: C string containing a "-" followed
829-
* by an integer value representing a
830-
* previously passed in socket file
831-
* descriptor
832-
* size: non-zero length of C string in @buf
833-
* Output:
834-
* On success: NFS service no longer listens on that socket;
835-
* passed-in buffer filled with a '\n'-terminated C
836-
* string containing a unique name of the listener;
837-
* return code is the size in bytes of the string
838-
* On error: return code is a negative errno value
839-
*
840-
* OR
841-
*
842-
* Input:
843778
* buf: C string containing a transport
844779
* name and an unsigned integer value
845780
* representing the port to listen on,
@@ -848,19 +783,6 @@ static ssize_t __write_ports(struct file *file, char *buf, size_t size)
848783
* Output:
849784
* On success: returns zero; NFS service is started
850785
* On error: return code is a negative errno value
851-
*
852-
* OR
853-
*
854-
* Input:
855-
* buf: C string containing a "-" followed
856-
* by a transport name and an unsigned
857-
* integer value representing the port
858-
* to listen on, separated by whitespace
859-
* size: non-zero length of C string in @buf
860-
* Output:
861-
* On success: returns zero; NFS service no longer listens
862-
* on that transport
863-
* On error: return code is a negative errno value
864786
*/
865787
static ssize_t write_ports(struct file *file, char *buf, size_t size)
866788
{

‎include/linux/sunrpc/svcsock.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ int svc_recv(struct svc_rqst *, long);
3939
int svc_send(struct svc_rqst *);
4040
void svc_drop(struct svc_rqst *);
4141
void svc_sock_update_bufs(struct svc_serv *serv);
42-
int svc_sock_names(struct svc_serv *serv, char *buf,
43-
const size_t buflen,
44-
const char *toclose);
4542
int svc_addsock(struct svc_serv *serv, const int fd,
4643
char *name_return, const size_t len);
4744
void svc_init_xprt_sock(void);

‎net/sunrpc/svcsock.c‎

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -305,57 +305,6 @@ static int svc_one_sock_name(struct svc_sock *svsk, char *buf, int remaining)
305305
return len;
306306
}
307307

308-
/**
309-
* svc_sock_names - construct a list of listener names in a string
310-
* @serv: pointer to RPC service
311-
* @buf: pointer to a buffer to fill in with socket names
312-
* @buflen: size of the buffer to be filled
313-
* @toclose: pointer to '\0'-terminated C string containing the name
314-
* of a listener to be closed
315-
*
316-
* Fills in @buf with a '\n'-separated list of names of listener
317-
* sockets. If @toclose is not NULL, the socket named by @toclose
318-
* is closed, and is not included in the output list.
319-
*
320-
* Returns positive length of the socket name string, or a negative
321-
* errno value on error.
322-
*/
323-
int svc_sock_names(struct svc_serv *serv, char *buf, const size_t buflen,
324-
const char *toclose)
325-
{
326-
struct svc_sock *svsk, *closesk = NULL;
327-
int len = 0;
328-
329-
if (!serv)
330-
return 0;
331-
332-
spin_lock_bh(&serv->sv_lock);
333-
list_for_each_entry(svsk, &serv->sv_permsocks, sk_xprt.xpt_list) {
334-
int onelen = svc_one_sock_name(svsk, buf + len, buflen - len);
335-
if (onelen < 0) {
336-
len = onelen;
337-
break;
338-
}
339-
if (toclose && strcmp(toclose, buf + len) == 0) {
340-
closesk = svsk;
341-
svc_xprt_get(&closesk->sk_xprt);
342-
} else
343-
len += onelen;
344-
}
345-
spin_unlock_bh(&serv->sv_lock);
346-
347-
if (closesk) {
348-
/* Should unregister with portmap, but you cannot
349-
* unregister just one protocol...
350-
*/
351-
svc_close_xprt(&closesk->sk_xprt);
352-
svc_xprt_put(&closesk->sk_xprt);
353-
} else if (toclose)
354-
return -ENOENT;
355-
return len;
356-
}
357-
EXPORT_SYMBOL_GPL(svc_sock_names);
358-
359308
/*
360309
* Check input queue length
361310
*/

0 commit comments

Comments
 (0)