aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2006-01-03 03:55:41 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-01-06 14:58:52 -0500
commita72b44222d222749d54b3e370d825094352e389f (patch)
treed64815b696d207927a4154a2cbc649552708c6f2 /fs
parenta895b4a198dd06f8353328867e4f6cfd28b63081 (diff)
NFSv4: Allow user to set the port used by the NFSv4 callback channel
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfs/Makefile1
-rw-r--r--fs/nfs/callback.c3
-rw-r--r--fs/nfs/callback.h1
-rw-r--r--fs/nfs/inode.c37
-rw-r--r--fs/nfs/sysctl.c74
5 files changed, 113 insertions, 3 deletions
diff --git a/fs/nfs/Makefile b/fs/nfs/Makefile
index 8b3bb715d177..ec61fd56a1a9 100644
--- a/fs/nfs/Makefile
+++ b/fs/nfs/Makefile
@@ -13,4 +13,5 @@ nfs-$(CONFIG_NFS_V4) += nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \
13 delegation.o idmap.o \ 13 delegation.o idmap.o \
14 callback.o callback_xdr.o callback_proc.o 14 callback.o callback_xdr.o callback_proc.o
15nfs-$(CONFIG_NFS_DIRECTIO) += direct.o 15nfs-$(CONFIG_NFS_DIRECTIO) += direct.o
16nfs-$(CONFIG_SYSCTL) += sysctl.o
16nfs-objs := $(nfs-y) 17nfs-objs := $(nfs-y)
diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
index 30cae3602867..fcd97406a778 100644
--- a/fs/nfs/callback.c
+++ b/fs/nfs/callback.c
@@ -34,6 +34,7 @@ static struct nfs_callback_data nfs_callback_info;
34static DECLARE_MUTEX(nfs_callback_sema); 34static DECLARE_MUTEX(nfs_callback_sema);
35static struct svc_program nfs4_callback_program; 35static struct svc_program nfs4_callback_program;
36 36
37unsigned int nfs_callback_set_tcpport;
37unsigned short nfs_callback_tcpport; 38unsigned short nfs_callback_tcpport;
38 39
39/* 40/*
@@ -98,7 +99,7 @@ int nfs_callback_up(void)
98 if (!serv) 99 if (!serv)
99 goto out_err; 100 goto out_err;
100 /* FIXME: We don't want to register this socket with the portmapper */ 101 /* FIXME: We don't want to register this socket with the portmapper */
101 ret = svc_makesock(serv, IPPROTO_TCP, 0); 102 ret = svc_makesock(serv, IPPROTO_TCP, nfs_callback_set_tcpport);
102 if (ret < 0) 103 if (ret < 0)
103 goto out_destroy; 104 goto out_destroy;
104 if (!list_empty(&serv->sv_permsocks)) { 105 if (!list_empty(&serv->sv_permsocks)) {
diff --git a/fs/nfs/callback.h b/fs/nfs/callback.h
index a0db2d4f9415..b252e7fe53a5 100644
--- a/fs/nfs/callback.h
+++ b/fs/nfs/callback.h
@@ -65,6 +65,7 @@ extern unsigned nfs4_callback_recall(struct cb_recallargs *args, void *dummy);
65extern int nfs_callback_up(void); 65extern int nfs_callback_up(void);
66extern int nfs_callback_down(void); 66extern int nfs_callback_down(void);
67 67
68extern unsigned int nfs_callback_set_tcpport;
68extern unsigned short nfs_callback_tcpport; 69extern unsigned short nfs_callback_tcpport;
69 70
70#endif /* __LINUX_FS_NFS_CALLBACK_H */ 71#endif /* __LINUX_FS_NFS_CALLBACK_H */
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 7270b1d73d30..648cb1aef3b1 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -40,6 +40,7 @@
40#include <asm/uaccess.h> 40#include <asm/uaccess.h>
41 41
42#include "nfs4_fs.h" 42#include "nfs4_fs.h"
43#include "callback.h"
43#include "delegation.h" 44#include "delegation.h"
44 45
45#define NFSDBG_FACILITY NFSDBG_VFS 46#define NFSDBG_FACILITY NFSDBG_VFS
@@ -2036,6 +2037,21 @@ static struct file_system_type nfs4_fs_type = {
2036 .fs_flags = FS_ODD_RENAME|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, 2037 .fs_flags = FS_ODD_RENAME|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
2037}; 2038};
2038 2039
2040static const int nfs_set_port_min = 0;
2041static const int nfs_set_port_max = 65535;
2042static int param_set_port(const char *val, struct kernel_param *kp)
2043{
2044 char *endp;
2045 int num = simple_strtol(val, &endp, 0);
2046 if (endp == val || *endp || num < nfs_set_port_min || num > nfs_set_port_max)
2047 return -EINVAL;
2048 *((int *)kp->arg) = num;
2049 return 0;
2050}
2051
2052module_param_call(callback_tcpport, param_set_port, param_get_int,
2053 &nfs_callback_set_tcpport, 0644);
2054
2039#define nfs4_init_once(nfsi) \ 2055#define nfs4_init_once(nfsi) \
2040 do { \ 2056 do { \
2041 INIT_LIST_HEAD(&(nfsi)->open_states); \ 2057 INIT_LIST_HEAD(&(nfsi)->open_states); \
@@ -2043,8 +2059,25 @@ static struct file_system_type nfs4_fs_type = {
2043 nfsi->delegation_state = 0; \ 2059 nfsi->delegation_state = 0; \
2044 init_rwsem(&nfsi->rwsem); \ 2060 init_rwsem(&nfsi->rwsem); \
2045 } while(0) 2061 } while(0)
2046#define register_nfs4fs() register_filesystem(&nfs4_fs_type) 2062
2047#define unregister_nfs4fs() unregister_filesystem(&nfs4_fs_type) 2063static inline int register_nfs4fs(void)
2064{
2065 int ret;
2066
2067 ret = nfs_register_sysctl();
2068 if (ret != 0)
2069 return ret;
2070 ret = register_filesystem(&nfs4_fs_type);
2071 if (ret != 0)
2072 nfs_unregister_sysctl();
2073 return ret;
2074}
2075
2076static inline void unregister_nfs4fs(void)
2077{
2078 unregister_filesystem(&nfs4_fs_type);
2079 nfs_unregister_sysctl();
2080}
2048#else 2081#else
2049#define nfs4_init_once(nfsi) \ 2082#define nfs4_init_once(nfsi) \
2050 do { } while (0) 2083 do { } while (0)
diff --git a/fs/nfs/sysctl.c b/fs/nfs/sysctl.c
new file mode 100644
index 000000000000..fdc64b59a4ee
--- /dev/null
+++ b/fs/nfs/sysctl.c
@@ -0,0 +1,74 @@
1/*
2 * linux/fs/nfs/sysctl.c
3 *
4 * Sysctl interface to NFS parameters
5 */
6#include <linux/config.h>
7#include <linux/types.h>
8#include <linux/linkage.h>
9#include <linux/ctype.h>
10#include <linux/fs.h>
11#include <linux/sysctl.h>
12#include <linux/module.h>
13#include <linux/nfs4.h>
14
15#include "callback.h"
16
17static const int nfs_set_port_min = 0;
18static const int nfs_set_port_max = 65535;
19static struct ctl_table_header *nfs_callback_sysctl_table;
20/*
21 * Something that isn't CTL_ANY, CTL_NONE or a value that may clash.
22 * Use the same values as fs/lockd/svc.c
23 */
24#define CTL_UNNUMBERED -2
25
26static ctl_table nfs_cb_sysctls[] = {
27#ifdef CONFIG_NFS_V4
28 {
29 .ctl_name = CTL_UNNUMBERED,
30 .procname = "nfs_callback_tcpport",
31 .data = &nfs_callback_set_tcpport,
32 .maxlen = sizeof(int),
33 .mode = 0644,
34 .proc_handler = &proc_dointvec_minmax,
35 .extra1 = (int *)&nfs_set_port_min,
36 .extra2 = (int *)&nfs_set_port_max,
37 },
38#endif
39 { .ctl_name = 0 }
40};
41
42static ctl_table nfs_cb_sysctl_dir[] = {
43 {
44 .ctl_name = CTL_UNNUMBERED,
45 .procname = "nfs",
46 .mode = 0555,
47 .child = nfs_cb_sysctls,
48 },
49 { .ctl_name = 0 }
50};
51
52static ctl_table nfs_cb_sysctl_root[] = {
53 {
54 .ctl_name = CTL_FS,
55 .procname = "fs",
56 .mode = 0555,
57 .child = nfs_cb_sysctl_dir,
58 },
59 { .ctl_name = 0 }
60};
61
62int nfs_register_sysctl(void)
63{
64 nfs_callback_sysctl_table = register_sysctl_table(nfs_cb_sysctl_root, 0);
65 if (nfs_callback_sysctl_table == NULL)
66 return -ENOMEM;
67 return 0;
68}
69
70void nfs_unregister_sysctl(void)
71{
72 unregister_sysctl_table(nfs_callback_sysctl_table);
73 nfs_callback_sysctl_table = NULL;
74}