Root/kernel/sysctl_check.c

1#include <linux/stat.h>
2#include <linux/sysctl.h>
3#include "../fs/xfs/linux-2.6/xfs_sysctl.h"
4#include <linux/sunrpc/debug.h>
5#include <linux/string.h>
6#include <net/ip_vs.h>
7
8struct trans_ctl_table {
9    int ctl_name;
10    const char *procname;
11    const struct trans_ctl_table *child;
12};
13
14static const struct trans_ctl_table trans_random_table[] = {
15    { RANDOM_POOLSIZE, "poolsize" },
16    { RANDOM_ENTROPY_COUNT, "entropy_avail" },
17    { RANDOM_READ_THRESH, "read_wakeup_threshold" },
18    { RANDOM_WRITE_THRESH, "write_wakeup_threshold" },
19    { RANDOM_BOOT_ID, "boot_id" },
20    { RANDOM_UUID, "uuid" },
21    {}
22};
23
24static const struct trans_ctl_table trans_pty_table[] = {
25    { PTY_MAX, "max" },
26    { PTY_NR, "nr" },
27    {}
28};
29
30static const struct trans_ctl_table trans_kern_table[] = {
31    { KERN_OSTYPE, "ostype" },
32    { KERN_OSRELEASE, "osrelease" },
33    /* KERN_OSREV not used */
34    { KERN_VERSION, "version" },
35    /* KERN_SECUREMASK not used */
36    /* KERN_PROF not used */
37    { KERN_NODENAME, "hostname" },
38    { KERN_DOMAINNAME, "domainname" },
39
40    { KERN_PANIC, "panic" },
41    { KERN_REALROOTDEV, "real-root-dev" },
42
43    { KERN_SPARC_REBOOT, "reboot-cmd" },
44    { KERN_CTLALTDEL, "ctrl-alt-del" },
45    { KERN_PRINTK, "printk" },
46
47    /* KERN_NAMETRANS not used */
48    /* KERN_PPC_HTABRECLAIM not used */
49    /* KERN_PPC_ZEROPAGED not used */
50    { KERN_PPC_POWERSAVE_NAP, "powersave-nap" },
51
52    { KERN_MODPROBE, "modprobe" },
53    { KERN_SG_BIG_BUFF, "sg-big-buff" },
54    { KERN_ACCT, "acct" },
55    { KERN_PPC_L2CR, "l2cr" },
56
57    /* KERN_RTSIGNR not used */
58    /* KERN_RTSIGMAX not used */
59
60    { KERN_SHMMAX, "shmmax" },
61    { KERN_MSGMAX, "msgmax" },
62    { KERN_MSGMNB, "msgmnb" },
63    /* KERN_MSGPOOL not used*/
64    { KERN_SYSRQ, "sysrq" },
65    { KERN_MAX_THREADS, "threads-max" },
66    { KERN_RANDOM, "random", trans_random_table },
67    { KERN_SHMALL, "shmall" },
68    { KERN_MSGMNI, "msgmni" },
69    { KERN_SEM, "sem" },
70    { KERN_SPARC_STOP_A, "stop-a" },
71    { KERN_SHMMNI, "shmmni" },
72
73    { KERN_OVERFLOWUID, "overflowuid" },
74    { KERN_OVERFLOWGID, "overflowgid" },
75
76    { KERN_HOTPLUG, "hotplug", },
77    { KERN_IEEE_EMULATION_WARNINGS, "ieee_emulation_warnings" },
78
79    { KERN_S390_USER_DEBUG_LOGGING, "userprocess_debug" },
80    { KERN_CORE_USES_PID, "core_uses_pid" },
81    { KERN_TAINTED, "tainted" },
82    { KERN_CADPID, "cad_pid" },
83    { KERN_PIDMAX, "pid_max" },
84    { KERN_CORE_PATTERN, "core_pattern" },
85    { KERN_PANIC_ON_OOPS, "panic_on_oops" },
86    { KERN_HPPA_PWRSW, "soft-power" },
87    { KERN_HPPA_UNALIGNED, "unaligned-trap" },
88
89    { KERN_PRINTK_RATELIMIT, "printk_ratelimit" },
90    { KERN_PRINTK_RATELIMIT_BURST, "printk_ratelimit_burst" },
91
92    { KERN_PTY, "pty", trans_pty_table },
93    { KERN_NGROUPS_MAX, "ngroups_max" },
94    { KERN_SPARC_SCONS_PWROFF, "scons-poweroff" },
95    { KERN_HZ_TIMER, "hz_timer" },
96    { KERN_UNKNOWN_NMI_PANIC, "unknown_nmi_panic" },
97    { KERN_BOOTLOADER_TYPE, "bootloader_type" },
98    { KERN_RANDOMIZE, "randomize_va_space" },
99
100    { KERN_SPIN_RETRY, "spin_retry" },
101    { KERN_ACPI_VIDEO_FLAGS, "acpi_video_flags" },
102    { KERN_IA64_UNALIGNED, "ignore-unaligned-usertrap" },
103    { KERN_COMPAT_LOG, "compat-log" },
104    { KERN_MAX_LOCK_DEPTH, "max_lock_depth" },
105    { KERN_NMI_WATCHDOG, "nmi_watchdog" },
106    { KERN_PANIC_ON_NMI, "panic_on_unrecovered_nmi" },
107    {}
108};
109
110static const struct trans_ctl_table trans_vm_table[] = {
111    { VM_OVERCOMMIT_MEMORY, "overcommit_memory" },
112    { VM_PAGE_CLUSTER, "page-cluster" },
113    { VM_DIRTY_BACKGROUND, "dirty_background_ratio" },
114    { VM_DIRTY_RATIO, "dirty_ratio" },
115    { VM_DIRTY_WB_CS, "dirty_writeback_centisecs" },
116    { VM_DIRTY_EXPIRE_CS, "dirty_expire_centisecs" },
117    { VM_NR_PDFLUSH_THREADS, "nr_pdflush_threads" },
118    { VM_OVERCOMMIT_RATIO, "overcommit_ratio" },
119    /* VM_PAGEBUF unused */
120    { VM_HUGETLB_PAGES, "nr_hugepages" },
121    { VM_SWAPPINESS, "swappiness" },
122    { VM_LOWMEM_RESERVE_RATIO, "lowmem_reserve_ratio" },
123    { VM_MIN_FREE_KBYTES, "min_free_kbytes" },
124    { VM_MAX_MAP_COUNT, "max_map_count" },
125    { VM_LAPTOP_MODE, "laptop_mode" },
126    { VM_BLOCK_DUMP, "block_dump" },
127    { VM_HUGETLB_GROUP, "hugetlb_shm_group" },
128    { VM_VFS_CACHE_PRESSURE, "vfs_cache_pressure" },
129    { VM_LEGACY_VA_LAYOUT, "legacy_va_layout" },
130    /* VM_SWAP_TOKEN_TIMEOUT unused */
131    { VM_DROP_PAGECACHE, "drop_caches" },
132    { VM_PERCPU_PAGELIST_FRACTION, "percpu_pagelist_fraction" },
133    { VM_ZONE_RECLAIM_MODE, "zone_reclaim_mode" },
134    { VM_MIN_UNMAPPED, "min_unmapped_ratio" },
135    { VM_PANIC_ON_OOM, "panic_on_oom" },
136    { VM_VDSO_ENABLED, "vdso_enabled" },
137    { VM_MIN_SLAB, "min_slab_ratio" },
138
139    {}
140};
141
142static const struct trans_ctl_table trans_net_core_table[] = {
143    { NET_CORE_WMEM_MAX, "wmem_max" },
144    { NET_CORE_RMEM_MAX, "rmem_max" },
145    { NET_CORE_WMEM_DEFAULT, "wmem_default" },
146    { NET_CORE_RMEM_DEFAULT, "rmem_default" },
147    /* NET_CORE_DESTROY_DELAY unused */
148    { NET_CORE_MAX_BACKLOG, "netdev_max_backlog" },
149    /* NET_CORE_FASTROUTE unused */
150    { NET_CORE_MSG_COST, "message_cost" },
151    { NET_CORE_MSG_BURST, "message_burst" },
152    { NET_CORE_OPTMEM_MAX, "optmem_max" },
153    /* NET_CORE_HOT_LIST_LENGTH unused */
154    /* NET_CORE_DIVERT_VERSION unused */
155    /* NET_CORE_NO_CONG_THRESH unused */
156    /* NET_CORE_NO_CONG unused */
157    /* NET_CORE_LO_CONG unused */
158    /* NET_CORE_MOD_CONG unused */
159    { NET_CORE_DEV_WEIGHT, "dev_weight" },
160    { NET_CORE_SOMAXCONN, "somaxconn" },
161    { NET_CORE_BUDGET, "netdev_budget" },
162    { NET_CORE_AEVENT_ETIME, "xfrm_aevent_etime" },
163    { NET_CORE_AEVENT_RSEQTH, "xfrm_aevent_rseqth" },
164    { NET_CORE_WARNINGS, "warnings" },
165    {},
166};
167
168static const struct trans_ctl_table trans_net_unix_table[] = {
169    /* NET_UNIX_DESTROY_DELAY unused */
170    /* NET_UNIX_DELETE_DELAY unused */
171    { NET_UNIX_MAX_DGRAM_QLEN, "max_dgram_qlen" },
172    {}
173};
174
175static const struct trans_ctl_table trans_net_ipv4_route_table[] = {
176    { NET_IPV4_ROUTE_FLUSH, "flush" },
177    { NET_IPV4_ROUTE_MIN_DELAY, "min_delay" },
178    { NET_IPV4_ROUTE_MAX_DELAY, "max_delay" },
179    { NET_IPV4_ROUTE_GC_THRESH, "gc_thresh" },
180    { NET_IPV4_ROUTE_MAX_SIZE, "max_size" },
181    { NET_IPV4_ROUTE_GC_MIN_INTERVAL, "gc_min_interval" },
182    { NET_IPV4_ROUTE_GC_TIMEOUT, "gc_timeout" },
183    { NET_IPV4_ROUTE_GC_INTERVAL, "gc_interval" },
184    { NET_IPV4_ROUTE_REDIRECT_LOAD, "redirect_load" },
185    { NET_IPV4_ROUTE_REDIRECT_NUMBER, "redirect_number" },
186    { NET_IPV4_ROUTE_REDIRECT_SILENCE, "redirect_silence" },
187    { NET_IPV4_ROUTE_ERROR_COST, "error_cost" },
188    { NET_IPV4_ROUTE_ERROR_BURST, "error_burst" },
189    { NET_IPV4_ROUTE_GC_ELASTICITY, "gc_elasticity" },
190    { NET_IPV4_ROUTE_MTU_EXPIRES, "mtu_expires" },
191    { NET_IPV4_ROUTE_MIN_PMTU, "min_pmtu" },
192    { NET_IPV4_ROUTE_MIN_ADVMSS, "min_adv_mss" },
193    { NET_IPV4_ROUTE_SECRET_INTERVAL, "secret_interval" },
194    { NET_IPV4_ROUTE_GC_MIN_INTERVAL_MS, "gc_min_interval_ms" },
195    {}
196};
197
198static const struct trans_ctl_table trans_net_ipv4_conf_vars_table[] = {
199    { NET_IPV4_CONF_FORWARDING, "forwarding" },
200    { NET_IPV4_CONF_MC_FORWARDING, "mc_forwarding" },
201
202    { NET_IPV4_CONF_PROXY_ARP, "proxy_arp" },
203    { NET_IPV4_CONF_ACCEPT_REDIRECTS, "accept_redirects" },
204    { NET_IPV4_CONF_SECURE_REDIRECTS, "secure_redirects" },
205    { NET_IPV4_CONF_SEND_REDIRECTS, "send_redirects" },
206    { NET_IPV4_CONF_SHARED_MEDIA, "shared_media" },
207    { NET_IPV4_CONF_RP_FILTER, "rp_filter" },
208    { NET_IPV4_CONF_ACCEPT_SOURCE_ROUTE, "accept_source_route" },
209    { NET_IPV4_CONF_BOOTP_RELAY, "bootp_relay" },
210    { NET_IPV4_CONF_LOG_MARTIANS, "log_martians" },
211    { NET_IPV4_CONF_TAG, "tag" },
212    { NET_IPV4_CONF_ARPFILTER, "arp_filter" },
213    { NET_IPV4_CONF_MEDIUM_ID, "medium_id" },
214    { NET_IPV4_CONF_NOXFRM, "disable_xfrm" },
215    { NET_IPV4_CONF_NOPOLICY, "disable_policy" },
216    { NET_IPV4_CONF_FORCE_IGMP_VERSION, "force_igmp_version" },
217
218    { NET_IPV4_CONF_ARP_ANNOUNCE, "arp_announce" },
219    { NET_IPV4_CONF_ARP_IGNORE, "arp_ignore" },
220    { NET_IPV4_CONF_PROMOTE_SECONDARIES, "promote_secondaries" },
221    { NET_IPV4_CONF_ARP_ACCEPT, "arp_accept" },
222    { NET_IPV4_CONF_ARP_NOTIFY, "arp_notify" },
223    { NET_IPV4_CONF_SRC_VMARK, "src_valid_mark" },
224    {}
225};
226
227static const struct trans_ctl_table trans_net_ipv4_conf_table[] = {
228    { NET_PROTO_CONF_ALL, "all", trans_net_ipv4_conf_vars_table },
229    { NET_PROTO_CONF_DEFAULT, "default", trans_net_ipv4_conf_vars_table },
230    { 0, NULL, trans_net_ipv4_conf_vars_table },
231    {}
232};
233
234static const struct trans_ctl_table trans_net_neigh_vars_table[] = {
235    { NET_NEIGH_MCAST_SOLICIT, "mcast_solicit" },
236    { NET_NEIGH_UCAST_SOLICIT, "ucast_solicit" },
237    { NET_NEIGH_APP_SOLICIT, "app_solicit" },
238    { NET_NEIGH_RETRANS_TIME, "retrans_time" },
239    { NET_NEIGH_REACHABLE_TIME, "base_reachable_time" },
240    { NET_NEIGH_DELAY_PROBE_TIME, "delay_first_probe_time" },
241    { NET_NEIGH_GC_STALE_TIME, "gc_stale_time" },
242    { NET_NEIGH_UNRES_QLEN, "unres_qlen" },
243    { NET_NEIGH_PROXY_QLEN, "proxy_qlen" },
244    { NET_NEIGH_ANYCAST_DELAY, "anycast_delay" },
245    { NET_NEIGH_PROXY_DELAY, "proxy_delay" },
246    { NET_NEIGH_LOCKTIME, "locktime" },
247    { NET_NEIGH_GC_INTERVAL, "gc_interval" },
248    { NET_NEIGH_GC_THRESH1, "gc_thresh1" },
249    { NET_NEIGH_GC_THRESH2, "gc_thresh2" },
250    { NET_NEIGH_GC_THRESH3, "gc_thresh3" },
251    { NET_NEIGH_RETRANS_TIME_MS, "retrans_time_ms" },
252    { NET_NEIGH_REACHABLE_TIME_MS, "base_reachable_time_ms" },
253    {}
254};
255
256static const struct trans_ctl_table trans_net_neigh_table[] = {
257    { NET_PROTO_CONF_DEFAULT, "default", trans_net_neigh_vars_table },
258    { 0, NULL, trans_net_neigh_vars_table },
259    {}
260};
261
262static const struct trans_ctl_table trans_net_ipv4_netfilter_table[] = {
263    { NET_IPV4_NF_CONNTRACK_MAX, "ip_conntrack_max" },
264
265    { NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_SYN_SENT, "ip_conntrack_tcp_timeout_syn_sent" },
266    { NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_SYN_RECV, "ip_conntrack_tcp_timeout_syn_recv" },
267    { NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_ESTABLISHED, "ip_conntrack_tcp_timeout_established" },
268    { NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_FIN_WAIT, "ip_conntrack_tcp_timeout_fin_wait" },
269    { NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_CLOSE_WAIT, "ip_conntrack_tcp_timeout_close_wait" },
270    { NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_LAST_ACK, "ip_conntrack_tcp_timeout_last_ack" },
271    { NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_TIME_WAIT, "ip_conntrack_tcp_timeout_time_wait" },
272    { NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_CLOSE, "ip_conntrack_tcp_timeout_close" },
273
274    { NET_IPV4_NF_CONNTRACK_UDP_TIMEOUT, "ip_conntrack_udp_timeout" },
275    { NET_IPV4_NF_CONNTRACK_UDP_TIMEOUT_STREAM, "ip_conntrack_udp_timeout_stream" },
276    { NET_IPV4_NF_CONNTRACK_ICMP_TIMEOUT, "ip_conntrack_icmp_timeout" },
277    { NET_IPV4_NF_CONNTRACK_GENERIC_TIMEOUT, "ip_conntrack_generic_timeout" },
278
279    { NET_IPV4_NF_CONNTRACK_BUCKETS, "ip_conntrack_buckets" },
280    { NET_IPV4_NF_CONNTRACK_LOG_INVALID, "ip_conntrack_log_invalid" },
281    { NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_MAX_RETRANS, "ip_conntrack_tcp_timeout_max_retrans" },
282    { NET_IPV4_NF_CONNTRACK_TCP_LOOSE, "ip_conntrack_tcp_loose" },
283    { NET_IPV4_NF_CONNTRACK_TCP_BE_LIBERAL, "ip_conntrack_tcp_be_liberal" },
284    { NET_IPV4_NF_CONNTRACK_TCP_MAX_RETRANS, "ip_conntrack_tcp_max_retrans" },
285
286    { NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_CLOSED, "ip_conntrack_sctp_timeout_closed" },
287    { NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_COOKIE_WAIT, "ip_conntrack_sctp_timeout_cookie_wait" },
288    { NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_COOKIE_ECHOED, "ip_conntrack_sctp_timeout_cookie_echoed" },
289    { NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_ESTABLISHED, "ip_conntrack_sctp_timeout_established" },
290    { NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_SENT, "ip_conntrack_sctp_timeout_shutdown_sent" },
291    { NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_RECD, "ip_conntrack_sctp_timeout_shutdown_recd" },
292    { NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_ACK_SENT, "ip_conntrack_sctp_timeout_shutdown_ack_sent" },
293
294    { NET_IPV4_NF_CONNTRACK_COUNT, "ip_conntrack_count" },
295    { NET_IPV4_NF_CONNTRACK_CHECKSUM, "ip_conntrack_checksum" },
296    {}
297};
298
299static const struct trans_ctl_table trans_net_ipv4_table[] = {
300    { NET_IPV4_FORWARD, "ip_forward" },
301    { NET_IPV4_DYNADDR, "ip_dynaddr" },
302
303    { NET_IPV4_CONF, "conf", trans_net_ipv4_conf_table },
304    { NET_IPV4_NEIGH, "neigh", trans_net_neigh_table },
305    { NET_IPV4_ROUTE, "route", trans_net_ipv4_route_table },
306    /* NET_IPV4_FIB_HASH unused */
307    { NET_IPV4_NETFILTER, "netfilter", trans_net_ipv4_netfilter_table },
308
309    { NET_IPV4_TCP_TIMESTAMPS, "tcp_timestamps" },
310    { NET_IPV4_TCP_WINDOW_SCALING, "tcp_window_scaling" },
311    { NET_IPV4_TCP_SACK, "tcp_sack" },
312    { NET_IPV4_TCP_RETRANS_COLLAPSE, "tcp_retrans_collapse" },
313    { NET_IPV4_DEFAULT_TTL, "ip_default_ttl" },
314    /* NET_IPV4_AUTOCONFIG unused */
315    { NET_IPV4_NO_PMTU_DISC, "ip_no_pmtu_disc" },
316    { NET_IPV4_TCP_SYN_RETRIES, "tcp_syn_retries" },
317    { NET_IPV4_IPFRAG_HIGH_THRESH, "ipfrag_high_thresh" },
318    { NET_IPV4_IPFRAG_LOW_THRESH, "ipfrag_low_thresh" },
319    { NET_IPV4_IPFRAG_TIME, "ipfrag_time" },
320    /* NET_IPV4_TCP_MAX_KA_PROBES unused */
321    { NET_IPV4_TCP_KEEPALIVE_TIME, "tcp_keepalive_time" },
322    { NET_IPV4_TCP_KEEPALIVE_PROBES, "tcp_keepalive_probes" },
323    { NET_IPV4_TCP_RETRIES1, "tcp_retries1" },
324    { NET_IPV4_TCP_RETRIES2, "tcp_retries2" },
325    { NET_IPV4_TCP_FIN_TIMEOUT, "tcp_fin_timeout" },
326    /* NET_IPV4_IP_MASQ_DEBUG unused */
327    { NET_TCP_SYNCOOKIES, "tcp_syncookies" },
328    { NET_TCP_STDURG, "tcp_stdurg" },
329    { NET_TCP_RFC1337, "tcp_rfc1337" },
330    /* NET_TCP_SYN_TAILDROP unused */
331    { NET_TCP_MAX_SYN_BACKLOG, "tcp_max_syn_backlog" },
332    { NET_IPV4_LOCAL_PORT_RANGE, "ip_local_port_range" },
333    { NET_IPV4_ICMP_ECHO_IGNORE_ALL, "icmp_echo_ignore_all" },
334    { NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS, "icmp_echo_ignore_broadcasts" },
335    /* NET_IPV4_ICMP_SOURCEQUENCH_RATE unused */
336    /* NET_IPV4_ICMP_DESTUNREACH_RATE unused */
337    /* NET_IPV4_ICMP_TIMEEXCEED_RATE unused */
338    /* NET_IPV4_ICMP_PARAMPROB_RATE unused */
339    /* NET_IPV4_ICMP_ECHOREPLY_RATE unused */
340    { NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES, "icmp_ignore_bogus_error_responses" },
341    { NET_IPV4_IGMP_MAX_MEMBERSHIPS, "igmp_max_memberships" },
342    { NET_TCP_TW_RECYCLE, "tcp_tw_recycle" },
343    /* NET_IPV4_ALWAYS_DEFRAG unused */
344    { NET_IPV4_TCP_KEEPALIVE_INTVL, "tcp_keepalive_intvl" },
345    { NET_IPV4_INET_PEER_THRESHOLD, "inet_peer_threshold" },
346    { NET_IPV4_INET_PEER_MINTTL, "inet_peer_minttl" },
347    { NET_IPV4_INET_PEER_MAXTTL, "inet_peer_maxttl" },
348    { NET_IPV4_INET_PEER_GC_MINTIME, "inet_peer_gc_mintime" },
349    { NET_IPV4_INET_PEER_GC_MAXTIME, "inet_peer_gc_maxtime" },
350    { NET_TCP_ORPHAN_RETRIES, "tcp_orphan_retries" },
351    { NET_TCP_ABORT_ON_OVERFLOW, "tcp_abort_on_overflow" },
352    { NET_TCP_SYNACK_RETRIES, "tcp_synack_retries" },
353    { NET_TCP_MAX_ORPHANS, "tcp_max_orphans" },
354    { NET_TCP_MAX_TW_BUCKETS, "tcp_max_tw_buckets" },
355    { NET_TCP_FACK, "tcp_fack" },
356    { NET_TCP_REORDERING, "tcp_reordering" },
357    { NET_TCP_ECN, "tcp_ecn" },
358    { NET_TCP_DSACK, "tcp_dsack" },
359    { NET_TCP_MEM, "tcp_mem" },
360    { NET_TCP_WMEM, "tcp_wmem" },
361    { NET_TCP_RMEM, "tcp_rmem" },
362    { NET_TCP_APP_WIN, "tcp_app_win" },
363    { NET_TCP_ADV_WIN_SCALE, "tcp_adv_win_scale" },
364    { NET_IPV4_NONLOCAL_BIND, "ip_nonlocal_bind" },
365    { NET_IPV4_ICMP_RATELIMIT, "icmp_ratelimit" },
366    { NET_IPV4_ICMP_RATEMASK, "icmp_ratemask" },
367    { NET_TCP_TW_REUSE, "tcp_tw_reuse" },
368    { NET_TCP_FRTO, "tcp_frto" },
369    { NET_TCP_LOW_LATENCY, "tcp_low_latency" },
370    { NET_IPV4_IPFRAG_SECRET_INTERVAL, "ipfrag_secret_interval" },
371    { NET_IPV4_IGMP_MAX_MSF, "igmp_max_msf" },
372    { NET_TCP_NO_METRICS_SAVE, "tcp_no_metrics_save" },
373    /* NET_TCP_DEFAULT_WIN_SCALE unused */
374    { NET_TCP_MODERATE_RCVBUF, "tcp_moderate_rcvbuf" },
375    { NET_TCP_TSO_WIN_DIVISOR, "tcp_tso_win_divisor" },
376    /* NET_TCP_BIC_BETA unused */
377    { NET_IPV4_ICMP_ERRORS_USE_INBOUND_IFADDR, "icmp_errors_use_inbound_ifaddr" },
378    { NET_TCP_CONG_CONTROL, "tcp_congestion_control" },
379    { NET_TCP_ABC, "tcp_abc" },
380    { NET_IPV4_IPFRAG_MAX_DIST, "ipfrag_max_dist" },
381    { NET_TCP_MTU_PROBING, "tcp_mtu_probing" },
382    { NET_TCP_BASE_MSS, "tcp_base_mss" },
383    { NET_IPV4_TCP_WORKAROUND_SIGNED_WINDOWS, "tcp_workaround_signed_windows" },
384    { NET_TCP_DMA_COPYBREAK, "tcp_dma_copybreak" },
385    { NET_TCP_SLOW_START_AFTER_IDLE, "tcp_slow_start_after_idle" },
386    { NET_CIPSOV4_CACHE_ENABLE, "cipso_cache_enable" },
387    { NET_CIPSOV4_CACHE_BUCKET_SIZE, "cipso_cache_bucket_size" },
388    { NET_CIPSOV4_RBM_OPTFMT, "cipso_rbm_optfmt" },
389    { NET_CIPSOV4_RBM_STRICTVALID, "cipso_rbm_strictvalid" },
390    { NET_TCP_AVAIL_CONG_CONTROL, "tcp_available_congestion_control" },
391    { NET_TCP_ALLOWED_CONG_CONTROL, "tcp_allowed_congestion_control" },
392    { NET_TCP_MAX_SSTHRESH, "tcp_max_ssthresh" },
393    { NET_TCP_FRTO_RESPONSE, "tcp_frto_response" },
394    { 2088 /* NET_IPQ_QMAX */, "ip_queue_maxlen" },
395    {}
396};
397
398static const struct trans_ctl_table trans_net_ipx_table[] = {
399    { NET_IPX_PPROP_BROADCASTING, "ipx_pprop_broadcasting" },
400    /* NET_IPX_FORWARDING unused */
401    {}
402};
403
404static const struct trans_ctl_table trans_net_atalk_table[] = {
405    { NET_ATALK_AARP_EXPIRY_TIME, "aarp-expiry-time" },
406    { NET_ATALK_AARP_TICK_TIME, "aarp-tick-time" },
407    { NET_ATALK_AARP_RETRANSMIT_LIMIT, "aarp-retransmit-limit" },
408    { NET_ATALK_AARP_RESOLVE_TIME, "aarp-resolve-time" },
409    {},
410};
411
412static const struct trans_ctl_table trans_net_netrom_table[] = {
413    { NET_NETROM_DEFAULT_PATH_QUALITY, "default_path_quality" },
414    { NET_NETROM_OBSOLESCENCE_COUNT_INITIALISER, "obsolescence_count_initialiser" },
415    { NET_NETROM_NETWORK_TTL_INITIALISER, "network_ttl_initialiser" },
416    { NET_NETROM_TRANSPORT_TIMEOUT, "transport_timeout" },
417    { NET_NETROM_TRANSPORT_MAXIMUM_TRIES, "transport_maximum_tries" },
418    { NET_NETROM_TRANSPORT_ACKNOWLEDGE_DELAY, "transport_acknowledge_delay" },
419    { NET_NETROM_TRANSPORT_BUSY_DELAY, "transport_busy_delay" },
420    { NET_NETROM_TRANSPORT_REQUESTED_WINDOW_SIZE, "transport_requested_window_size" },
421    { NET_NETROM_TRANSPORT_NO_ACTIVITY_TIMEOUT, "transport_no_activity_timeout" },
422    { NET_NETROM_ROUTING_CONTROL, "routing_control" },
423    { NET_NETROM_LINK_FAILS_COUNT, "link_fails_count" },
424    { NET_NETROM_RESET, "reset" },
425    {}
426};
427
428static const struct trans_ctl_table trans_net_ax25_param_table[] = {
429    { NET_AX25_IP_DEFAULT_MODE, "ip_default_mode" },
430    { NET_AX25_DEFAULT_MODE, "ax25_default_mode" },
431    { NET_AX25_BACKOFF_TYPE, "backoff_type" },
432    { NET_AX25_CONNECT_MODE, "connect_mode" },
433    { NET_AX25_STANDARD_WINDOW, "standard_window_size" },
434    { NET_AX25_EXTENDED_WINDOW, "extended_window_size" },
435    { NET_AX25_T1_TIMEOUT, "t1_timeout" },
436    { NET_AX25_T2_TIMEOUT, "t2_timeout" },
437    { NET_AX25_T3_TIMEOUT, "t3_timeout" },
438    { NET_AX25_IDLE_TIMEOUT, "idle_timeout" },
439    { NET_AX25_N2, "maximum_retry_count" },
440    { NET_AX25_PACLEN, "maximum_packet_length" },
441    { NET_AX25_PROTOCOL, "protocol" },
442    { NET_AX25_DAMA_SLAVE_TIMEOUT, "dama_slave_timeout" },
443    {}
444};
445
446static const struct trans_ctl_table trans_net_ax25_table[] = {
447    { 0, NULL, trans_net_ax25_param_table },
448    {}
449};
450
451static const struct trans_ctl_table trans_net_bridge_table[] = {
452    { NET_BRIDGE_NF_CALL_ARPTABLES, "bridge-nf-call-arptables" },
453    { NET_BRIDGE_NF_CALL_IPTABLES, "bridge-nf-call-iptables" },
454    { NET_BRIDGE_NF_CALL_IP6TABLES, "bridge-nf-call-ip6tables" },
455    { NET_BRIDGE_NF_FILTER_VLAN_TAGGED, "bridge-nf-filter-vlan-tagged" },
456    { NET_BRIDGE_NF_FILTER_PPPOE_TAGGED, "bridge-nf-filter-pppoe-tagged" },
457    {}
458};
459
460static const struct trans_ctl_table trans_net_rose_table[] = {
461    { NET_ROSE_RESTART_REQUEST_TIMEOUT, "restart_request_timeout" },
462    { NET_ROSE_CALL_REQUEST_TIMEOUT, "call_request_timeout" },
463    { NET_ROSE_RESET_REQUEST_TIMEOUT, "reset_request_timeout" },
464    { NET_ROSE_CLEAR_REQUEST_TIMEOUT, "clear_request_timeout" },
465    { NET_ROSE_ACK_HOLD_BACK_TIMEOUT, "acknowledge_hold_back_timeout" },
466    { NET_ROSE_ROUTING_CONTROL, "routing_control" },
467    { NET_ROSE_LINK_FAIL_TIMEOUT, "link_fail_timeout" },
468    { NET_ROSE_MAX_VCS, "maximum_virtual_circuits" },
469    { NET_ROSE_WINDOW_SIZE, "window_size" },
470    { NET_ROSE_NO_ACTIVITY_TIMEOUT, "no_activity_timeout" },
471    {}
472};
473
474static const struct trans_ctl_table trans_net_ipv6_conf_var_table[] = {
475    { NET_IPV6_FORWARDING, "forwarding" },
476    { NET_IPV6_HOP_LIMIT, "hop_limit" },
477    { NET_IPV6_MTU, "mtu" },
478    { NET_IPV6_ACCEPT_RA, "accept_ra" },
479    { NET_IPV6_ACCEPT_REDIRECTS, "accept_redirects" },
480    { NET_IPV6_AUTOCONF, "autoconf" },
481    { NET_IPV6_DAD_TRANSMITS, "dad_transmits" },
482    { NET_IPV6_RTR_SOLICITS, "router_solicitations" },
483    { NET_IPV6_RTR_SOLICIT_INTERVAL, "router_solicitation_interval" },
484    { NET_IPV6_RTR_SOLICIT_DELAY, "router_solicitation_delay" },
485    { NET_IPV6_USE_TEMPADDR, "use_tempaddr" },
486    { NET_IPV6_TEMP_VALID_LFT, "temp_valid_lft" },
487    { NET_IPV6_TEMP_PREFERED_LFT, "temp_prefered_lft" },
488    { NET_IPV6_REGEN_MAX_RETRY, "regen_max_retry" },
489    { NET_IPV6_MAX_DESYNC_FACTOR, "max_desync_factor" },
490    { NET_IPV6_MAX_ADDRESSES, "max_addresses" },
491    { NET_IPV6_FORCE_MLD_VERSION, "force_mld_version" },
492    { NET_IPV6_ACCEPT_RA_DEFRTR, "accept_ra_defrtr" },
493    { NET_IPV6_ACCEPT_RA_PINFO, "accept_ra_pinfo" },
494    { NET_IPV6_ACCEPT_RA_RTR_PREF, "accept_ra_rtr_pref" },
495    { NET_IPV6_RTR_PROBE_INTERVAL, "router_probe_interval" },
496    { NET_IPV6_ACCEPT_RA_RT_INFO_MAX_PLEN, "accept_ra_rt_info_max_plen" },
497    { NET_IPV6_PROXY_NDP, "proxy_ndp" },
498    { NET_IPV6_ACCEPT_SOURCE_ROUTE, "accept_source_route" },
499    {}
500};
501
502static const struct trans_ctl_table trans_net_ipv6_conf_table[] = {
503    { NET_PROTO_CONF_ALL, "all", trans_net_ipv6_conf_var_table },
504    { NET_PROTO_CONF_DEFAULT, "default", trans_net_ipv6_conf_var_table },
505    { 0, NULL, trans_net_ipv6_conf_var_table },
506    {}
507};
508
509static const struct trans_ctl_table trans_net_ipv6_route_table[] = {
510    { NET_IPV6_ROUTE_FLUSH, "flush" },
511    { NET_IPV6_ROUTE_GC_THRESH, "gc_thresh" },
512    { NET_IPV6_ROUTE_MAX_SIZE, "max_size" },
513    { NET_IPV6_ROUTE_GC_MIN_INTERVAL, "gc_min_interval" },
514    { NET_IPV6_ROUTE_GC_TIMEOUT, "gc_timeout" },
515    { NET_IPV6_ROUTE_GC_INTERVAL, "gc_interval" },
516    { NET_IPV6_ROUTE_GC_ELASTICITY, "gc_elasticity" },
517    { NET_IPV6_ROUTE_MTU_EXPIRES, "mtu_expires" },
518    { NET_IPV6_ROUTE_MIN_ADVMSS, "min_adv_mss" },
519    { NET_IPV6_ROUTE_GC_MIN_INTERVAL_MS, "gc_min_interval_ms" },
520    {}
521};
522
523static const struct trans_ctl_table trans_net_ipv6_icmp_table[] = {
524    { NET_IPV6_ICMP_RATELIMIT, "ratelimit" },
525    {}
526};
527
528static const struct trans_ctl_table trans_net_ipv6_table[] = {
529    { NET_IPV6_CONF, "conf", trans_net_ipv6_conf_table },
530    { NET_IPV6_NEIGH, "neigh", trans_net_neigh_table },
531    { NET_IPV6_ROUTE, "route", trans_net_ipv6_route_table },
532    { NET_IPV6_ICMP, "icmp", trans_net_ipv6_icmp_table },
533    { NET_IPV6_BINDV6ONLY, "bindv6only" },
534    { NET_IPV6_IP6FRAG_HIGH_THRESH, "ip6frag_high_thresh" },
535    { NET_IPV6_IP6FRAG_LOW_THRESH, "ip6frag_low_thresh" },
536    { NET_IPV6_IP6FRAG_TIME, "ip6frag_time" },
537    { NET_IPV6_IP6FRAG_SECRET_INTERVAL, "ip6frag_secret_interval" },
538    { NET_IPV6_MLD_MAX_MSF, "mld_max_msf" },
539    { 2088 /* IPQ_QMAX */, "ip6_queue_maxlen" },
540    {}
541};
542
543static const struct trans_ctl_table trans_net_x25_table[] = {
544    { NET_X25_RESTART_REQUEST_TIMEOUT, "restart_request_timeout" },
545    { NET_X25_CALL_REQUEST_TIMEOUT, "call_request_timeout" },
546    { NET_X25_RESET_REQUEST_TIMEOUT, "reset_request_timeout" },
547    { NET_X25_CLEAR_REQUEST_TIMEOUT, "clear_request_timeout" },
548    { NET_X25_ACK_HOLD_BACK_TIMEOUT, "acknowledgement_hold_back_timeout" },
549    { NET_X25_FORWARD, "x25_forward" },
550    {}
551};
552
553static const struct trans_ctl_table trans_net_tr_table[] = {
554    { NET_TR_RIF_TIMEOUT, "rif_timeout" },
555    {}
556};
557
558
559static const struct trans_ctl_table trans_net_decnet_conf_vars[] = {
560    { NET_DECNET_CONF_DEV_FORWARDING, "forwarding" },
561    { NET_DECNET_CONF_DEV_PRIORITY, "priority" },
562    { NET_DECNET_CONF_DEV_T2, "t2" },
563    { NET_DECNET_CONF_DEV_T3, "t3" },
564    {}
565};
566
567static const struct trans_ctl_table trans_net_decnet_conf[] = {
568    { 0, NULL, trans_net_decnet_conf_vars },
569    {}
570};
571
572static const struct trans_ctl_table trans_net_decnet_table[] = {
573    { NET_DECNET_CONF, "conf", trans_net_decnet_conf },
574    { NET_DECNET_NODE_ADDRESS, "node_address" },
575    { NET_DECNET_NODE_NAME, "node_name" },
576    { NET_DECNET_DEFAULT_DEVICE, "default_device" },
577    { NET_DECNET_TIME_WAIT, "time_wait" },
578    { NET_DECNET_DN_COUNT, "dn_count" },
579    { NET_DECNET_DI_COUNT, "di_count" },
580    { NET_DECNET_DR_COUNT, "dr_count" },
581    { NET_DECNET_DST_GC_INTERVAL, "dst_gc_interval" },
582    { NET_DECNET_NO_FC_MAX_CWND, "no_fc_max_cwnd" },
583    { NET_DECNET_MEM, "decnet_mem" },
584    { NET_DECNET_RMEM, "decnet_rmem" },
585    { NET_DECNET_WMEM, "decnet_wmem" },
586    { NET_DECNET_DEBUG_LEVEL, "debug" },
587    {}
588};
589
590static const struct trans_ctl_table trans_net_sctp_table[] = {
591    { NET_SCTP_RTO_INITIAL, "rto_initial" },
592    { NET_SCTP_RTO_MIN, "rto_min" },
593    { NET_SCTP_RTO_MAX, "rto_max" },
594    { NET_SCTP_RTO_ALPHA, "rto_alpha_exp_divisor" },
595    { NET_SCTP_RTO_BETA, "rto_beta_exp_divisor" },
596    { NET_SCTP_VALID_COOKIE_LIFE, "valid_cookie_life" },
597    { NET_SCTP_ASSOCIATION_MAX_RETRANS, "association_max_retrans" },
598    { NET_SCTP_PATH_MAX_RETRANS, "path_max_retrans" },
599    { NET_SCTP_MAX_INIT_RETRANSMITS, "max_init_retransmits" },
600    { NET_SCTP_HB_INTERVAL, "hb_interval" },
601    { NET_SCTP_PRESERVE_ENABLE, "cookie_preserve_enable" },
602    { NET_SCTP_MAX_BURST, "max_burst" },
603    { NET_SCTP_ADDIP_ENABLE, "addip_enable" },
604    { NET_SCTP_PRSCTP_ENABLE, "prsctp_enable" },
605    { NET_SCTP_SNDBUF_POLICY, "sndbuf_policy" },
606    { NET_SCTP_SACK_TIMEOUT, "sack_timeout" },
607    { NET_SCTP_RCVBUF_POLICY, "rcvbuf_policy" },
608    {}
609};
610
611static const struct trans_ctl_table trans_net_llc_llc2_timeout_table[] = {
612    { NET_LLC2_ACK_TIMEOUT, "ack" },
613    { NET_LLC2_P_TIMEOUT, "p" },
614    { NET_LLC2_REJ_TIMEOUT, "rej" },
615    { NET_LLC2_BUSY_TIMEOUT, "busy" },
616    {}
617};
618
619static const struct trans_ctl_table trans_net_llc_station_table[] = {
620    { NET_LLC_STATION_ACK_TIMEOUT, "ack_timeout" },
621    {}
622};
623
624static const struct trans_ctl_table trans_net_llc_llc2_table[] = {
625    { NET_LLC2, "timeout", trans_net_llc_llc2_timeout_table },
626    {}
627};
628
629static const struct trans_ctl_table trans_net_llc_table[] = {
630    { NET_LLC2, "llc2", trans_net_llc_llc2_table },
631    { NET_LLC_STATION, "station", trans_net_llc_station_table },
632    {}
633};
634
635static const struct trans_ctl_table trans_net_netfilter_table[] = {
636    { NET_NF_CONNTRACK_MAX, "nf_conntrack_max" },
637    { NET_NF_CONNTRACK_TCP_TIMEOUT_SYN_SENT, "nf_conntrack_tcp_timeout_syn_sent" },
638    { NET_NF_CONNTRACK_TCP_TIMEOUT_SYN_RECV, "nf_conntrack_tcp_timeout_syn_recv" },
639    { NET_NF_CONNTRACK_TCP_TIMEOUT_ESTABLISHED, "nf_conntrack_tcp_timeout_established" },
640    { NET_NF_CONNTRACK_TCP_TIMEOUT_FIN_WAIT, "nf_conntrack_tcp_timeout_fin_wait" },
641    { NET_NF_CONNTRACK_TCP_TIMEOUT_CLOSE_WAIT, "nf_conntrack_tcp_timeout_close_wait" },
642    { NET_NF_CONNTRACK_TCP_TIMEOUT_LAST_ACK, "nf_conntrack_tcp_timeout_last_ack" },
643    { NET_NF_CONNTRACK_TCP_TIMEOUT_TIME_WAIT, "nf_conntrack_tcp_timeout_time_wait" },
644    { NET_NF_CONNTRACK_TCP_TIMEOUT_CLOSE, "nf_conntrack_tcp_timeout_close" },
645    { NET_NF_CONNTRACK_UDP_TIMEOUT, "nf_conntrack_udp_timeout" },
646    { NET_NF_CONNTRACK_UDP_TIMEOUT_STREAM, "nf_conntrack_udp_timeout_stream" },
647    { NET_NF_CONNTRACK_ICMP_TIMEOUT, "nf_conntrack_icmp_timeout" },
648    { NET_NF_CONNTRACK_GENERIC_TIMEOUT, "nf_conntrack_generic_timeout" },
649    { NET_NF_CONNTRACK_BUCKETS, "nf_conntrack_buckets" },
650    { NET_NF_CONNTRACK_LOG_INVALID, "nf_conntrack_log_invalid" },
651    { NET_NF_CONNTRACK_TCP_TIMEOUT_MAX_RETRANS, "nf_conntrack_tcp_timeout_max_retrans" },
652    { NET_NF_CONNTRACK_TCP_LOOSE, "nf_conntrack_tcp_loose" },
653    { NET_NF_CONNTRACK_TCP_BE_LIBERAL, "nf_conntrack_tcp_be_liberal" },
654    { NET_NF_CONNTRACK_TCP_MAX_RETRANS, "nf_conntrack_tcp_max_retrans" },
655    { NET_NF_CONNTRACK_SCTP_TIMEOUT_CLOSED, "nf_conntrack_sctp_timeout_closed" },
656    { NET_NF_CONNTRACK_SCTP_TIMEOUT_COOKIE_WAIT, "nf_conntrack_sctp_timeout_cookie_wait" },
657    { NET_NF_CONNTRACK_SCTP_TIMEOUT_COOKIE_ECHOED, "nf_conntrack_sctp_timeout_cookie_echoed" },
658    { NET_NF_CONNTRACK_SCTP_TIMEOUT_ESTABLISHED, "nf_conntrack_sctp_timeout_established" },
659    { NET_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_SENT, "nf_conntrack_sctp_timeout_shutdown_sent" },
660    { NET_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_RECD, "nf_conntrack_sctp_timeout_shutdown_recd" },
661    { NET_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_ACK_SENT, "nf_conntrack_sctp_timeout_shutdown_ack_sent" },
662    { NET_NF_CONNTRACK_COUNT, "nf_conntrack_count" },
663    { NET_NF_CONNTRACK_ICMPV6_TIMEOUT, "nf_conntrack_icmpv6_timeout" },
664    { NET_NF_CONNTRACK_FRAG6_TIMEOUT, "nf_conntrack_frag6_timeout" },
665    { NET_NF_CONNTRACK_FRAG6_LOW_THRESH, "nf_conntrack_frag6_low_thresh" },
666    { NET_NF_CONNTRACK_FRAG6_HIGH_THRESH, "nf_conntrack_frag6_high_thresh" },
667    { NET_NF_CONNTRACK_CHECKSUM, "nf_conntrack_checksum" },
668
669    {}
670};
671
672static const struct trans_ctl_table trans_net_dccp_table[] = {
673    { NET_DCCP_DEFAULT, "default" },
674    {}
675};
676
677static const struct trans_ctl_table trans_net_irda_table[] = {
678    { NET_IRDA_DISCOVERY, "discovery" },
679    { NET_IRDA_DEVNAME, "devname" },
680    { NET_IRDA_DEBUG, "debug" },
681    { NET_IRDA_FAST_POLL, "fast_poll_increase" },
682    { NET_IRDA_DISCOVERY_SLOTS, "discovery_slots" },
683    { NET_IRDA_DISCOVERY_TIMEOUT, "discovery_timeout" },
684    { NET_IRDA_SLOT_TIMEOUT, "slot_timeout" },
685    { NET_IRDA_MAX_BAUD_RATE, "max_baud_rate" },
686    { NET_IRDA_MIN_TX_TURN_TIME, "min_tx_turn_time" },
687    { NET_IRDA_MAX_TX_DATA_SIZE, "max_tx_data_size" },
688    { NET_IRDA_MAX_TX_WINDOW, "max_tx_window" },
689    { NET_IRDA_MAX_NOREPLY_TIME, "max_noreply_time" },
690    { NET_IRDA_WARN_NOREPLY_TIME, "warn_noreply_time" },
691    { NET_IRDA_LAP_KEEPALIVE_TIME, "lap_keepalive_time" },
692    {}
693};
694
695static const struct trans_ctl_table trans_net_table[] = {
696    { NET_CORE, "core", trans_net_core_table },
697    /* NET_ETHER not used */
698    /* NET_802 not used */
699    { NET_UNIX, "unix", trans_net_unix_table },
700    { NET_IPV4, "ipv4", trans_net_ipv4_table },
701    { NET_IPX, "ipx", trans_net_ipx_table },
702    { NET_ATALK, "appletalk", trans_net_atalk_table },
703    { NET_NETROM, "netrom", trans_net_netrom_table },
704    { NET_AX25, "ax25", trans_net_ax25_table },
705    { NET_BRIDGE, "bridge", trans_net_bridge_table },
706    { NET_ROSE, "rose", trans_net_rose_table },
707    { NET_IPV6, "ipv6", trans_net_ipv6_table },
708    { NET_X25, "x25", trans_net_x25_table },
709    { NET_TR, "token-ring", trans_net_tr_table },
710    { NET_DECNET, "decnet", trans_net_decnet_table },
711    /* NET_ECONET not used */
712    { NET_SCTP, "sctp", trans_net_sctp_table },
713    { NET_LLC, "llc", trans_net_llc_table },
714    { NET_NETFILTER, "netfilter", trans_net_netfilter_table },
715    { NET_DCCP, "dccp", trans_net_dccp_table },
716    { NET_IRDA, "irda", trans_net_irda_table },
717    { 2089, "nf_conntrack_max" },
718    {}
719};
720
721static const struct trans_ctl_table trans_fs_quota_table[] = {
722    { FS_DQ_LOOKUPS, "lookups" },
723    { FS_DQ_DROPS, "drops" },
724    { FS_DQ_READS, "reads" },
725    { FS_DQ_WRITES, "writes" },
726    { FS_DQ_CACHE_HITS, "cache_hits" },
727    { FS_DQ_ALLOCATED, "allocated_dquots" },
728    { FS_DQ_FREE, "free_dquots" },
729    { FS_DQ_SYNCS, "syncs" },
730    { FS_DQ_WARNINGS, "warnings" },
731    {}
732};
733
734static const struct trans_ctl_table trans_fs_xfs_table[] = {
735    { XFS_SGID_INHERIT, "irix_sgid_inherit" },
736    { XFS_SYMLINK_MODE, "irix_symlink_mode" },
737    { XFS_PANIC_MASK, "panic_mask" },
738
739    { XFS_ERRLEVEL, "error_level" },
740    { XFS_SYNCD_TIMER, "xfssyncd_centisecs" },
741    { XFS_INHERIT_SYNC, "inherit_sync" },
742    { XFS_INHERIT_NODUMP, "inherit_nodump" },
743    { XFS_INHERIT_NOATIME, "inherit_noatime" },
744    { XFS_BUF_TIMER, "xfsbufd_centisecs" },
745    { XFS_BUF_AGE, "age_buffer_centisecs" },
746    { XFS_INHERIT_NOSYM, "inherit_nosymlinks" },
747    { XFS_ROTORSTEP, "rotorstep" },
748    { XFS_INHERIT_NODFRG, "inherit_nodefrag" },
749    { XFS_FILESTREAM_TIMER, "filestream_centisecs" },
750    { XFS_STATS_CLEAR, "stats_clear" },
751    {}
752};
753
754static const struct trans_ctl_table trans_fs_ocfs2_nm_table[] = {
755    { 1, "hb_ctl_path" },
756    {}
757};
758
759static const struct trans_ctl_table trans_fs_ocfs2_table[] = {
760    { 1, "nm", trans_fs_ocfs2_nm_table },
761    {}
762};
763
764static const struct trans_ctl_table trans_inotify_table[] = {
765    { INOTIFY_MAX_USER_INSTANCES, "max_user_instances" },
766    { INOTIFY_MAX_USER_WATCHES, "max_user_watches" },
767    { INOTIFY_MAX_QUEUED_EVENTS, "max_queued_events" },
768    {}
769};
770
771static const struct trans_ctl_table trans_fs_table[] = {
772    { FS_NRINODE, "inode-nr" },
773    { FS_STATINODE, "inode-state" },
774    /* FS_MAXINODE unused */
775    /* FS_NRDQUOT unused */
776    /* FS_MAXDQUOT unused */
777    { FS_NRFILE, "file-nr" },
778    { FS_MAXFILE, "file-max" },
779    { FS_DENTRY, "dentry-state" },
780    /* FS_NRSUPER unused */
781    /* FS_MAXUPSER unused */
782    { FS_OVERFLOWUID, "overflowuid" },
783    { FS_OVERFLOWGID, "overflowgid" },
784    { FS_LEASES, "leases-enable" },
785    { FS_DIR_NOTIFY, "dir-notify-enable" },
786    { FS_LEASE_TIME, "lease-break-time" },
787    { FS_DQSTATS, "quota", trans_fs_quota_table },
788    { FS_XFS, "xfs", trans_fs_xfs_table },
789    { FS_AIO_NR, "aio-nr" },
790    { FS_AIO_MAX_NR, "aio-max-nr" },
791    { FS_INOTIFY, "inotify", trans_inotify_table },
792    { FS_OCFS2, "ocfs2", trans_fs_ocfs2_table },
793    { KERN_SETUID_DUMPABLE, "suid_dumpable" },
794    {}
795};
796
797static const struct trans_ctl_table trans_debug_table[] = {
798    {}
799};
800
801static const struct trans_ctl_table trans_cdrom_table[] = {
802    { DEV_CDROM_INFO, "info" },
803    { DEV_CDROM_AUTOCLOSE, "autoclose" },
804    { DEV_CDROM_AUTOEJECT, "autoeject" },
805    { DEV_CDROM_DEBUG, "debug" },
806    { DEV_CDROM_LOCK, "lock" },
807    { DEV_CDROM_CHECK_MEDIA, "check_media" },
808    {}
809};
810
811static const struct trans_ctl_table trans_ipmi_table[] = {
812    { DEV_IPMI_POWEROFF_POWERCYCLE, "poweroff_powercycle" },
813    {}
814};
815
816static const struct trans_ctl_table trans_mac_hid_files[] = {
817    /* DEV_MAC_HID_KEYBOARD_SENDS_LINUX_KEYCODES unused */
818    /* DEV_MAC_HID_KEYBOARD_LOCK_KEYCODES unused */
819    { DEV_MAC_HID_MOUSE_BUTTON_EMULATION, "mouse_button_emulation" },
820    { DEV_MAC_HID_MOUSE_BUTTON2_KEYCODE, "mouse_button2_keycode" },
821    { DEV_MAC_HID_MOUSE_BUTTON3_KEYCODE, "mouse_button3_keycode" },
822    /* DEV_MAC_HID_ADB_MOUSE_SENDS_KEYCODES unused */
823    {}
824};
825
826static const struct trans_ctl_table trans_raid_table[] = {
827    { DEV_RAID_SPEED_LIMIT_MIN, "speed_limit_min" },
828    { DEV_RAID_SPEED_LIMIT_MAX, "speed_limit_max" },
829    {}
830};
831
832static const struct trans_ctl_table trans_scsi_table[] = {
833    { DEV_SCSI_LOGGING_LEVEL, "logging_level" },
834    {}
835};
836
837static const struct trans_ctl_table trans_parport_default_table[] = {
838    { DEV_PARPORT_DEFAULT_TIMESLICE, "timeslice" },
839    { DEV_PARPORT_DEFAULT_SPINTIME, "spintime" },
840    {}
841};
842
843static const struct trans_ctl_table trans_parport_device_table[] = {
844    { DEV_PARPORT_DEVICE_TIMESLICE, "timeslice" },
845    {}
846};
847
848static const struct trans_ctl_table trans_parport_devices_table[] = {
849    { DEV_PARPORT_DEVICES_ACTIVE, "active" },
850    { 0, NULL, trans_parport_device_table },
851    {}
852};
853
854static const struct trans_ctl_table trans_parport_parport_table[] = {
855    { DEV_PARPORT_SPINTIME, "spintime" },
856    { DEV_PARPORT_BASE_ADDR, "base-addr" },
857    { DEV_PARPORT_IRQ, "irq" },
858    { DEV_PARPORT_DMA, "dma" },
859    { DEV_PARPORT_MODES, "modes" },
860    { DEV_PARPORT_DEVICES, "devices", trans_parport_devices_table },
861    { DEV_PARPORT_AUTOPROBE, "autoprobe" },
862    { DEV_PARPORT_AUTOPROBE + 1, "autoprobe0" },
863    { DEV_PARPORT_AUTOPROBE + 2, "autoprobe1" },
864    { DEV_PARPORT_AUTOPROBE + 3, "autoprobe2" },
865    { DEV_PARPORT_AUTOPROBE + 4, "autoprobe3" },
866    {}
867};
868static const struct trans_ctl_table trans_parport_table[] = {
869    { DEV_PARPORT_DEFAULT, "default", trans_parport_default_table },
870    { 0, NULL, trans_parport_parport_table },
871    {}
872};
873
874static const struct trans_ctl_table trans_dev_table[] = {
875    { DEV_CDROM, "cdrom", trans_cdrom_table },
876    /* DEV_HWMON unused */
877    { DEV_PARPORT, "parport", trans_parport_table },
878    { DEV_RAID, "raid", trans_raid_table },
879    { DEV_MAC_HID, "mac_hid", trans_mac_hid_files },
880    { DEV_SCSI, "scsi", trans_scsi_table },
881    { DEV_IPMI, "ipmi", trans_ipmi_table },
882    {}
883};
884
885static const struct trans_ctl_table trans_bus_isa_table[] = {
886    { BUS_ISA_MEM_BASE, "membase" },
887    { BUS_ISA_PORT_BASE, "portbase" },
888    { BUS_ISA_PORT_SHIFT, "portshift" },
889    {}
890};
891
892static const struct trans_ctl_table trans_bus_table[] = {
893    { CTL_BUS_ISA, "isa", trans_bus_isa_table },
894    {}
895};
896
897static const struct trans_ctl_table trans_arlan_conf_table0[] = {
898    { 1, "spreadingCode" },
899    { 2, "channelNumber" },
900    { 3, "scramblingDisable" },
901    { 4, "txAttenuation" },
902    { 5, "systemId" },
903    { 6, "maxDatagramSize" },
904    { 7, "maxFrameSize" },
905    { 8, "maxRetries" },
906    { 9, "receiveMode" },
907    { 10, "priority" },
908    { 11, "rootOrRepeater" },
909    { 12, "SID" },
910    { 13, "registrationMode" },
911    { 14, "registrationFill" },
912    { 15, "localTalkAddress" },
913    { 16, "codeFormat" },
914    { 17, "numChannels" },
915    { 18, "channel1" },
916    { 19, "channel2" },
917    { 20, "channel3" },
918    { 21, "channel4" },
919    { 22, "txClear" },
920    { 23, "txRetries" },
921    { 24, "txRouting" },
922    { 25, "txScrambled" },
923    { 26, "rxParameter" },
924    { 27, "txTimeoutMs" },
925    { 28, "waitCardTimeout" },
926    { 29, "channelSet" },
927    { 30, "name" },
928    { 31, "waitTime" },
929    { 32, "lParameter" },
930    { 33, "_15" },
931    { 34, "headerSize" },
932    { 36, "tx_delay_ms" },
933    { 37, "retries" },
934    { 38, "ReTransmitPacketMaxSize" },
935    { 39, "waitReTransmitPacketMaxSize" },
936    { 40, "fastReTransCount" },
937    { 41, "driverRetransmissions" },
938    { 42, "txAckTimeoutMs" },
939    { 43, "registrationInterrupts" },
940    { 44, "hardwareType" },
941    { 45, "radioType" },
942    { 46, "writeEEPROM" },
943    { 47, "writeRadioType" },
944    { 48, "entry_exit_debug" },
945    { 49, "debug" },
946    { 50, "in_speed" },
947    { 51, "out_speed" },
948    { 52, "in_speed10" },
949    { 53, "out_speed10" },
950    { 54, "in_speed_max" },
951    { 55, "out_speed_max" },
952    { 56, "measure_rate" },
953    { 57, "pre_Command_Wait" },
954    { 58, "rx_tweak1" },
955    { 59, "rx_tweak2" },
956    { 60, "tx_queue_len" },
957
958    { 150, "arlan0-txRing" },
959    { 151, "arlan0-rxRing" },
960    { 152, "arlan0-18" },
961    { 153, "arlan0-ring" },
962    { 154, "arlan0-shm-cpy" },
963    { 155, "config0" },
964    { 156, "reset0" },
965    {}
966};
967
968static const struct trans_ctl_table trans_arlan_conf_table1[] = {
969    { 1, "spreadingCode" },
970    { 2, "channelNumber" },
971    { 3, "scramblingDisable" },
972    { 4, "txAttenuation" },
973    { 5, "systemId" },
974    { 6, "maxDatagramSize" },
975    { 7, "maxFrameSize" },
976    { 8, "maxRetries" },
977    { 9, "receiveMode" },
978    { 10, "priority" },
979    { 11, "rootOrRepeater" },
980    { 12, "SID" },
981    { 13, "registrationMode" },
982    { 14, "registrationFill" },
983    { 15, "localTalkAddress" },
984    { 16, "codeFormat" },
985    { 17, "numChannels" },
986    { 18, "channel1" },
987    { 19, "channel2" },
988    { 20, "channel3" },
989    { 21, "channel4" },
990    { 22, "txClear" },
991    { 23, "txRetries" },
992    { 24, "txRouting" },
993    { 25, "txScrambled" },
994    { 26, "rxParameter" },
995    { 27, "txTimeoutMs" },
996    { 28, "waitCardTimeout" },
997    { 29, "channelSet" },
998    { 30, "name" },
999    { 31, "waitTime" },
1000    { 32, "lParameter" },
1001    { 33, "_15" },
1002    { 34, "headerSize" },
1003    { 36, "tx_delay_ms" },
1004    { 37, "retries" },
1005    { 38, "ReTransmitPacketMaxSize" },
1006    { 39, "waitReTransmitPacketMaxSize" },
1007    { 40, "fastReTransCount" },
1008    { 41, "driverRetransmissions" },
1009    { 42, "txAckTimeoutMs" },
1010    { 43, "registrationInterrupts" },
1011    { 44, "hardwareType" },
1012    { 45, "radioType" },
1013    { 46, "writeEEPROM" },
1014    { 47, "writeRadioType" },
1015    { 48, "entry_exit_debug" },
1016    { 49, "debug" },
1017    { 50, "in_speed" },
1018    { 51, "out_speed" },
1019    { 52, "in_speed10" },
1020    { 53, "out_speed10" },
1021    { 54, "in_speed_max" },
1022    { 55, "out_speed_max" },
1023    { 56, "measure_rate" },
1024    { 57, "pre_Command_Wait" },
1025    { 58, "rx_tweak1" },
1026    { 59, "rx_tweak2" },
1027    { 60, "tx_queue_len" },
1028
1029    { 150, "arlan1-txRing" },
1030    { 151, "arlan1-rxRing" },
1031    { 152, "arlan1-18" },
1032    { 153, "arlan1-ring" },
1033    { 154, "arlan1-shm-cpy" },
1034    { 155, "config1" },
1035    { 156, "reset1" },
1036    {}
1037};
1038
1039static const struct trans_ctl_table trans_arlan_conf_table2[] = {
1040    { 1, "spreadingCode" },
1041    { 2, "channelNumber" },
1042    { 3, "scramblingDisable" },
1043    { 4, "txAttenuation" },
1044    { 5, "systemId" },
1045    { 6, "maxDatagramSize" },
1046    { 7, "maxFrameSize" },
1047    { 8, "maxRetries" },
1048    { 9, "receiveMode" },
1049    { 10, "priority" },
1050    { 11, "rootOrRepeater" },
1051    { 12, "SID" },
1052    { 13, "registrationMode" },
1053    { 14, "registrationFill" },
1054    { 15, "localTalkAddress" },
1055    { 16, "codeFormat" },
1056    { 17, "numChannels" },
1057    { 18, "channel1" },
1058    { 19, "channel2" },
1059    { 20, "channel3" },
1060    { 21, "channel4" },
1061    { 22, "txClear" },
1062    { 23, "txRetries" },
1063    { 24, "txRouting" },
1064    { 25, "txScrambled" },
1065    { 26, "rxParameter" },
1066    { 27, "txTimeoutMs" },
1067    { 28, "waitCardTimeout" },
1068    { 29, "channelSet" },
1069    { 30, "name" },
1070    { 31, "waitTime" },
1071    { 32, "lParameter" },
1072    { 33, "_15" },
1073    { 34, "headerSize" },
1074    { 36, "tx_delay_ms" },
1075    { 37, "retries" },
1076    { 38, "ReTransmitPacketMaxSize" },
1077    { 39, "waitReTransmitPacketMaxSize" },
1078    { 40, "fastReTransCount" },
1079    { 41, "driverRetransmissions" },
1080    { 42, "txAckTimeoutMs" },
1081    { 43, "registrationInterrupts" },
1082    { 44, "hardwareType" },
1083    { 45, "radioType" },
1084    { 46, "writeEEPROM" },
1085    { 47, "writeRadioType" },
1086    { 48, "entry_exit_debug" },
1087    { 49, "debug" },
1088    { 50, "in_speed" },
1089    { 51, "out_speed" },
1090    { 52, "in_speed10" },
1091    { 53, "out_speed10" },
1092    { 54, "in_speed_max" },
1093    { 55, "out_speed_max" },
1094    { 56, "measure_rate" },
1095    { 57, "pre_Command_Wait" },
1096    { 58, "rx_tweak1" },
1097    { 59, "rx_tweak2" },
1098    { 60, "tx_queue_len" },
1099
1100    { 150, "arlan2-txRing" },
1101    { 151, "arlan2-rxRing" },
1102    { 152, "arlan2-18" },
1103    { 153, "arlan2-ring" },
1104    { 154, "arlan2-shm-cpy" },
1105    { 155, "config2" },
1106    { 156, "reset2" },
1107    {}
1108};
1109
1110static const struct trans_ctl_table trans_arlan_conf_table3[] = {
1111    { 1, "spreadingCode" },
1112    { 2, "channelNumber" },
1113    { 3, "scramblingDisable" },
1114    { 4, "txAttenuation" },
1115    { 5, "systemId" },
1116    { 6, "maxDatagramSize" },
1117    { 7, "maxFrameSize" },
1118    { 8, "maxRetries" },
1119    { 9, "receiveMode" },
1120    { 10, "priority" },
1121    { 11, "rootOrRepeater" },
1122    { 12, "SID" },
1123    { 13, "registrationMode" },
1124    { 14, "registrationFill" },
1125    { 15, "localTalkAddress" },
1126    { 16, "codeFormat" },
1127    { 17, "numChannels" },
1128    { 18, "channel1" },
1129    { 19, "channel2" },
1130    { 20, "channel3" },
1131    { 21, "channel4" },
1132    { 22, "txClear" },
1133    { 23, "txRetries" },
1134    { 24, "txRouting" },
1135    { 25, "txScrambled" },
1136    { 26, "rxParameter" },
1137    { 27, "txTimeoutMs" },
1138    { 28, "waitCardTimeout" },
1139    { 29, "channelSet" },
1140    { 30, "name" },
1141    { 31, "waitTime" },
1142    { 32, "lParameter" },
1143    { 33, "_15" },
1144    { 34, "headerSize" },
1145    { 36, "tx_delay_ms" },
1146    { 37, "retries" },
1147    { 38, "ReTransmitPacketMaxSize" },
1148    { 39, "waitReTransmitPacketMaxSize" },
1149    { 40, "fastReTransCount" },
1150    { 41, "driverRetransmissions" },
1151    { 42, "txAckTimeoutMs" },
1152    { 43, "registrationInterrupts" },
1153    { 44, "hardwareType" },
1154    { 45, "radioType" },
1155    { 46, "writeEEPROM" },
1156    { 47, "writeRadioType" },
1157    { 48, "entry_exit_debug" },
1158    { 49, "debug" },
1159    { 50, "in_speed" },
1160    { 51, "out_speed" },
1161    { 52, "in_speed10" },
1162    { 53, "out_speed10" },
1163    { 54, "in_speed_max" },
1164    { 55, "out_speed_max" },
1165    { 56, "measure_rate" },
1166    { 57, "pre_Command_Wait" },
1167    { 58, "rx_tweak1" },
1168    { 59, "rx_tweak2" },
1169    { 60, "tx_queue_len" },
1170
1171    { 150, "arlan3-txRing" },
1172    { 151, "arlan3-rxRing" },
1173    { 152, "arlan3-18" },
1174    { 153, "arlan3-ring" },
1175    { 154, "arlan3-shm-cpy" },
1176    { 155, "config3" },
1177    { 156, "reset3" },
1178    {}
1179};
1180
1181static const struct trans_ctl_table trans_arlan_table[] = {
1182    { 1, "arlan0", trans_arlan_conf_table0 },
1183    { 2, "arlan1", trans_arlan_conf_table1 },
1184    { 3, "arlan2", trans_arlan_conf_table2 },
1185    { 4, "arlan3", trans_arlan_conf_table3 },
1186    {}
1187};
1188
1189static const struct trans_ctl_table trans_s390dbf_table[] = {
1190    { 5678 /* CTL_S390DBF_STOPPABLE */, "debug_stoppable" },
1191    { 5679 /* CTL_S390DBF_ACTIVE */, "debug_active" },
1192    {}
1193};
1194
1195static const struct trans_ctl_table trans_sunrpc_table[] = {
1196    { CTL_RPCDEBUG, "rpc_debug" },
1197    { CTL_NFSDEBUG, "nfs_debug" },
1198    { CTL_NFSDDEBUG, "nfsd_debug" },
1199    { CTL_NLMDEBUG, "nlm_debug" },
1200    { CTL_SLOTTABLE_UDP, "udp_slot_table_entries" },
1201    { CTL_SLOTTABLE_TCP, "tcp_slot_table_entries" },
1202    { CTL_MIN_RESVPORT, "min_resvport" },
1203    { CTL_MAX_RESVPORT, "max_resvport" },
1204    {}
1205};
1206
1207static const struct trans_ctl_table trans_pm_table[] = {
1208    { 1 /* CTL_PM_SUSPEND */, "suspend" },
1209    { 2 /* CTL_PM_CMODE */, "cmode" },
1210    { 3 /* CTL_PM_P0 */, "p0" },
1211    { 4 /* CTL_PM_CM */, "cm" },
1212    {}
1213};
1214
1215static const struct trans_ctl_table trans_frv_table[] = {
1216    { 1, "cache-mode" },
1217    { 2, "pin-cxnr" },
1218    {}
1219};
1220
1221static const struct trans_ctl_table trans_root_table[] = {
1222    { CTL_KERN, "kernel", trans_kern_table },
1223    { CTL_VM, "vm", trans_vm_table },
1224    { CTL_NET, "net", trans_net_table },
1225    /* CTL_PROC not used */
1226    { CTL_FS, "fs", trans_fs_table },
1227    { CTL_DEBUG, "debug", trans_debug_table },
1228    { CTL_DEV, "dev", trans_dev_table },
1229    { CTL_BUS, "bus", trans_bus_table },
1230    { CTL_ABI, "abi" },
1231    /* CTL_CPU not used */
1232    { CTL_ARLAN, "arlan", trans_arlan_table },
1233    { CTL_S390DBF, "s390dbf", trans_s390dbf_table },
1234    { CTL_SUNRPC, "sunrpc", trans_sunrpc_table },
1235    { CTL_PM, "pm", trans_pm_table },
1236    { CTL_FRV, "frv", trans_frv_table },
1237    {}
1238};
1239
1240
1241
1242
1243static int sysctl_depth(struct ctl_table *table)
1244{
1245    struct ctl_table *tmp;
1246    int depth;
1247
1248    depth = 0;
1249    for (tmp = table; tmp->parent; tmp = tmp->parent)
1250        depth++;
1251
1252    return depth;
1253}
1254
1255static struct ctl_table *sysctl_parent(struct ctl_table *table, int n)
1256{
1257    int i;
1258
1259    for (i = 0; table && i < n; i++)
1260        table = table->parent;
1261
1262    return table;
1263}
1264
1265static const struct trans_ctl_table *sysctl_binary_lookup(struct ctl_table *table)
1266{
1267    struct ctl_table *test;
1268    const struct trans_ctl_table *ref;
1269    int cur_depth;
1270
1271    cur_depth = sysctl_depth(table);
1272
1273    ref = trans_root_table;
1274repeat:
1275    test = sysctl_parent(table, cur_depth);
1276    for (; ref->ctl_name || ref->procname || ref->child; ref++) {
1277        int match = 0;
1278
1279        if (cur_depth && !ref->child)
1280            continue;
1281
1282        if (test->procname && ref->procname &&
1283            (strcmp(test->procname, ref->procname) == 0))
1284            match++;
1285
1286        if (test->ctl_name && ref->ctl_name &&
1287            (test->ctl_name == ref->ctl_name))
1288            match++;
1289
1290        if (!ref->ctl_name && !ref->procname)
1291            match++;
1292
1293        if (match) {
1294            if (cur_depth != 0) {
1295                cur_depth--;
1296                ref = ref->child;
1297                goto repeat;
1298            }
1299            goto out;
1300        }
1301    }
1302    ref = NULL;
1303out:
1304    return ref;
1305}
1306
1307static void sysctl_print_path(struct ctl_table *table)
1308{
1309    struct ctl_table *tmp;
1310    int depth, i;
1311    depth = sysctl_depth(table);
1312    if (table->procname) {
1313        for (i = depth; i >= 0; i--) {
1314            tmp = sysctl_parent(table, i);
1315            printk("/%s", tmp->procname?tmp->procname:"");
1316        }
1317    }
1318    printk(" ");
1319    if (table->ctl_name) {
1320        for (i = depth; i >= 0; i--) {
1321            tmp = sysctl_parent(table, i);
1322            printk(".%d", tmp->ctl_name);
1323        }
1324    }
1325}
1326
1327static void sysctl_repair_table(struct ctl_table *table)
1328{
1329    /* Don't complain about the classic default
1330     * sysctl strategy routine. Maybe later we
1331     * can get the tables fixed and complain about
1332     * this.
1333     */
1334    if (table->ctl_name && table->procname &&
1335        (table->proc_handler == proc_dointvec) &&
1336        (!table->strategy)) {
1337        table->strategy = sysctl_data;
1338    }
1339}
1340
1341static struct ctl_table *sysctl_check_lookup(struct nsproxy *namespaces,
1342                        struct ctl_table *table)
1343{
1344    struct ctl_table_header *head;
1345    struct ctl_table *ref, *test;
1346    int depth, cur_depth;
1347
1348    depth = sysctl_depth(table);
1349
1350    for (head = __sysctl_head_next(namespaces, NULL); head;
1351         head = __sysctl_head_next(namespaces, head)) {
1352        cur_depth = depth;
1353        ref = head->ctl_table;
1354repeat:
1355        test = sysctl_parent(table, cur_depth);
1356        for (; ref->ctl_name || ref->procname; ref++) {
1357            int match = 0;
1358            if (cur_depth && !ref->child)
1359                continue;
1360
1361            if (test->procname && ref->procname &&
1362                (strcmp(test->procname, ref->procname) == 0))
1363                    match++;
1364
1365            if (test->ctl_name && ref->ctl_name &&
1366                (test->ctl_name == ref->ctl_name))
1367                match++;
1368
1369            if (match) {
1370                if (cur_depth != 0) {
1371                    cur_depth--;
1372                    ref = ref->child;
1373                    goto repeat;
1374                }
1375                goto out;
1376            }
1377        }
1378    }
1379    ref = NULL;
1380out:
1381    sysctl_head_finish(head);
1382    return ref;
1383}
1384
1385static void set_fail(const char **fail, struct ctl_table *table, const char *str)
1386{
1387    if (*fail) {
1388        printk(KERN_ERR "sysctl table check failed: ");
1389        sysctl_print_path(table);
1390        printk(" %s\n", *fail);
1391        dump_stack();
1392    }
1393    *fail = str;
1394}
1395
1396static int sysctl_check_dir(struct nsproxy *namespaces,
1397                struct ctl_table *table)
1398{
1399    struct ctl_table *ref;
1400    int error;
1401
1402    error = 0;
1403    ref = sysctl_check_lookup(namespaces, table);
1404    if (ref) {
1405        int match = 0;
1406        if ((!table->procname && !ref->procname) ||
1407            (table->procname && ref->procname &&
1408             (strcmp(table->procname, ref->procname) == 0)))
1409            match++;
1410
1411        if ((!table->ctl_name && !ref->ctl_name) ||
1412            (table->ctl_name && ref->ctl_name &&
1413             (table->ctl_name == ref->ctl_name)))
1414            match++;
1415
1416        if (match != 2) {
1417            printk(KERN_ERR "%s: failed: ", __func__);
1418            sysctl_print_path(table);
1419            printk(" ref: ");
1420            sysctl_print_path(ref);
1421            printk("\n");
1422            error = -EINVAL;
1423        }
1424    }
1425    return error;
1426}
1427
1428static void sysctl_check_leaf(struct nsproxy *namespaces,
1429                struct ctl_table *table, const char **fail)
1430{
1431    struct ctl_table *ref;
1432
1433    ref = sysctl_check_lookup(namespaces, table);
1434    if (ref && (ref != table))
1435        set_fail(fail, table, "Sysctl already exists");
1436}
1437
1438static void sysctl_check_bin_path(struct ctl_table *table, const char **fail)
1439{
1440    const struct trans_ctl_table *ref;
1441
1442    ref = sysctl_binary_lookup(table);
1443    if (table->ctl_name && !ref)
1444        set_fail(fail, table, "Unknown sysctl binary path");
1445    if (ref) {
1446        if (ref->procname &&
1447            (!table->procname ||
1448             (strcmp(table->procname, ref->procname) != 0)))
1449            set_fail(fail, table, "procname does not match binary path procname");
1450
1451        if (ref->ctl_name && table->ctl_name &&
1452            (table->ctl_name != ref->ctl_name))
1453            set_fail(fail, table, "ctl_name does not match binary path ctl_name");
1454    }
1455}
1456
1457int sysctl_check_table(struct nsproxy *namespaces, struct ctl_table *table)
1458{
1459    int error = 0;
1460    for (; table->ctl_name || table->procname; table++) {
1461        const char *fail = NULL;
1462
1463        sysctl_repair_table(table);
1464        if (table->parent) {
1465            if (table->procname && !table->parent->procname)
1466                set_fail(&fail, table, "Parent without procname");
1467            if (table->ctl_name && !table->parent->ctl_name)
1468                set_fail(&fail, table, "Parent without ctl_name");
1469        }
1470        if (!table->procname)
1471            set_fail(&fail, table, "No procname");
1472        if (table->child) {
1473            if (table->data)
1474                set_fail(&fail, table, "Directory with data?");
1475            if (table->maxlen)
1476                set_fail(&fail, table, "Directory with maxlen?");
1477            if ((table->mode & (S_IRUGO|S_IXUGO)) != table->mode)
1478                set_fail(&fail, table, "Writable sysctl directory");
1479            if (table->proc_handler)
1480                set_fail(&fail, table, "Directory with proc_handler");
1481            if (table->strategy)
1482                set_fail(&fail, table, "Directory with strategy");
1483            if (table->extra1)
1484                set_fail(&fail, table, "Directory with extra1");
1485            if (table->extra2)
1486                set_fail(&fail, table, "Directory with extra2");
1487            if (sysctl_check_dir(namespaces, table))
1488                set_fail(&fail, table, "Inconsistent directory names");
1489        } else {
1490            if ((table->strategy == sysctl_data) ||
1491                (table->strategy == sysctl_string) ||
1492                (table->strategy == sysctl_intvec) ||
1493                (table->strategy == sysctl_jiffies) ||
1494                (table->strategy == sysctl_ms_jiffies) ||
1495                (table->proc_handler == proc_dostring) ||
1496                (table->proc_handler == proc_dointvec) ||
1497                (table->proc_handler == proc_dointvec_minmax) ||
1498                (table->proc_handler == proc_dointvec_jiffies) ||
1499                (table->proc_handler == proc_dointvec_userhz_jiffies) ||
1500                (table->proc_handler == proc_dointvec_ms_jiffies) ||
1501                (table->proc_handler == proc_doulongvec_minmax) ||
1502                (table->proc_handler == proc_doulongvec_ms_jiffies_minmax)) {
1503                if (!table->data)
1504                    set_fail(&fail, table, "No data");
1505                if (!table->maxlen)
1506                    set_fail(&fail, table, "No maxlen");
1507            }
1508            if ((table->proc_handler == proc_doulongvec_minmax) ||
1509                (table->proc_handler == proc_doulongvec_ms_jiffies_minmax)) {
1510                if (table->maxlen > sizeof (unsigned long)) {
1511                    if (!table->extra1)
1512                        set_fail(&fail, table, "No min");
1513                    if (!table->extra2)
1514                        set_fail(&fail, table, "No max");
1515                }
1516            }
1517#ifdef CONFIG_SYSCTL_SYSCALL
1518            if (table->ctl_name && !table->strategy)
1519                set_fail(&fail, table, "Missing strategy");
1520#endif
1521#if 0
1522            if (!table->ctl_name && table->strategy)
1523                set_fail(&fail, table, "Strategy without ctl_name");
1524#endif
1525#ifdef CONFIG_PROC_SYSCTL
1526            if (table->procname && !table->proc_handler)
1527                set_fail(&fail, table, "No proc_handler");
1528#endif
1529#if 0
1530            if (!table->procname && table->proc_handler)
1531                set_fail(&fail, table, "proc_handler without procname");
1532#endif
1533            sysctl_check_leaf(namespaces, table, &fail);
1534        }
1535        sysctl_check_bin_path(table, &fail);
1536        if (table->mode > 0777)
1537            set_fail(&fail, table, "bogus .mode");
1538        if (fail) {
1539            set_fail(&fail, table, NULL);
1540            error = -EINVAL;
1541        }
1542        if (table->child)
1543            error |= sysctl_check_table(namespaces, table->child);
1544    }
1545    return error;
1546}
1547

Archive Download this file



interactive