diff options
Diffstat (limited to 'fs/nfsd/nfsctl.c')
-rw-r--r-- | fs/nfsd/nfsctl.c | 49 |
1 files changed, 48 insertions, 1 deletions
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 | ||