Merge rsync://rsync.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
[linux-2.6] / net / core / sysctl_net_core.c
1 /* -*- linux-c -*-
2  * sysctl_net_core.c: sysctl interface to net core subsystem.
3  *
4  * Begun April 1, 1996, Mike Shaver.
5  * Added /proc/sys/net/core directory entry (empty =) ). [MS]
6  */
7
8 #include <linux/mm.h>
9 #include <linux/sysctl.h>
10 #include <linux/config.h>
11 #include <linux/module.h>
12
13 #ifdef CONFIG_SYSCTL
14
15 extern int netdev_max_backlog;
16 extern int weight_p;
17 extern int no_cong_thresh;
18 extern int no_cong;
19 extern int lo_cong;
20 extern int mod_cong;
21 extern int netdev_fastroute;
22 extern int net_msg_cost;
23 extern int net_msg_burst;
24
25 extern __u32 sysctl_wmem_max;
26 extern __u32 sysctl_rmem_max;
27 extern __u32 sysctl_wmem_default;
28 extern __u32 sysctl_rmem_default;
29
30 extern int sysctl_core_destroy_delay;
31 extern int sysctl_optmem_max;
32 extern int sysctl_somaxconn;
33
34 #ifdef CONFIG_NET_DIVERT
35 extern char sysctl_divert_version[];
36 #endif /* CONFIG_NET_DIVERT */
37
38 /*
39  * This strdup() is used for creating copies of network 
40  * device names to be handed over to sysctl.
41  */
42  
43 char *net_sysctl_strdup(const char *s)
44 {
45         char *rv = kmalloc(strlen(s)+1, GFP_KERNEL);
46         if (rv)
47                 strcpy(rv, s);
48         return rv;
49 }
50
51 ctl_table core_table[] = {
52 #ifdef CONFIG_NET
53         {
54                 .ctl_name       = NET_CORE_WMEM_MAX,
55                 .procname       = "wmem_max",
56                 .data           = &sysctl_wmem_max,
57                 .maxlen         = sizeof(int),
58                 .mode           = 0644,
59                 .proc_handler   = &proc_dointvec
60         },
61         {
62                 .ctl_name       = NET_CORE_RMEM_MAX,
63                 .procname       = "rmem_max",
64                 .data           = &sysctl_rmem_max,
65                 .maxlen         = sizeof(int),
66                 .mode           = 0644,
67                 .proc_handler   = &proc_dointvec
68         },
69         {
70                 .ctl_name       = NET_CORE_WMEM_DEFAULT,
71                 .procname       = "wmem_default",
72                 .data           = &sysctl_wmem_default,
73                 .maxlen         = sizeof(int),
74                 .mode           = 0644,
75                 .proc_handler   = &proc_dointvec
76         },
77         {
78                 .ctl_name       = NET_CORE_RMEM_DEFAULT,
79                 .procname       = "rmem_default",
80                 .data           = &sysctl_rmem_default,
81                 .maxlen         = sizeof(int),
82                 .mode           = 0644,
83                 .proc_handler   = &proc_dointvec
84         },
85         {
86                 .ctl_name       = NET_CORE_DEV_WEIGHT,
87                 .procname       = "dev_weight",
88                 .data           = &weight_p,
89                 .maxlen         = sizeof(int),
90                 .mode           = 0644,
91                 .proc_handler   = &proc_dointvec
92         },
93         {
94                 .ctl_name       = NET_CORE_MAX_BACKLOG,
95                 .procname       = "netdev_max_backlog",
96                 .data           = &netdev_max_backlog,
97                 .maxlen         = sizeof(int),
98                 .mode           = 0644,
99                 .proc_handler   = &proc_dointvec
100         },
101         {
102                 .ctl_name       = NET_CORE_NO_CONG_THRESH,
103                 .procname       = "no_cong_thresh",
104                 .data           = &no_cong_thresh,
105                 .maxlen         = sizeof(int),
106                 .mode           = 0644,
107                 .proc_handler   = &proc_dointvec
108         },
109         {
110                 .ctl_name       = NET_CORE_NO_CONG,
111                 .procname       = "no_cong",
112                 .data           = &no_cong,
113                 .maxlen         = sizeof(int),
114                 .mode           = 0644,
115                 .proc_handler   = &proc_dointvec
116         },
117         {
118                 .ctl_name       = NET_CORE_LO_CONG,
119                 .procname       = "lo_cong",
120                 .data           = &lo_cong,
121                 .maxlen         = sizeof(int),
122                 .mode           = 0644,
123                 .proc_handler   = &proc_dointvec
124         },
125         {
126                 .ctl_name       = NET_CORE_MOD_CONG,
127                 .procname       = "mod_cong",
128                 .data           = &mod_cong,
129                 .maxlen         = sizeof(int),
130                 .mode           = 0644,
131                 .proc_handler   = &proc_dointvec
132         },
133         {
134                 .ctl_name       = NET_CORE_MSG_COST,
135                 .procname       = "message_cost",
136                 .data           = &net_msg_cost,
137                 .maxlen         = sizeof(int),
138                 .mode           = 0644,
139                 .proc_handler   = &proc_dointvec_jiffies,
140                 .strategy       = &sysctl_jiffies,
141         },
142         {
143                 .ctl_name       = NET_CORE_MSG_BURST,
144                 .procname       = "message_burst",
145                 .data           = &net_msg_burst,
146                 .maxlen         = sizeof(int),
147                 .mode           = 0644,
148                 .proc_handler   = &proc_dointvec,
149         },
150         {
151                 .ctl_name       = NET_CORE_OPTMEM_MAX,
152                 .procname       = "optmem_max",
153                 .data           = &sysctl_optmem_max,
154                 .maxlen         = sizeof(int),
155                 .mode           = 0644,
156                 .proc_handler   = &proc_dointvec
157         },
158 #ifdef CONFIG_NET_DIVERT
159         {
160                 .ctl_name       = NET_CORE_DIVERT_VERSION,
161                 .procname       = "divert_version",
162                 .data           = (void *)sysctl_divert_version,
163                 .maxlen         = 32,
164                 .mode           = 0444,
165                 .proc_handler   = &proc_dostring
166         },
167 #endif /* CONFIG_NET_DIVERT */
168 #endif /* CONFIG_NET */
169         {
170                 .ctl_name       = NET_CORE_SOMAXCONN,
171                 .procname       = "somaxconn",
172                 .data           = &sysctl_somaxconn,
173                 .maxlen         = sizeof(int),
174                 .mode           = 0644,
175                 .proc_handler   = &proc_dointvec
176         },
177         { .ctl_name = 0 }
178 };
179
180 EXPORT_SYMBOL(net_sysctl_strdup);
181
182 #endif