NFSv4: Allow user to set the port used by the NFSv4 callback channel
[linux-2.6-block.git] / fs / nfs / sysctl.c
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
17 static const int nfs_set_port_min = 0;
18 static const int nfs_set_port_max = 65535;
19 static 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
26 static 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
42 static 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
52 static 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
62 int 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
70 void nfs_unregister_sysctl(void)
71 {
72         unregister_sysctl_table(nfs_callback_sysctl_table);
73         nfs_callback_sysctl_table = NULL;
74 }