Back to home page

LXR

 
 

    


0001 #include <linux/stat.h>
0002 #include <linux/sysctl.h>
0003 #include "../fs/xfs/xfs_sysctl.h"
0004 #include <linux/sunrpc/debug.h>
0005 #include <linux/string.h>
0006 #include <linux/syscalls.h>
0007 #include <linux/namei.h>
0008 #include <linux/mount.h>
0009 #include <linux/fs.h>
0010 #include <linux/nsproxy.h>
0011 #include <linux/pid_namespace.h>
0012 #include <linux/file.h>
0013 #include <linux/ctype.h>
0014 #include <linux/netdevice.h>
0015 #include <linux/kernel.h>
0016 #include <linux/uuid.h>
0017 #include <linux/slab.h>
0018 #include <linux/compat.h>
0019 
0020 #ifdef CONFIG_SYSCTL_SYSCALL
0021 
0022 struct bin_table;
0023 typedef ssize_t bin_convert_t(struct file *file,
0024     void __user *oldval, size_t oldlen, void __user *newval, size_t newlen);
0025 
0026 static bin_convert_t bin_dir;
0027 static bin_convert_t bin_string;
0028 static bin_convert_t bin_intvec;
0029 static bin_convert_t bin_ulongvec;
0030 static bin_convert_t bin_uuid;
0031 static bin_convert_t bin_dn_node_address;
0032 
0033 #define CTL_DIR   bin_dir
0034 #define CTL_STR   bin_string
0035 #define CTL_INT   bin_intvec
0036 #define CTL_ULONG bin_ulongvec
0037 #define CTL_UUID  bin_uuid
0038 #define CTL_DNADR bin_dn_node_address
0039 
0040 #define BUFSZ 256
0041 
0042 struct bin_table {
0043     bin_convert_t       *convert;
0044     int         ctl_name;
0045     const char      *procname;
0046     const struct bin_table  *child;
0047 };
0048 
0049 static const struct bin_table bin_random_table[] = {
0050     { CTL_INT,  RANDOM_POOLSIZE,    "poolsize" },
0051     { CTL_INT,  RANDOM_ENTROPY_COUNT,   "entropy_avail" },
0052     { CTL_INT,  RANDOM_READ_THRESH, "read_wakeup_threshold" },
0053     { CTL_INT,  RANDOM_WRITE_THRESH,    "write_wakeup_threshold" },
0054     { CTL_UUID, RANDOM_BOOT_ID,     "boot_id" },
0055     { CTL_UUID, RANDOM_UUID,        "uuid" },
0056     {}
0057 };
0058 
0059 static const struct bin_table bin_pty_table[] = {
0060     { CTL_INT,  PTY_MAX,    "max" },
0061     { CTL_INT,  PTY_NR,     "nr" },
0062     {}
0063 };
0064 
0065 static const struct bin_table bin_kern_table[] = {
0066     { CTL_STR,  KERN_OSTYPE,            "ostype" },
0067     { CTL_STR,  KERN_OSRELEASE,         "osrelease" },
0068     /* KERN_OSREV not used */
0069     { CTL_STR,  KERN_VERSION,           "version" },
0070     /* KERN_SECUREMASK not used */
0071     /* KERN_PROF not used */
0072     { CTL_STR,  KERN_NODENAME,          "hostname" },
0073     { CTL_STR,  KERN_DOMAINNAME,        "domainname" },
0074 
0075     { CTL_INT,  KERN_PANIC,         "panic" },
0076     { CTL_INT,  KERN_REALROOTDEV,       "real-root-dev" },
0077 
0078     { CTL_STR,  KERN_SPARC_REBOOT,      "reboot-cmd" },
0079     { CTL_INT,  KERN_CTLALTDEL,         "ctrl-alt-del" },
0080     { CTL_INT,  KERN_PRINTK,            "printk" },
0081 
0082     /* KERN_NAMETRANS not used */
0083     /* KERN_PPC_HTABRECLAIM not used */
0084     /* KERN_PPC_ZEROPAGED not used */
0085     { CTL_INT,  KERN_PPC_POWERSAVE_NAP,     "powersave-nap" },
0086 
0087     { CTL_STR,  KERN_MODPROBE,          "modprobe" },
0088     { CTL_INT,  KERN_SG_BIG_BUFF,       "sg-big-buff" },
0089     { CTL_INT,  KERN_ACCT,          "acct" },
0090     /* KERN_PPC_L2CR "l2cr" no longer used */
0091 
0092     /* KERN_RTSIGNR not used */
0093     /* KERN_RTSIGMAX not used */
0094 
0095     { CTL_ULONG,    KERN_SHMMAX,            "shmmax" },
0096     { CTL_INT,  KERN_MSGMAX,            "msgmax" },
0097     { CTL_INT,  KERN_MSGMNB,            "msgmnb" },
0098     /* KERN_MSGPOOL not used*/
0099     { CTL_INT,  KERN_SYSRQ,         "sysrq" },
0100     { CTL_INT,  KERN_MAX_THREADS,       "threads-max" },
0101     { CTL_DIR,  KERN_RANDOM,            "random",   bin_random_table },
0102     { CTL_ULONG,    KERN_SHMALL,            "shmall" },
0103     { CTL_INT,  KERN_MSGMNI,            "msgmni" },
0104     { CTL_INT,  KERN_SEM,           "sem" },
0105     { CTL_INT,  KERN_SPARC_STOP_A,      "stop-a" },
0106     { CTL_INT,  KERN_SHMMNI,            "shmmni" },
0107 
0108     { CTL_INT,  KERN_OVERFLOWUID,       "overflowuid" },
0109     { CTL_INT,  KERN_OVERFLOWGID,       "overflowgid" },
0110 
0111     { CTL_STR,  KERN_HOTPLUG,           "hotplug", },
0112     { CTL_INT,  KERN_IEEE_EMULATION_WARNINGS,   "ieee_emulation_warnings" },
0113 
0114     { CTL_INT,  KERN_S390_USER_DEBUG_LOGGING,   "userprocess_debug" },
0115     { CTL_INT,  KERN_CORE_USES_PID,     "core_uses_pid" },
0116     /* KERN_TAINTED "tainted" no longer used */
0117     { CTL_INT,  KERN_CADPID,            "cad_pid" },
0118     { CTL_INT,  KERN_PIDMAX,            "pid_max" },
0119     { CTL_STR,  KERN_CORE_PATTERN,      "core_pattern" },
0120     { CTL_INT,  KERN_PANIC_ON_OOPS,     "panic_on_oops" },
0121     { CTL_INT,  KERN_HPPA_PWRSW,        "soft-power" },
0122     { CTL_INT,  KERN_HPPA_UNALIGNED,        "unaligned-trap" },
0123 
0124     { CTL_INT,  KERN_PRINTK_RATELIMIT,      "printk_ratelimit" },
0125     { CTL_INT,  KERN_PRINTK_RATELIMIT_BURST,    "printk_ratelimit_burst" },
0126 
0127     { CTL_DIR,  KERN_PTY,           "pty",      bin_pty_table },
0128     { CTL_INT,  KERN_NGROUPS_MAX,       "ngroups_max" },
0129     { CTL_INT,  KERN_SPARC_SCONS_PWROFF,    "scons-poweroff" },
0130     /* KERN_HZ_TIMER "hz_timer" no longer used */
0131     { CTL_INT,  KERN_UNKNOWN_NMI_PANIC,     "unknown_nmi_panic" },
0132     { CTL_INT,  KERN_BOOTLOADER_TYPE,       "bootloader_type" },
0133     { CTL_INT,  KERN_RANDOMIZE,         "randomize_va_space" },
0134 
0135     { CTL_INT,  KERN_SPIN_RETRY,        "spin_retry" },
0136     /* KERN_ACPI_VIDEO_FLAGS "acpi_video_flags" no longer used */
0137     { CTL_INT,  KERN_IA64_UNALIGNED,        "ignore-unaligned-usertrap" },
0138     { CTL_INT,  KERN_COMPAT_LOG,        "compat-log" },
0139     { CTL_INT,  KERN_MAX_LOCK_DEPTH,        "max_lock_depth" },
0140     { CTL_INT,  KERN_PANIC_ON_NMI,      "panic_on_unrecovered_nmi" },
0141     { CTL_INT,  KERN_PANIC_ON_WARN,     "panic_on_warn" },
0142     {}
0143 };
0144 
0145 static const struct bin_table bin_vm_table[] = {
0146     { CTL_INT,  VM_OVERCOMMIT_MEMORY,       "overcommit_memory" },
0147     { CTL_INT,  VM_PAGE_CLUSTER,        "page-cluster" },
0148     { CTL_INT,  VM_DIRTY_BACKGROUND,        "dirty_background_ratio" },
0149     { CTL_INT,  VM_DIRTY_RATIO,         "dirty_ratio" },
0150     /* VM_DIRTY_WB_CS "dirty_writeback_centisecs" no longer used */
0151     /* VM_DIRTY_EXPIRE_CS "dirty_expire_centisecs" no longer used */
0152     /* VM_NR_PDFLUSH_THREADS "nr_pdflush_threads" no longer used */
0153     { CTL_INT,  VM_OVERCOMMIT_RATIO,        "overcommit_ratio" },
0154     /* VM_PAGEBUF unused */
0155     /* VM_HUGETLB_PAGES "nr_hugepages" no longer used */
0156     { CTL_INT,  VM_SWAPPINESS,          "swappiness" },
0157     { CTL_INT,  VM_LOWMEM_RESERVE_RATIO,    "lowmem_reserve_ratio" },
0158     { CTL_INT,  VM_MIN_FREE_KBYTES,     "min_free_kbytes" },
0159     { CTL_INT,  VM_MAX_MAP_COUNT,       "max_map_count" },
0160     { CTL_INT,  VM_LAPTOP_MODE,         "laptop_mode" },
0161     { CTL_INT,  VM_BLOCK_DUMP,          "block_dump" },
0162     { CTL_INT,  VM_HUGETLB_GROUP,       "hugetlb_shm_group" },
0163     { CTL_INT,  VM_VFS_CACHE_PRESSURE,  "vfs_cache_pressure" },
0164     { CTL_INT,  VM_LEGACY_VA_LAYOUT,        "legacy_va_layout" },
0165     /* VM_SWAP_TOKEN_TIMEOUT unused */
0166     { CTL_INT,  VM_DROP_PAGECACHE,      "drop_caches" },
0167     { CTL_INT,  VM_PERCPU_PAGELIST_FRACTION,    "percpu_pagelist_fraction" },
0168     { CTL_INT,  VM_ZONE_RECLAIM_MODE,       "zone_reclaim_mode" },
0169     { CTL_INT,  VM_MIN_UNMAPPED,        "min_unmapped_ratio" },
0170     { CTL_INT,  VM_PANIC_ON_OOM,        "panic_on_oom" },
0171     { CTL_INT,  VM_VDSO_ENABLED,        "vdso_enabled" },
0172     { CTL_INT,  VM_MIN_SLAB,            "min_slab_ratio" },
0173 
0174     {}
0175 };
0176 
0177 static const struct bin_table bin_net_core_table[] = {
0178     { CTL_INT,  NET_CORE_WMEM_MAX,  "wmem_max" },
0179     { CTL_INT,  NET_CORE_RMEM_MAX,  "rmem_max" },
0180     { CTL_INT,  NET_CORE_WMEM_DEFAULT,  "wmem_default" },
0181     { CTL_INT,  NET_CORE_RMEM_DEFAULT,  "rmem_default" },
0182     /* NET_CORE_DESTROY_DELAY unused */
0183     { CTL_INT,  NET_CORE_MAX_BACKLOG,   "netdev_max_backlog" },
0184     /* NET_CORE_FASTROUTE unused */
0185     { CTL_INT,  NET_CORE_MSG_COST,  "message_cost" },
0186     { CTL_INT,  NET_CORE_MSG_BURST, "message_burst" },
0187     { CTL_INT,  NET_CORE_OPTMEM_MAX,    "optmem_max" },
0188     /* NET_CORE_HOT_LIST_LENGTH unused */
0189     /* NET_CORE_DIVERT_VERSION unused */
0190     /* NET_CORE_NO_CONG_THRESH unused */
0191     /* NET_CORE_NO_CONG unused */
0192     /* NET_CORE_LO_CONG unused */
0193     /* NET_CORE_MOD_CONG unused */
0194     { CTL_INT,  NET_CORE_DEV_WEIGHT,    "dev_weight" },
0195     { CTL_INT,  NET_CORE_SOMAXCONN, "somaxconn" },
0196     { CTL_INT,  NET_CORE_BUDGET,    "netdev_budget" },
0197     { CTL_INT,  NET_CORE_AEVENT_ETIME,  "xfrm_aevent_etime" },
0198     { CTL_INT,  NET_CORE_AEVENT_RSEQTH, "xfrm_aevent_rseqth" },
0199     { CTL_INT,  NET_CORE_WARNINGS,  "warnings" },
0200     {},
0201 };
0202 
0203 static const struct bin_table bin_net_unix_table[] = {
0204     /* NET_UNIX_DESTROY_DELAY unused */
0205     /* NET_UNIX_DELETE_DELAY unused */
0206     { CTL_INT,  NET_UNIX_MAX_DGRAM_QLEN,    "max_dgram_qlen" },
0207     {}
0208 };
0209 
0210 static const struct bin_table bin_net_ipv4_route_table[] = {
0211     { CTL_INT,  NET_IPV4_ROUTE_FLUSH,           "flush" },
0212     /* NET_IPV4_ROUTE_MIN_DELAY "min_delay" no longer used */
0213     /* NET_IPV4_ROUTE_MAX_DELAY "max_delay" no longer used */
0214     { CTL_INT,  NET_IPV4_ROUTE_GC_THRESH,       "gc_thresh" },
0215     { CTL_INT,  NET_IPV4_ROUTE_MAX_SIZE,        "max_size" },
0216     { CTL_INT,  NET_IPV4_ROUTE_GC_MIN_INTERVAL,     "gc_min_interval" },
0217     { CTL_INT,  NET_IPV4_ROUTE_GC_MIN_INTERVAL_MS,  "gc_min_interval_ms" },
0218     { CTL_INT,  NET_IPV4_ROUTE_GC_TIMEOUT,      "gc_timeout" },
0219     /* NET_IPV4_ROUTE_GC_INTERVAL "gc_interval" no longer used */
0220     { CTL_INT,  NET_IPV4_ROUTE_REDIRECT_LOAD,       "redirect_load" },
0221     { CTL_INT,  NET_IPV4_ROUTE_REDIRECT_NUMBER,     "redirect_number" },
0222     { CTL_INT,  NET_IPV4_ROUTE_REDIRECT_SILENCE,    "redirect_silence" },
0223     { CTL_INT,  NET_IPV4_ROUTE_ERROR_COST,      "error_cost" },
0224     { CTL_INT,  NET_IPV4_ROUTE_ERROR_BURST,     "error_burst" },
0225     { CTL_INT,  NET_IPV4_ROUTE_GC_ELASTICITY,       "gc_elasticity" },
0226     { CTL_INT,  NET_IPV4_ROUTE_MTU_EXPIRES,     "mtu_expires" },
0227     { CTL_INT,  NET_IPV4_ROUTE_MIN_PMTU,        "min_pmtu" },
0228     { CTL_INT,  NET_IPV4_ROUTE_MIN_ADVMSS,      "min_adv_mss" },
0229     {}
0230 };
0231 
0232 static const struct bin_table bin_net_ipv4_conf_vars_table[] = {
0233     { CTL_INT,  NET_IPV4_CONF_FORWARDING,       "forwarding" },
0234     { CTL_INT,  NET_IPV4_CONF_MC_FORWARDING,        "mc_forwarding" },
0235 
0236     { CTL_INT,  NET_IPV4_CONF_ACCEPT_REDIRECTS,     "accept_redirects" },
0237     { CTL_INT,  NET_IPV4_CONF_SECURE_REDIRECTS,     "secure_redirects" },
0238     { CTL_INT,  NET_IPV4_CONF_SEND_REDIRECTS,       "send_redirects" },
0239     { CTL_INT,  NET_IPV4_CONF_SHARED_MEDIA,     "shared_media" },
0240     { CTL_INT,  NET_IPV4_CONF_RP_FILTER,        "rp_filter" },
0241     { CTL_INT,  NET_IPV4_CONF_ACCEPT_SOURCE_ROUTE,  "accept_source_route" },
0242     { CTL_INT,  NET_IPV4_CONF_PROXY_ARP,        "proxy_arp" },
0243     { CTL_INT,  NET_IPV4_CONF_MEDIUM_ID,        "medium_id" },
0244     { CTL_INT,  NET_IPV4_CONF_BOOTP_RELAY,      "bootp_relay" },
0245     { CTL_INT,  NET_IPV4_CONF_LOG_MARTIANS,     "log_martians" },
0246     { CTL_INT,  NET_IPV4_CONF_TAG,          "tag" },
0247     { CTL_INT,  NET_IPV4_CONF_ARPFILTER,        "arp_filter" },
0248     { CTL_INT,  NET_IPV4_CONF_ARP_ANNOUNCE,     "arp_announce" },
0249     { CTL_INT,  NET_IPV4_CONF_ARP_IGNORE,       "arp_ignore" },
0250     { CTL_INT,  NET_IPV4_CONF_ARP_ACCEPT,       "arp_accept" },
0251     { CTL_INT,  NET_IPV4_CONF_ARP_NOTIFY,       "arp_notify" },
0252 
0253     { CTL_INT,  NET_IPV4_CONF_NOXFRM,           "disable_xfrm" },
0254     { CTL_INT,  NET_IPV4_CONF_NOPOLICY,         "disable_policy" },
0255     { CTL_INT,  NET_IPV4_CONF_FORCE_IGMP_VERSION,   "force_igmp_version" },
0256     { CTL_INT,  NET_IPV4_CONF_PROMOTE_SECONDARIES,  "promote_secondaries" },
0257     {}
0258 };
0259 
0260 static const struct bin_table bin_net_ipv4_conf_table[] = {
0261     { CTL_DIR,  NET_PROTO_CONF_ALL, "all",      bin_net_ipv4_conf_vars_table },
0262     { CTL_DIR,  NET_PROTO_CONF_DEFAULT, "default",  bin_net_ipv4_conf_vars_table },
0263     { CTL_DIR,  0, NULL, bin_net_ipv4_conf_vars_table },
0264     {}
0265 };
0266 
0267 static const struct bin_table bin_net_neigh_vars_table[] = {
0268     { CTL_INT,  NET_NEIGH_MCAST_SOLICIT,    "mcast_solicit" },
0269     { CTL_INT,  NET_NEIGH_UCAST_SOLICIT,    "ucast_solicit" },
0270     { CTL_INT,  NET_NEIGH_APP_SOLICIT,      "app_solicit" },
0271     /* NET_NEIGH_RETRANS_TIME "retrans_time" no longer used */
0272     { CTL_INT,  NET_NEIGH_REACHABLE_TIME,   "base_reachable_time" },
0273     { CTL_INT,  NET_NEIGH_DELAY_PROBE_TIME, "delay_first_probe_time" },
0274     { CTL_INT,  NET_NEIGH_GC_STALE_TIME,    "gc_stale_time" },
0275     { CTL_INT,  NET_NEIGH_UNRES_QLEN,       "unres_qlen" },
0276     { CTL_INT,  NET_NEIGH_PROXY_QLEN,       "proxy_qlen" },
0277     /* NET_NEIGH_ANYCAST_DELAY "anycast_delay" no longer used */
0278     /* NET_NEIGH_PROXY_DELAY "proxy_delay" no longer used */
0279     /* NET_NEIGH_LOCKTIME "locktime" no longer used */
0280     { CTL_INT,  NET_NEIGH_GC_INTERVAL,      "gc_interval" },
0281     { CTL_INT,  NET_NEIGH_GC_THRESH1,       "gc_thresh1" },
0282     { CTL_INT,  NET_NEIGH_GC_THRESH2,       "gc_thresh2" },
0283     { CTL_INT,  NET_NEIGH_GC_THRESH3,       "gc_thresh3" },
0284     { CTL_INT,  NET_NEIGH_RETRANS_TIME_MS,  "retrans_time_ms" },
0285     { CTL_INT,  NET_NEIGH_REACHABLE_TIME_MS,    "base_reachable_time_ms" },
0286     {}
0287 };
0288 
0289 static const struct bin_table bin_net_neigh_table[] = {
0290     { CTL_DIR,  NET_PROTO_CONF_DEFAULT, "default", bin_net_neigh_vars_table },
0291     { CTL_DIR,  0, NULL, bin_net_neigh_vars_table },
0292     {}
0293 };
0294 
0295 static const struct bin_table bin_net_ipv4_netfilter_table[] = {
0296     { CTL_INT,  NET_IPV4_NF_CONNTRACK_MAX,      "ip_conntrack_max" },
0297 
0298     /* NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_SYN_SENT "ip_conntrack_tcp_timeout_syn_sent" no longer used */
0299     /* NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_SYN_RECV "ip_conntrack_tcp_timeout_syn_recv" no longer used */
0300     /* NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_ESTABLISHED "ip_conntrack_tcp_timeout_established" no longer used */
0301     /* NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_FIN_WAIT "ip_conntrack_tcp_timeout_fin_wait" no longer used */
0302     /* NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_CLOSE_WAIT "ip_conntrack_tcp_timeout_close_wait" no longer used */
0303     /* NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_LAST_ACK "ip_conntrack_tcp_timeout_last_ack" no longer used */
0304     /* NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_TIME_WAIT "ip_conntrack_tcp_timeout_time_wait" no longer used */
0305     /* NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_CLOSE "ip_conntrack_tcp_timeout_close" no longer used */
0306 
0307     /* NET_IPV4_NF_CONNTRACK_UDP_TIMEOUT "ip_conntrack_udp_timeout" no longer used */
0308     /* NET_IPV4_NF_CONNTRACK_UDP_TIMEOUT_STREAM "ip_conntrack_udp_timeout_stream" no longer used */
0309     /* NET_IPV4_NF_CONNTRACK_ICMP_TIMEOUT "ip_conntrack_icmp_timeout" no longer used */
0310     /* NET_IPV4_NF_CONNTRACK_GENERIC_TIMEOUT "ip_conntrack_generic_timeout" no longer used */
0311 
0312     { CTL_INT,  NET_IPV4_NF_CONNTRACK_BUCKETS,      "ip_conntrack_buckets" },
0313     { CTL_INT,  NET_IPV4_NF_CONNTRACK_LOG_INVALID,  "ip_conntrack_log_invalid" },
0314     /* NET_IPV4_NF_CONNTRACK_TCP_TIMEOUT_MAX_RETRANS "ip_conntrack_tcp_timeout_max_retrans" no longer used */
0315     { CTL_INT,  NET_IPV4_NF_CONNTRACK_TCP_LOOSE,    "ip_conntrack_tcp_loose" },
0316     { CTL_INT,  NET_IPV4_NF_CONNTRACK_TCP_BE_LIBERAL,   "ip_conntrack_tcp_be_liberal" },
0317     { CTL_INT,  NET_IPV4_NF_CONNTRACK_TCP_MAX_RETRANS,  "ip_conntrack_tcp_max_retrans" },
0318 
0319     /* NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_CLOSED "ip_conntrack_sctp_timeout_closed" no longer used */
0320     /* NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_COOKIE_WAIT "ip_conntrack_sctp_timeout_cookie_wait" no longer used */
0321     /* NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_COOKIE_ECHOED "ip_conntrack_sctp_timeout_cookie_echoed" no longer used */
0322     /* NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_ESTABLISHED "ip_conntrack_sctp_timeout_established" no longer used */
0323     /* NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_SENT "ip_conntrack_sctp_timeout_shutdown_sent" no longer used */
0324     /* NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_RECD "ip_conntrack_sctp_timeout_shutdown_recd" no longer used */
0325     /* NET_IPV4_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_ACK_SENT "ip_conntrack_sctp_timeout_shutdown_ack_sent" no longer used */
0326 
0327     { CTL_INT,  NET_IPV4_NF_CONNTRACK_COUNT,        "ip_conntrack_count" },
0328     { CTL_INT,  NET_IPV4_NF_CONNTRACK_CHECKSUM,     "ip_conntrack_checksum" },
0329     {}
0330 };
0331 
0332 static const struct bin_table bin_net_ipv4_table[] = {
0333     {CTL_INT,   NET_IPV4_FORWARD,           "ip_forward" },
0334 
0335     { CTL_DIR,  NET_IPV4_CONF,      "conf",     bin_net_ipv4_conf_table },
0336     { CTL_DIR,  NET_IPV4_NEIGH,     "neigh",    bin_net_neigh_table },
0337     { CTL_DIR,  NET_IPV4_ROUTE,     "route",    bin_net_ipv4_route_table },
0338     /* NET_IPV4_FIB_HASH unused */
0339     { CTL_DIR,  NET_IPV4_NETFILTER, "netfilter",    bin_net_ipv4_netfilter_table },
0340 
0341     { CTL_INT,  NET_IPV4_TCP_TIMESTAMPS,        "tcp_timestamps" },
0342     { CTL_INT,  NET_IPV4_TCP_WINDOW_SCALING,        "tcp_window_scaling" },
0343     { CTL_INT,  NET_IPV4_TCP_SACK,          "tcp_sack" },
0344     { CTL_INT,  NET_IPV4_TCP_RETRANS_COLLAPSE,      "tcp_retrans_collapse" },
0345     { CTL_INT,  NET_IPV4_DEFAULT_TTL,           "ip_default_ttl" },
0346     /* NET_IPV4_AUTOCONFIG unused */
0347     { CTL_INT,  NET_IPV4_NO_PMTU_DISC,          "ip_no_pmtu_disc" },
0348     { CTL_INT,  NET_IPV4_NONLOCAL_BIND,         "ip_nonlocal_bind" },
0349     { CTL_INT,  NET_IPV4_TCP_SYN_RETRIES,       "tcp_syn_retries" },
0350     { CTL_INT,  NET_TCP_SYNACK_RETRIES,         "tcp_synack_retries" },
0351     { CTL_INT,  NET_TCP_MAX_ORPHANS,            "tcp_max_orphans" },
0352     { CTL_INT,  NET_TCP_MAX_TW_BUCKETS,         "tcp_max_tw_buckets" },
0353     { CTL_INT,  NET_IPV4_DYNADDR,           "ip_dynaddr" },
0354     { CTL_INT,  NET_IPV4_TCP_KEEPALIVE_TIME,        "tcp_keepalive_time" },
0355     { CTL_INT,  NET_IPV4_TCP_KEEPALIVE_PROBES,      "tcp_keepalive_probes" },
0356     { CTL_INT,  NET_IPV4_TCP_KEEPALIVE_INTVL,       "tcp_keepalive_intvl" },
0357     { CTL_INT,  NET_IPV4_TCP_RETRIES1,          "tcp_retries1" },
0358     { CTL_INT,  NET_IPV4_TCP_RETRIES2,          "tcp_retries2" },
0359     { CTL_INT,  NET_IPV4_TCP_FIN_TIMEOUT,       "tcp_fin_timeout" },
0360     { CTL_INT,  NET_TCP_SYNCOOKIES,         "tcp_syncookies" },
0361     { CTL_INT,  NET_TCP_TW_RECYCLE,         "tcp_tw_recycle" },
0362     { CTL_INT,  NET_TCP_ABORT_ON_OVERFLOW,      "tcp_abort_on_overflow" },
0363     { CTL_INT,  NET_TCP_STDURG,             "tcp_stdurg" },
0364     { CTL_INT,  NET_TCP_RFC1337,            "tcp_rfc1337" },
0365     { CTL_INT,  NET_TCP_MAX_SYN_BACKLOG,        "tcp_max_syn_backlog" },
0366     { CTL_INT,  NET_IPV4_LOCAL_PORT_RANGE,      "ip_local_port_range" },
0367     { CTL_INT,  NET_IPV4_IGMP_MAX_MEMBERSHIPS,      "igmp_max_memberships" },
0368     { CTL_INT,  NET_IPV4_IGMP_MAX_MSF,          "igmp_max_msf" },
0369     { CTL_INT,  NET_IPV4_INET_PEER_THRESHOLD,       "inet_peer_threshold" },
0370     { CTL_INT,  NET_IPV4_INET_PEER_MINTTL,      "inet_peer_minttl" },
0371     { CTL_INT,  NET_IPV4_INET_PEER_MAXTTL,      "inet_peer_maxttl" },
0372     { CTL_INT,  NET_IPV4_INET_PEER_GC_MINTIME,      "inet_peer_gc_mintime" },
0373     { CTL_INT,  NET_IPV4_INET_PEER_GC_MAXTIME,      "inet_peer_gc_maxtime" },
0374     { CTL_INT,  NET_TCP_ORPHAN_RETRIES,         "tcp_orphan_retries" },
0375     { CTL_INT,  NET_TCP_FACK,               "tcp_fack" },
0376     { CTL_INT,  NET_TCP_REORDERING,         "tcp_reordering" },
0377     { CTL_INT,  NET_TCP_ECN,                "tcp_ecn" },
0378     { CTL_INT,  NET_TCP_DSACK,              "tcp_dsack" },
0379     { CTL_INT,  NET_TCP_MEM,                "tcp_mem" },
0380     { CTL_INT,  NET_TCP_WMEM,               "tcp_wmem" },
0381     { CTL_INT,  NET_TCP_RMEM,               "tcp_rmem" },
0382     { CTL_INT,  NET_TCP_APP_WIN,            "tcp_app_win" },
0383     { CTL_INT,  NET_TCP_ADV_WIN_SCALE,          "tcp_adv_win_scale" },
0384     { CTL_INT,  NET_TCP_TW_REUSE,           "tcp_tw_reuse" },
0385     { CTL_INT,  NET_TCP_FRTO,               "tcp_frto" },
0386     { CTL_INT,  NET_TCP_FRTO_RESPONSE,          "tcp_frto_response" },
0387     { CTL_INT,  NET_TCP_LOW_LATENCY,            "tcp_low_latency" },
0388     { CTL_INT,  NET_TCP_NO_METRICS_SAVE,        "tcp_no_metrics_save" },
0389     { CTL_INT,  NET_TCP_MODERATE_RCVBUF,        "tcp_moderate_rcvbuf" },
0390     { CTL_INT,  NET_TCP_TSO_WIN_DIVISOR,        "tcp_tso_win_divisor" },
0391     { CTL_STR,  NET_TCP_CONG_CONTROL,           "tcp_congestion_control" },
0392     { CTL_INT,  NET_TCP_MTU_PROBING,            "tcp_mtu_probing" },
0393     { CTL_INT,  NET_TCP_BASE_MSS,           "tcp_base_mss" },
0394     { CTL_INT,  NET_IPV4_TCP_WORKAROUND_SIGNED_WINDOWS, "tcp_workaround_signed_windows" },
0395     { CTL_INT,  NET_TCP_SLOW_START_AFTER_IDLE,      "tcp_slow_start_after_idle" },
0396     { CTL_INT,  NET_CIPSOV4_CACHE_ENABLE,       "cipso_cache_enable" },
0397     { CTL_INT,  NET_CIPSOV4_CACHE_BUCKET_SIZE,      "cipso_cache_bucket_size" },
0398     { CTL_INT,  NET_CIPSOV4_RBM_OPTFMT,         "cipso_rbm_optfmt" },
0399     { CTL_INT,  NET_CIPSOV4_RBM_STRICTVALID,        "cipso_rbm_strictvalid" },
0400     /* NET_TCP_AVAIL_CONG_CONTROL "tcp_available_congestion_control" no longer used */
0401     { CTL_STR,  NET_TCP_ALLOWED_CONG_CONTROL,       "tcp_allowed_congestion_control" },
0402     { CTL_INT,  NET_TCP_MAX_SSTHRESH,           "tcp_max_ssthresh" },
0403 
0404     { CTL_INT,  NET_IPV4_ICMP_ECHO_IGNORE_ALL,      "icmp_echo_ignore_all" },
0405     { CTL_INT,  NET_IPV4_ICMP_ECHO_IGNORE_BROADCASTS,   "icmp_echo_ignore_broadcasts" },
0406     { CTL_INT,  NET_IPV4_ICMP_IGNORE_BOGUS_ERROR_RESPONSES, "icmp_ignore_bogus_error_responses" },
0407     { CTL_INT,  NET_IPV4_ICMP_ERRORS_USE_INBOUND_IFADDR,    "icmp_errors_use_inbound_ifaddr" },
0408     { CTL_INT,  NET_IPV4_ICMP_RATELIMIT,        "icmp_ratelimit" },
0409     { CTL_INT,  NET_IPV4_ICMP_RATEMASK,         "icmp_ratemask" },
0410 
0411     { CTL_INT,  NET_IPV4_IPFRAG_HIGH_THRESH,        "ipfrag_high_thresh" },
0412     { CTL_INT,  NET_IPV4_IPFRAG_LOW_THRESH,     "ipfrag_low_thresh" },
0413     { CTL_INT,  NET_IPV4_IPFRAG_TIME,           "ipfrag_time" },
0414 
0415     { CTL_INT,  NET_IPV4_IPFRAG_SECRET_INTERVAL,    "ipfrag_secret_interval" },
0416     /* NET_IPV4_IPFRAG_MAX_DIST "ipfrag_max_dist" no longer used */
0417 
0418     { CTL_INT,  2088 /* NET_IPQ_QMAX */,        "ip_queue_maxlen" },
0419 
0420     /* NET_TCP_DEFAULT_WIN_SCALE unused */
0421     /* NET_TCP_BIC_BETA unused */
0422     /* NET_IPV4_TCP_MAX_KA_PROBES unused */
0423     /* NET_IPV4_IP_MASQ_DEBUG unused */
0424     /* NET_TCP_SYN_TAILDROP unused */
0425     /* NET_IPV4_ICMP_SOURCEQUENCH_RATE unused */
0426     /* NET_IPV4_ICMP_DESTUNREACH_RATE unused */
0427     /* NET_IPV4_ICMP_TIMEEXCEED_RATE unused */
0428     /* NET_IPV4_ICMP_PARAMPROB_RATE unused */
0429     /* NET_IPV4_ICMP_ECHOREPLY_RATE unused */
0430     /* NET_IPV4_ALWAYS_DEFRAG unused */
0431     {}
0432 };
0433 
0434 static const struct bin_table bin_net_ipx_table[] = {
0435     { CTL_INT,  NET_IPX_PPROP_BROADCASTING, "ipx_pprop_broadcasting" },
0436     /* NET_IPX_FORWARDING unused */
0437     {}
0438 };
0439 
0440 static const struct bin_table bin_net_atalk_table[] = {
0441     { CTL_INT,  NET_ATALK_AARP_EXPIRY_TIME,     "aarp-expiry-time" },
0442     { CTL_INT,  NET_ATALK_AARP_TICK_TIME,       "aarp-tick-time" },
0443     { CTL_INT,  NET_ATALK_AARP_RETRANSMIT_LIMIT,    "aarp-retransmit-limit" },
0444     { CTL_INT,  NET_ATALK_AARP_RESOLVE_TIME,        "aarp-resolve-time" },
0445     {},
0446 };
0447 
0448 static const struct bin_table bin_net_netrom_table[] = {
0449     { CTL_INT,  NET_NETROM_DEFAULT_PATH_QUALITY,        "default_path_quality" },
0450     { CTL_INT,  NET_NETROM_OBSOLESCENCE_COUNT_INITIALISER,  "obsolescence_count_initialiser" },
0451     { CTL_INT,  NET_NETROM_NETWORK_TTL_INITIALISER,     "network_ttl_initialiser" },
0452     { CTL_INT,  NET_NETROM_TRANSPORT_TIMEOUT,           "transport_timeout" },
0453     { CTL_INT,  NET_NETROM_TRANSPORT_MAXIMUM_TRIES,     "transport_maximum_tries" },
0454     { CTL_INT,  NET_NETROM_TRANSPORT_ACKNOWLEDGE_DELAY,     "transport_acknowledge_delay" },
0455     { CTL_INT,  NET_NETROM_TRANSPORT_BUSY_DELAY,        "transport_busy_delay" },
0456     { CTL_INT,  NET_NETROM_TRANSPORT_REQUESTED_WINDOW_SIZE, "transport_requested_window_size" },
0457     { CTL_INT,  NET_NETROM_TRANSPORT_NO_ACTIVITY_TIMEOUT,   "transport_no_activity_timeout" },
0458     { CTL_INT,  NET_NETROM_ROUTING_CONTROL,         "routing_control" },
0459     { CTL_INT,  NET_NETROM_LINK_FAILS_COUNT,            "link_fails_count" },
0460     { CTL_INT,  NET_NETROM_RESET,               "reset" },
0461     {}
0462 };
0463 
0464 static const struct bin_table bin_net_ax25_param_table[] = {
0465     { CTL_INT,  NET_AX25_IP_DEFAULT_MODE,   "ip_default_mode" },
0466     { CTL_INT,  NET_AX25_DEFAULT_MODE,      "ax25_default_mode" },
0467     { CTL_INT,  NET_AX25_BACKOFF_TYPE,      "backoff_type" },
0468     { CTL_INT,  NET_AX25_CONNECT_MODE,      "connect_mode" },
0469     { CTL_INT,  NET_AX25_STANDARD_WINDOW,   "standard_window_size" },
0470     { CTL_INT,  NET_AX25_EXTENDED_WINDOW,   "extended_window_size" },
0471     { CTL_INT,  NET_AX25_T1_TIMEOUT,        "t1_timeout" },
0472     { CTL_INT,  NET_AX25_T2_TIMEOUT,        "t2_timeout" },
0473     { CTL_INT,  NET_AX25_T3_TIMEOUT,        "t3_timeout" },
0474     { CTL_INT,  NET_AX25_IDLE_TIMEOUT,      "idle_timeout" },
0475     { CTL_INT,  NET_AX25_N2,            "maximum_retry_count" },
0476     { CTL_INT,  NET_AX25_PACLEN,        "maximum_packet_length" },
0477     { CTL_INT,  NET_AX25_PROTOCOL,      "protocol" },
0478     { CTL_INT,  NET_AX25_DAMA_SLAVE_TIMEOUT,    "dama_slave_timeout" },
0479     {}
0480 };
0481 
0482 static const struct bin_table bin_net_ax25_table[] = {
0483     { CTL_DIR,  0, NULL, bin_net_ax25_param_table },
0484     {}
0485 };
0486 
0487 static const struct bin_table bin_net_rose_table[] = {
0488     { CTL_INT,  NET_ROSE_RESTART_REQUEST_TIMEOUT,   "restart_request_timeout" },
0489     { CTL_INT,  NET_ROSE_CALL_REQUEST_TIMEOUT,      "call_request_timeout" },
0490     { CTL_INT,  NET_ROSE_RESET_REQUEST_TIMEOUT,     "reset_request_timeout" },
0491     { CTL_INT,  NET_ROSE_CLEAR_REQUEST_TIMEOUT,     "clear_request_timeout" },
0492     { CTL_INT,  NET_ROSE_ACK_HOLD_BACK_TIMEOUT,     "acknowledge_hold_back_timeout" },
0493     { CTL_INT,  NET_ROSE_ROUTING_CONTROL,       "routing_control" },
0494     { CTL_INT,  NET_ROSE_LINK_FAIL_TIMEOUT,     "link_fail_timeout" },
0495     { CTL_INT,  NET_ROSE_MAX_VCS,           "maximum_virtual_circuits" },
0496     { CTL_INT,  NET_ROSE_WINDOW_SIZE,           "window_size" },
0497     { CTL_INT,  NET_ROSE_NO_ACTIVITY_TIMEOUT,       "no_activity_timeout" },
0498     {}
0499 };
0500 
0501 static const struct bin_table bin_net_ipv6_conf_var_table[] = {
0502     { CTL_INT,  NET_IPV6_FORWARDING,            "forwarding" },
0503     { CTL_INT,  NET_IPV6_HOP_LIMIT,         "hop_limit" },
0504     { CTL_INT,  NET_IPV6_MTU,               "mtu" },
0505     { CTL_INT,  NET_IPV6_ACCEPT_RA,         "accept_ra" },
0506     { CTL_INT,  NET_IPV6_ACCEPT_REDIRECTS,      "accept_redirects" },
0507     { CTL_INT,  NET_IPV6_AUTOCONF,          "autoconf" },
0508     { CTL_INT,  NET_IPV6_DAD_TRANSMITS,         "dad_transmits" },
0509     { CTL_INT,  NET_IPV6_RTR_SOLICITS,          "router_solicitations" },
0510     { CTL_INT,  NET_IPV6_RTR_SOLICIT_INTERVAL,      "router_solicitation_interval" },
0511     { CTL_INT,  NET_IPV6_RTR_SOLICIT_DELAY,     "router_solicitation_delay" },
0512     { CTL_INT,  NET_IPV6_USE_TEMPADDR,          "use_tempaddr" },
0513     { CTL_INT,  NET_IPV6_TEMP_VALID_LFT,        "temp_valid_lft" },
0514     { CTL_INT,  NET_IPV6_TEMP_PREFERED_LFT,     "temp_prefered_lft" },
0515     { CTL_INT,  NET_IPV6_REGEN_MAX_RETRY,       "regen_max_retry" },
0516     { CTL_INT,  NET_IPV6_MAX_DESYNC_FACTOR,     "max_desync_factor" },
0517     { CTL_INT,  NET_IPV6_MAX_ADDRESSES,         "max_addresses" },
0518     { CTL_INT,  NET_IPV6_FORCE_MLD_VERSION,     "force_mld_version" },
0519     { CTL_INT,  NET_IPV6_ACCEPT_RA_DEFRTR,      "accept_ra_defrtr" },
0520     { CTL_INT,  NET_IPV6_ACCEPT_RA_PINFO,       "accept_ra_pinfo" },
0521     { CTL_INT,  NET_IPV6_ACCEPT_RA_RTR_PREF,        "accept_ra_rtr_pref" },
0522     { CTL_INT,  NET_IPV6_RTR_PROBE_INTERVAL,        "router_probe_interval" },
0523     { CTL_INT,  NET_IPV6_ACCEPT_RA_RT_INFO_MAX_PLEN,    "accept_ra_rt_info_max_plen" },
0524     { CTL_INT,  NET_IPV6_PROXY_NDP,         "proxy_ndp" },
0525     { CTL_INT,  NET_IPV6_ACCEPT_SOURCE_ROUTE,       "accept_source_route" },
0526     { CTL_INT,  NET_IPV6_ACCEPT_RA_FROM_LOCAL,      "accept_ra_from_local" },
0527     {}
0528 };
0529 
0530 static const struct bin_table bin_net_ipv6_conf_table[] = {
0531     { CTL_DIR,  NET_PROTO_CONF_ALL,     "all",  bin_net_ipv6_conf_var_table },
0532     { CTL_DIR,  NET_PROTO_CONF_DEFAULT,     "default", bin_net_ipv6_conf_var_table },
0533     { CTL_DIR,  0, NULL, bin_net_ipv6_conf_var_table },
0534     {}
0535 };
0536 
0537 static const struct bin_table bin_net_ipv6_route_table[] = {
0538     /* NET_IPV6_ROUTE_FLUSH "flush"  no longer used */
0539     { CTL_INT,  NET_IPV6_ROUTE_GC_THRESH,       "gc_thresh" },
0540     { CTL_INT,  NET_IPV6_ROUTE_MAX_SIZE,        "max_size" },
0541     { CTL_INT,  NET_IPV6_ROUTE_GC_MIN_INTERVAL,     "gc_min_interval" },
0542     { CTL_INT,  NET_IPV6_ROUTE_GC_TIMEOUT,      "gc_timeout" },
0543     { CTL_INT,  NET_IPV6_ROUTE_GC_INTERVAL,     "gc_interval" },
0544     { CTL_INT,  NET_IPV6_ROUTE_GC_ELASTICITY,       "gc_elasticity" },
0545     { CTL_INT,  NET_IPV6_ROUTE_MTU_EXPIRES,     "mtu_expires" },
0546     { CTL_INT,  NET_IPV6_ROUTE_MIN_ADVMSS,      "min_adv_mss" },
0547     { CTL_INT,  NET_IPV6_ROUTE_GC_MIN_INTERVAL_MS,  "gc_min_interval_ms" },
0548     {}
0549 };
0550 
0551 static const struct bin_table bin_net_ipv6_icmp_table[] = {
0552     { CTL_INT,  NET_IPV6_ICMP_RATELIMIT,    "ratelimit" },
0553     {}
0554 };
0555 
0556 static const struct bin_table bin_net_ipv6_table[] = {
0557     { CTL_DIR,  NET_IPV6_CONF,      "conf",     bin_net_ipv6_conf_table },
0558     { CTL_DIR,  NET_IPV6_NEIGH,     "neigh",    bin_net_neigh_table },
0559     { CTL_DIR,  NET_IPV6_ROUTE,     "route",    bin_net_ipv6_route_table },
0560     { CTL_DIR,  NET_IPV6_ICMP,      "icmp",     bin_net_ipv6_icmp_table },
0561     { CTL_INT,  NET_IPV6_BINDV6ONLY,        "bindv6only" },
0562     { CTL_INT,  NET_IPV6_IP6FRAG_HIGH_THRESH,   "ip6frag_high_thresh" },
0563     { CTL_INT,  NET_IPV6_IP6FRAG_LOW_THRESH,    "ip6frag_low_thresh" },
0564     { CTL_INT,  NET_IPV6_IP6FRAG_TIME,      "ip6frag_time" },
0565     { CTL_INT,  NET_IPV6_IP6FRAG_SECRET_INTERVAL,   "ip6frag_secret_interval" },
0566     { CTL_INT,  NET_IPV6_MLD_MAX_MSF,       "mld_max_msf" },
0567     { CTL_INT,  2088 /* IPQ_QMAX */,        "ip6_queue_maxlen" },
0568     {}
0569 };
0570 
0571 static const struct bin_table bin_net_x25_table[] = {
0572     { CTL_INT,  NET_X25_RESTART_REQUEST_TIMEOUT,    "restart_request_timeout" },
0573     { CTL_INT,  NET_X25_CALL_REQUEST_TIMEOUT,       "call_request_timeout" },
0574     { CTL_INT,  NET_X25_RESET_REQUEST_TIMEOUT,  "reset_request_timeout" },
0575     { CTL_INT,  NET_X25_CLEAR_REQUEST_TIMEOUT,  "clear_request_timeout" },
0576     { CTL_INT,  NET_X25_ACK_HOLD_BACK_TIMEOUT,  "acknowledgement_hold_back_timeout" },
0577     { CTL_INT,  NET_X25_FORWARD,            "x25_forward" },
0578     {}
0579 };
0580 
0581 static const struct bin_table bin_net_tr_table[] = {
0582     { CTL_INT,  NET_TR_RIF_TIMEOUT, "rif_timeout" },
0583     {}
0584 };
0585 
0586 
0587 static const struct bin_table bin_net_decnet_conf_vars[] = {
0588     { CTL_INT,  NET_DECNET_CONF_DEV_FORWARDING, "forwarding" },
0589     { CTL_INT,  NET_DECNET_CONF_DEV_PRIORITY,   "priority" },
0590     { CTL_INT,  NET_DECNET_CONF_DEV_T2,     "t2" },
0591     { CTL_INT,  NET_DECNET_CONF_DEV_T3,     "t3" },
0592     {}
0593 };
0594 
0595 static const struct bin_table bin_net_decnet_conf[] = {
0596     { CTL_DIR, NET_DECNET_CONF_ETHER,    "ethernet", bin_net_decnet_conf_vars },
0597     { CTL_DIR, NET_DECNET_CONF_GRE,      "ipgre",    bin_net_decnet_conf_vars },
0598     { CTL_DIR, NET_DECNET_CONF_X25,      "x25",      bin_net_decnet_conf_vars },
0599     { CTL_DIR, NET_DECNET_CONF_PPP,      "ppp",      bin_net_decnet_conf_vars },
0600     { CTL_DIR, NET_DECNET_CONF_DDCMP,    "ddcmp",    bin_net_decnet_conf_vars },
0601     { CTL_DIR, NET_DECNET_CONF_LOOPBACK, "loopback", bin_net_decnet_conf_vars },
0602     { CTL_DIR, 0,                NULL,   bin_net_decnet_conf_vars },
0603     {}
0604 };
0605 
0606 static const struct bin_table bin_net_decnet_table[] = {
0607     { CTL_DIR,  NET_DECNET_CONF,        "conf", bin_net_decnet_conf },
0608     { CTL_DNADR,    NET_DECNET_NODE_ADDRESS,    "node_address" },
0609     { CTL_STR,  NET_DECNET_NODE_NAME,       "node_name" },
0610     { CTL_STR,  NET_DECNET_DEFAULT_DEVICE,  "default_device" },
0611     { CTL_INT,  NET_DECNET_TIME_WAIT,       "time_wait" },
0612     { CTL_INT,  NET_DECNET_DN_COUNT,        "dn_count" },
0613     { CTL_INT,  NET_DECNET_DI_COUNT,        "di_count" },
0614     { CTL_INT,  NET_DECNET_DR_COUNT,        "dr_count" },
0615     { CTL_INT,  NET_DECNET_DST_GC_INTERVAL, "dst_gc_interval" },
0616     { CTL_INT,  NET_DECNET_NO_FC_MAX_CWND,  "no_fc_max_cwnd" },
0617     { CTL_INT,  NET_DECNET_MEM,     "decnet_mem" },
0618     { CTL_INT,  NET_DECNET_RMEM,        "decnet_rmem" },
0619     { CTL_INT,  NET_DECNET_WMEM,        "decnet_wmem" },
0620     { CTL_INT,  NET_DECNET_DEBUG_LEVEL, "debug" },
0621     {}
0622 };
0623 
0624 static const struct bin_table bin_net_sctp_table[] = {
0625     { CTL_INT,  NET_SCTP_RTO_INITIAL,       "rto_initial" },
0626     { CTL_INT,  NET_SCTP_RTO_MIN,       "rto_min" },
0627     { CTL_INT,  NET_SCTP_RTO_MAX,       "rto_max" },
0628     { CTL_INT,  NET_SCTP_RTO_ALPHA,     "rto_alpha_exp_divisor" },
0629     { CTL_INT,  NET_SCTP_RTO_BETA,      "rto_beta_exp_divisor" },
0630     { CTL_INT,  NET_SCTP_VALID_COOKIE_LIFE, "valid_cookie_life" },
0631     { CTL_INT,  NET_SCTP_ASSOCIATION_MAX_RETRANS,   "association_max_retrans" },
0632     { CTL_INT,  NET_SCTP_PATH_MAX_RETRANS,  "path_max_retrans" },
0633     { CTL_INT,  NET_SCTP_MAX_INIT_RETRANSMITS,  "max_init_retransmits" },
0634     { CTL_INT,  NET_SCTP_HB_INTERVAL,       "hb_interval" },
0635     { CTL_INT,  NET_SCTP_PRESERVE_ENABLE,   "cookie_preserve_enable" },
0636     { CTL_INT,  NET_SCTP_MAX_BURST,     "max_burst" },
0637     { CTL_INT,  NET_SCTP_ADDIP_ENABLE,      "addip_enable" },
0638     { CTL_INT,  NET_SCTP_PRSCTP_ENABLE,     "prsctp_enable" },
0639     { CTL_INT,  NET_SCTP_SNDBUF_POLICY,     "sndbuf_policy" },
0640     { CTL_INT,  NET_SCTP_SACK_TIMEOUT,      "sack_timeout" },
0641     { CTL_INT,  NET_SCTP_RCVBUF_POLICY,     "rcvbuf_policy" },
0642     {}
0643 };
0644 
0645 static const struct bin_table bin_net_llc_llc2_timeout_table[] = {
0646     { CTL_INT,  NET_LLC2_ACK_TIMEOUT,   "ack" },
0647     { CTL_INT,  NET_LLC2_P_TIMEOUT, "p" },
0648     { CTL_INT,  NET_LLC2_REJ_TIMEOUT,   "rej" },
0649     { CTL_INT,  NET_LLC2_BUSY_TIMEOUT,  "busy" },
0650     {}
0651 };
0652 
0653 static const struct bin_table bin_net_llc_station_table[] = {
0654     { CTL_INT,  NET_LLC_STATION_ACK_TIMEOUT,    "ack_timeout" },
0655     {}
0656 };
0657 
0658 static const struct bin_table bin_net_llc_llc2_table[] = {
0659     { CTL_DIR,  NET_LLC2,       "timeout",  bin_net_llc_llc2_timeout_table },
0660     {}
0661 };
0662 
0663 static const struct bin_table bin_net_llc_table[] = {
0664     { CTL_DIR,  NET_LLC2,       "llc2",     bin_net_llc_llc2_table },
0665     { CTL_DIR,  NET_LLC_STATION,    "station",  bin_net_llc_station_table },
0666     {}
0667 };
0668 
0669 static const struct bin_table bin_net_netfilter_table[] = {
0670     { CTL_INT,  NET_NF_CONNTRACK_MAX,           "nf_conntrack_max" },
0671     /* NET_NF_CONNTRACK_TCP_TIMEOUT_SYN_SENT "nf_conntrack_tcp_timeout_syn_sent" no longer used */
0672     /* NET_NF_CONNTRACK_TCP_TIMEOUT_SYN_RECV "nf_conntrack_tcp_timeout_syn_recv" no longer used */
0673     /* NET_NF_CONNTRACK_TCP_TIMEOUT_ESTABLISHED "nf_conntrack_tcp_timeout_established" no longer used */
0674     /* NET_NF_CONNTRACK_TCP_TIMEOUT_FIN_WAIT "nf_conntrack_tcp_timeout_fin_wait" no longer used */
0675     /* NET_NF_CONNTRACK_TCP_TIMEOUT_CLOSE_WAIT "nf_conntrack_tcp_timeout_close_wait" no longer used */
0676     /* NET_NF_CONNTRACK_TCP_TIMEOUT_LAST_ACK "nf_conntrack_tcp_timeout_last_ack" no longer used */
0677     /* NET_NF_CONNTRACK_TCP_TIMEOUT_TIME_WAIT "nf_conntrack_tcp_timeout_time_wait" no longer used */
0678     /* NET_NF_CONNTRACK_TCP_TIMEOUT_CLOSE "nf_conntrack_tcp_timeout_close" no longer used */
0679     /* NET_NF_CONNTRACK_UDP_TIMEOUT "nf_conntrack_udp_timeout" no longer used */
0680     /* NET_NF_CONNTRACK_UDP_TIMEOUT_STREAM "nf_conntrack_udp_timeout_stream" no longer used */
0681     /* NET_NF_CONNTRACK_ICMP_TIMEOUT "nf_conntrack_icmp_timeout" no longer used */
0682     /* NET_NF_CONNTRACK_GENERIC_TIMEOUT "nf_conntrack_generic_timeout" no longer used */
0683     { CTL_INT,  NET_NF_CONNTRACK_BUCKETS,       "nf_conntrack_buckets" },
0684     { CTL_INT,  NET_NF_CONNTRACK_LOG_INVALID,       "nf_conntrack_log_invalid" },
0685     /* NET_NF_CONNTRACK_TCP_TIMEOUT_MAX_RETRANS "nf_conntrack_tcp_timeout_max_retrans" no longer used */
0686     { CTL_INT,  NET_NF_CONNTRACK_TCP_LOOSE,     "nf_conntrack_tcp_loose" },
0687     { CTL_INT,  NET_NF_CONNTRACK_TCP_BE_LIBERAL,    "nf_conntrack_tcp_be_liberal" },
0688     { CTL_INT,  NET_NF_CONNTRACK_TCP_MAX_RETRANS,   "nf_conntrack_tcp_max_retrans" },
0689     /* NET_NF_CONNTRACK_SCTP_TIMEOUT_CLOSED "nf_conntrack_sctp_timeout_closed" no longer used */
0690     /* NET_NF_CONNTRACK_SCTP_TIMEOUT_COOKIE_WAIT "nf_conntrack_sctp_timeout_cookie_wait" no longer used */
0691     /* NET_NF_CONNTRACK_SCTP_TIMEOUT_COOKIE_ECHOED "nf_conntrack_sctp_timeout_cookie_echoed" no longer used */
0692     /* NET_NF_CONNTRACK_SCTP_TIMEOUT_ESTABLISHED "nf_conntrack_sctp_timeout_established" no longer used */
0693     /* NET_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_SENT "nf_conntrack_sctp_timeout_shutdown_sent" no longer used */
0694     /* NET_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_RECD "nf_conntrack_sctp_timeout_shutdown_recd" no longer used */
0695     /* NET_NF_CONNTRACK_SCTP_TIMEOUT_SHUTDOWN_ACK_SENT "nf_conntrack_sctp_timeout_shutdown_ack_sent" no longer used */
0696     { CTL_INT,  NET_NF_CONNTRACK_COUNT,         "nf_conntrack_count" },
0697     /* NET_NF_CONNTRACK_ICMPV6_TIMEOUT "nf_conntrack_icmpv6_timeout" no longer used */
0698     /* NET_NF_CONNTRACK_FRAG6_TIMEOUT "nf_conntrack_frag6_timeout" no longer used */
0699     { CTL_INT,  NET_NF_CONNTRACK_FRAG6_LOW_THRESH,  "nf_conntrack_frag6_low_thresh" },
0700     { CTL_INT,  NET_NF_CONNTRACK_FRAG6_HIGH_THRESH, "nf_conntrack_frag6_high_thresh" },
0701     { CTL_INT,  NET_NF_CONNTRACK_CHECKSUM,      "nf_conntrack_checksum" },
0702 
0703     {}
0704 };
0705 
0706 static const struct bin_table bin_net_irda_table[] = {
0707     { CTL_INT,  NET_IRDA_DISCOVERY,     "discovery" },
0708     { CTL_STR,  NET_IRDA_DEVNAME,       "devname" },
0709     { CTL_INT,  NET_IRDA_DEBUG,         "debug" },
0710     { CTL_INT,  NET_IRDA_FAST_POLL,     "fast_poll_increase" },
0711     { CTL_INT,  NET_IRDA_DISCOVERY_SLOTS,   "discovery_slots" },
0712     { CTL_INT,  NET_IRDA_DISCOVERY_TIMEOUT, "discovery_timeout" },
0713     { CTL_INT,  NET_IRDA_SLOT_TIMEOUT,      "slot_timeout" },
0714     { CTL_INT,  NET_IRDA_MAX_BAUD_RATE,     "max_baud_rate" },
0715     { CTL_INT,  NET_IRDA_MIN_TX_TURN_TIME,  "min_tx_turn_time" },
0716     { CTL_INT,  NET_IRDA_MAX_TX_DATA_SIZE,  "max_tx_data_size" },
0717     { CTL_INT,  NET_IRDA_MAX_TX_WINDOW,     "max_tx_window" },
0718     { CTL_INT,  NET_IRDA_MAX_NOREPLY_TIME,  "max_noreply_time" },
0719     { CTL_INT,  NET_IRDA_WARN_NOREPLY_TIME, "warn_noreply_time" },
0720     { CTL_INT,  NET_IRDA_LAP_KEEPALIVE_TIME,    "lap_keepalive_time" },
0721     {}
0722 };
0723 
0724 static const struct bin_table bin_net_table[] = {
0725     { CTL_DIR,  NET_CORE,       "core",     bin_net_core_table },
0726     /* NET_ETHER not used */
0727     /* NET_802 not used */
0728     { CTL_DIR,  NET_UNIX,       "unix",     bin_net_unix_table },
0729     { CTL_DIR,  NET_IPV4,       "ipv4",     bin_net_ipv4_table },
0730     { CTL_DIR,  NET_IPX,        "ipx",      bin_net_ipx_table },
0731     { CTL_DIR,  NET_ATALK,      "appletalk",    bin_net_atalk_table },
0732     { CTL_DIR,  NET_NETROM,     "netrom",   bin_net_netrom_table },
0733     { CTL_DIR,  NET_AX25,       "ax25",     bin_net_ax25_table },
0734     /*  NET_BRIDGE "bridge" no longer used */
0735     { CTL_DIR,  NET_ROSE,       "rose",     bin_net_rose_table },
0736     { CTL_DIR,  NET_IPV6,       "ipv6",     bin_net_ipv6_table },
0737     { CTL_DIR,  NET_X25,        "x25",      bin_net_x25_table },
0738     { CTL_DIR,  NET_TR,         "token-ring",   bin_net_tr_table },
0739     { CTL_DIR,  NET_DECNET,     "decnet",   bin_net_decnet_table },
0740     /*  NET_ECONET not used */
0741     { CTL_DIR,  NET_SCTP,       "sctp",     bin_net_sctp_table },
0742     { CTL_DIR,  NET_LLC,        "llc",      bin_net_llc_table },
0743     { CTL_DIR,  NET_NETFILTER,      "netfilter",    bin_net_netfilter_table },
0744     /* NET_DCCP "dccp" no longer used */
0745     { CTL_DIR,  NET_IRDA,       "irda",     bin_net_irda_table },
0746     { CTL_INT,  2089,           "nf_conntrack_max" },
0747     {}
0748 };
0749 
0750 static const struct bin_table bin_fs_quota_table[] = {
0751     { CTL_INT,  FS_DQ_LOOKUPS,      "lookups" },
0752     { CTL_INT,  FS_DQ_DROPS,        "drops" },
0753     { CTL_INT,  FS_DQ_READS,        "reads" },
0754     { CTL_INT,  FS_DQ_WRITES,       "writes" },
0755     { CTL_INT,  FS_DQ_CACHE_HITS,   "cache_hits" },
0756     { CTL_INT,  FS_DQ_ALLOCATED,    "allocated_dquots" },
0757     { CTL_INT,  FS_DQ_FREE,     "free_dquots" },
0758     { CTL_INT,  FS_DQ_SYNCS,        "syncs" },
0759     { CTL_INT,  FS_DQ_WARNINGS,     "warnings" },
0760     {}
0761 };
0762 
0763 static const struct bin_table bin_fs_xfs_table[] = {
0764     { CTL_INT,  XFS_SGID_INHERIT,   "irix_sgid_inherit" },
0765     { CTL_INT,  XFS_SYMLINK_MODE,   "irix_symlink_mode" },
0766     { CTL_INT,  XFS_PANIC_MASK,     "panic_mask" },
0767 
0768     { CTL_INT,  XFS_ERRLEVEL,       "error_level" },
0769     { CTL_INT,  XFS_SYNCD_TIMER,    "xfssyncd_centisecs" },
0770     { CTL_INT,  XFS_INHERIT_SYNC,   "inherit_sync" },
0771     { CTL_INT,  XFS_INHERIT_NODUMP, "inherit_nodump" },
0772     { CTL_INT,  XFS_INHERIT_NOATIME,    "inherit_noatime" },
0773     { CTL_INT,  XFS_BUF_TIMER,      "xfsbufd_centisecs" },
0774     { CTL_INT,  XFS_BUF_AGE,        "age_buffer_centisecs" },
0775     { CTL_INT,  XFS_INHERIT_NOSYM,  "inherit_nosymlinks" },
0776     { CTL_INT,  XFS_ROTORSTEP,  "rotorstep" },
0777     { CTL_INT,  XFS_INHERIT_NODFRG, "inherit_nodefrag" },
0778     { CTL_INT,  XFS_FILESTREAM_TIMER,   "filestream_centisecs" },
0779     { CTL_INT,  XFS_STATS_CLEAR,    "stats_clear" },
0780     {}
0781 };
0782 
0783 static const struct bin_table bin_fs_ocfs2_nm_table[] = {
0784     { CTL_STR,  1, "hb_ctl_path" },
0785     {}
0786 };
0787 
0788 static const struct bin_table bin_fs_ocfs2_table[] = {
0789     { CTL_DIR,  1,  "nm",   bin_fs_ocfs2_nm_table },
0790     {}
0791 };
0792 
0793 static const struct bin_table bin_inotify_table[] = {
0794     { CTL_INT,  INOTIFY_MAX_USER_INSTANCES, "max_user_instances" },
0795     { CTL_INT,  INOTIFY_MAX_USER_WATCHES,   "max_user_watches" },
0796     { CTL_INT,  INOTIFY_MAX_QUEUED_EVENTS,  "max_queued_events" },
0797     {}
0798 };
0799 
0800 static const struct bin_table bin_fs_table[] = {
0801     { CTL_INT,  FS_NRINODE,     "inode-nr" },
0802     { CTL_INT,  FS_STATINODE,       "inode-state" },
0803     /* FS_MAXINODE unused */
0804     /* FS_NRDQUOT unused */
0805     /* FS_MAXDQUOT unused */
0806     /* FS_NRFILE "file-nr" no longer used */
0807     { CTL_INT,  FS_MAXFILE,     "file-max" },
0808     { CTL_INT,  FS_DENTRY,      "dentry-state" },
0809     /* FS_NRSUPER unused */
0810     /* FS_MAXUPSER unused */
0811     { CTL_INT,  FS_OVERFLOWUID,     "overflowuid" },
0812     { CTL_INT,  FS_OVERFLOWGID,     "overflowgid" },
0813     { CTL_INT,  FS_LEASES,      "leases-enable" },
0814     { CTL_INT,  FS_DIR_NOTIFY,      "dir-notify-enable" },
0815     { CTL_INT,  FS_LEASE_TIME,      "lease-break-time" },
0816     { CTL_DIR,  FS_DQSTATS,     "quota",    bin_fs_quota_table },
0817     { CTL_DIR,  FS_XFS,         "xfs",      bin_fs_xfs_table },
0818     { CTL_ULONG,    FS_AIO_NR,      "aio-nr" },
0819     { CTL_ULONG,    FS_AIO_MAX_NR,      "aio-max-nr" },
0820     { CTL_DIR,  FS_INOTIFY,     "inotify",  bin_inotify_table },
0821     { CTL_DIR,  FS_OCFS2,       "ocfs2",    bin_fs_ocfs2_table },
0822     { CTL_INT,  KERN_SETUID_DUMPABLE,   "suid_dumpable" },
0823     {}
0824 };
0825 
0826 static const struct bin_table bin_ipmi_table[] = {
0827     { CTL_INT,  DEV_IPMI_POWEROFF_POWERCYCLE,   "poweroff_powercycle" },
0828     {}
0829 };
0830 
0831 static const struct bin_table bin_mac_hid_files[] = {
0832     /* DEV_MAC_HID_KEYBOARD_SENDS_LINUX_KEYCODES unused */
0833     /* DEV_MAC_HID_KEYBOARD_LOCK_KEYCODES unused */
0834     { CTL_INT,  DEV_MAC_HID_MOUSE_BUTTON_EMULATION, "mouse_button_emulation" },
0835     { CTL_INT,  DEV_MAC_HID_MOUSE_BUTTON2_KEYCODE,  "mouse_button2_keycode" },
0836     { CTL_INT,  DEV_MAC_HID_MOUSE_BUTTON3_KEYCODE,  "mouse_button3_keycode" },
0837     /* DEV_MAC_HID_ADB_MOUSE_SENDS_KEYCODES unused */
0838     {}
0839 };
0840 
0841 static const struct bin_table bin_raid_table[] = {
0842     { CTL_INT,  DEV_RAID_SPEED_LIMIT_MIN,   "speed_limit_min" },
0843     { CTL_INT,  DEV_RAID_SPEED_LIMIT_MAX,   "speed_limit_max" },
0844     {}
0845 };
0846 
0847 static const struct bin_table bin_scsi_table[] = {
0848     { CTL_INT, DEV_SCSI_LOGGING_LEVEL, "logging_level" },
0849     {}
0850 };
0851 
0852 static const struct bin_table bin_dev_table[] = {
0853     /* DEV_CDROM    "cdrom" no longer used */
0854     /* DEV_HWMON unused */
0855     /* DEV_PARPORT  "parport" no longer used */
0856     { CTL_DIR,  DEV_RAID,   "raid",     bin_raid_table },
0857     { CTL_DIR,  DEV_MAC_HID,    "mac_hid",  bin_mac_hid_files },
0858     { CTL_DIR,  DEV_SCSI,   "scsi",     bin_scsi_table },
0859     { CTL_DIR,  DEV_IPMI,   "ipmi",     bin_ipmi_table },
0860     {}
0861 };
0862 
0863 static const struct bin_table bin_bus_isa_table[] = {
0864     { CTL_INT,  BUS_ISA_MEM_BASE,   "membase" },
0865     { CTL_INT,  BUS_ISA_PORT_BASE,  "portbase" },
0866     { CTL_INT,  BUS_ISA_PORT_SHIFT, "portshift" },
0867     {}
0868 };
0869 
0870 static const struct bin_table bin_bus_table[] = {
0871     { CTL_DIR,  CTL_BUS_ISA,    "isa",  bin_bus_isa_table },
0872     {}
0873 };
0874 
0875 
0876 static const struct bin_table bin_s390dbf_table[] = {
0877     { CTL_INT,  5678 /* CTL_S390DBF_STOPPABLE */, "debug_stoppable" },
0878     { CTL_INT,  5679 /* CTL_S390DBF_ACTIVE */,    "debug_active" },
0879     {}
0880 };
0881 
0882 static const struct bin_table bin_sunrpc_table[] = {
0883     /* CTL_RPCDEBUG "rpc_debug"  no longer used */
0884     /* CTL_NFSDEBUG "nfs_debug"  no longer used */
0885     /* CTL_NFSDDEBUG "nfsd_debug" no longer used  */
0886     /* CTL_NLMDEBUG "nlm_debug" no longer used */
0887 
0888     { CTL_INT,  CTL_SLOTTABLE_UDP,  "udp_slot_table_entries" },
0889     { CTL_INT,  CTL_SLOTTABLE_TCP,  "tcp_slot_table_entries" },
0890     { CTL_INT,  CTL_MIN_RESVPORT,   "min_resvport" },
0891     { CTL_INT,  CTL_MAX_RESVPORT,   "max_resvport" },
0892     {}
0893 };
0894 
0895 static const struct bin_table bin_pm_table[] = {
0896     /* frv specific */
0897     /* 1 == CTL_PM_SUSPEND  "suspend"  no longer used" */
0898     { CTL_INT,  2 /* CTL_PM_CMODE */,       "cmode" },
0899     { CTL_INT,  3 /* CTL_PM_P0 */,      "p0" },
0900     { CTL_INT,  4 /* CTL_PM_CM */,      "cm" },
0901     {}
0902 };
0903 
0904 static const struct bin_table bin_root_table[] = {
0905     { CTL_DIR,  CTL_KERN,   "kernel",   bin_kern_table },
0906     { CTL_DIR,  CTL_VM,     "vm",       bin_vm_table },
0907     { CTL_DIR,  CTL_NET,    "net",      bin_net_table },
0908     /* CTL_PROC not used */
0909     { CTL_DIR,  CTL_FS,     "fs",       bin_fs_table },
0910     /* CTL_DEBUG "debug" no longer used */
0911     { CTL_DIR,  CTL_DEV,    "dev",      bin_dev_table },
0912     { CTL_DIR,  CTL_BUS,    "bus",      bin_bus_table },
0913     { CTL_DIR,  CTL_ABI,    "abi" },
0914     /* CTL_CPU not used */
0915     /* CTL_ARLAN "arlan" no longer used */
0916     { CTL_DIR,  CTL_S390DBF,    "s390dbf",  bin_s390dbf_table },
0917     { CTL_DIR,  CTL_SUNRPC, "sunrpc",   bin_sunrpc_table },
0918     { CTL_DIR,  CTL_PM,     "pm",       bin_pm_table },
0919     {}
0920 };
0921 
0922 static ssize_t bin_dir(struct file *file,
0923     void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
0924 {
0925     return -ENOTDIR;
0926 }
0927 
0928 
0929 static ssize_t bin_string(struct file *file,
0930     void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
0931 {
0932     ssize_t result, copied = 0;
0933 
0934     if (oldval && oldlen) {
0935         char __user *lastp;
0936         loff_t pos = 0;
0937         int ch;
0938 
0939         result = vfs_read(file, oldval, oldlen, &pos);
0940         if (result < 0)
0941             goto out;
0942 
0943         copied = result;
0944         lastp = oldval + copied - 1;
0945 
0946         result = -EFAULT;
0947         if (get_user(ch, lastp))
0948             goto out;
0949 
0950         /* Trim off the trailing newline */
0951         if (ch == '\n') {
0952             result = -EFAULT;
0953             if (put_user('\0', lastp))
0954                 goto out;
0955             copied -= 1;
0956         }
0957     }
0958 
0959     if (newval && newlen) {
0960         loff_t pos = 0;
0961 
0962         result = vfs_write(file, newval, newlen, &pos);
0963         if (result < 0)
0964             goto out;
0965     }
0966 
0967     result = copied;
0968 out:
0969     return result;
0970 }
0971 
0972 static ssize_t bin_intvec(struct file *file,
0973     void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
0974 {
0975     ssize_t copied = 0;
0976     char *buffer;
0977     ssize_t result;
0978 
0979     result = -ENOMEM;
0980     buffer = kmalloc(BUFSZ, GFP_KERNEL);
0981     if (!buffer)
0982         goto out;
0983 
0984     if (oldval && oldlen) {
0985         unsigned __user *vec = oldval;
0986         size_t length = oldlen / sizeof(*vec);
0987         char *str, *end;
0988         int i;
0989 
0990         result = kernel_read(file, 0, buffer, BUFSZ - 1);
0991         if (result < 0)
0992             goto out_kfree;
0993 
0994         str = buffer;
0995         end = str + result;
0996         *end++ = '\0';
0997         for (i = 0; i < length; i++) {
0998             unsigned long value;
0999 
1000             value = simple_strtoul(str, &str, 10);
1001             while (isspace(*str))
1002                 str++;
1003             
1004             result = -EFAULT;
1005             if (put_user(value, vec + i))
1006                 goto out_kfree;
1007 
1008             copied += sizeof(*vec);
1009             if (!isdigit(*str))
1010                 break;
1011         }
1012     }
1013 
1014     if (newval && newlen) {
1015         unsigned __user *vec = newval;
1016         size_t length = newlen / sizeof(*vec);
1017         char *str, *end;
1018         int i;
1019 
1020         str = buffer;
1021         end = str + BUFSZ;
1022         for (i = 0; i < length; i++) {
1023             unsigned long value;
1024 
1025             result = -EFAULT;
1026             if (get_user(value, vec + i))
1027                 goto out_kfree;
1028 
1029             str += scnprintf(str, end - str, "%lu\t", value);
1030         }
1031 
1032         result = kernel_write(file, buffer, str - buffer, 0);
1033         if (result < 0)
1034             goto out_kfree;
1035     }
1036     result = copied;
1037 out_kfree:
1038     kfree(buffer);
1039 out:
1040     return result;
1041 }
1042 
1043 static ssize_t bin_ulongvec(struct file *file,
1044     void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
1045 {
1046     ssize_t copied = 0;
1047     char *buffer;
1048     ssize_t result;
1049 
1050     result = -ENOMEM;
1051     buffer = kmalloc(BUFSZ, GFP_KERNEL);
1052     if (!buffer)
1053         goto out;
1054 
1055     if (oldval && oldlen) {
1056         unsigned long __user *vec = oldval;
1057         size_t length = oldlen / sizeof(*vec);
1058         char *str, *end;
1059         int i;
1060 
1061         result = kernel_read(file, 0, buffer, BUFSZ - 1);
1062         if (result < 0)
1063             goto out_kfree;
1064 
1065         str = buffer;
1066         end = str + result;
1067         *end++ = '\0';
1068         for (i = 0; i < length; i++) {
1069             unsigned long value;
1070 
1071             value = simple_strtoul(str, &str, 10);
1072             while (isspace(*str))
1073                 str++;
1074             
1075             result = -EFAULT;
1076             if (put_user(value, vec + i))
1077                 goto out_kfree;
1078 
1079             copied += sizeof(*vec);
1080             if (!isdigit(*str))
1081                 break;
1082         }
1083     }
1084 
1085     if (newval && newlen) {
1086         unsigned long __user *vec = newval;
1087         size_t length = newlen / sizeof(*vec);
1088         char *str, *end;
1089         int i;
1090 
1091         str = buffer;
1092         end = str + BUFSZ;
1093         for (i = 0; i < length; i++) {
1094             unsigned long value;
1095 
1096             result = -EFAULT;
1097             if (get_user(value, vec + i))
1098                 goto out_kfree;
1099 
1100             str += scnprintf(str, end - str, "%lu\t", value);
1101         }
1102 
1103         result = kernel_write(file, buffer, str - buffer, 0);
1104         if (result < 0)
1105             goto out_kfree;
1106     }
1107     result = copied;
1108 out_kfree:
1109     kfree(buffer);
1110 out:
1111     return result;
1112 }
1113 
1114 static ssize_t bin_uuid(struct file *file,
1115     void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
1116 {
1117     ssize_t result, copied = 0;
1118 
1119     /* Only supports reads */
1120     if (oldval && oldlen) {
1121         char buf[UUID_STRING_LEN + 1];
1122         uuid_be uuid;
1123 
1124         result = kernel_read(file, 0, buf, sizeof(buf) - 1);
1125         if (result < 0)
1126             goto out;
1127 
1128         buf[result] = '\0';
1129 
1130         result = -EIO;
1131         if (uuid_be_to_bin(buf, &uuid))
1132             goto out;
1133 
1134         if (oldlen > 16)
1135             oldlen = 16;
1136 
1137         result = -EFAULT;
1138         if (copy_to_user(oldval, &uuid, oldlen))
1139             goto out;
1140 
1141         copied = oldlen;
1142     }
1143     result = copied;
1144 out:
1145     return result;
1146 }
1147 
1148 static ssize_t bin_dn_node_address(struct file *file,
1149     void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
1150 {
1151     ssize_t result, copied = 0;
1152 
1153     if (oldval && oldlen) {
1154         char buf[15], *nodep;
1155         unsigned long area, node;
1156         __le16 dnaddr;
1157 
1158         result = kernel_read(file, 0, buf, sizeof(buf) - 1);
1159         if (result < 0)
1160             goto out;
1161 
1162         buf[result] = '\0';
1163 
1164         /* Convert the decnet address to binary */
1165         result = -EIO;
1166         nodep = strchr(buf, '.');
1167         if (!nodep)
1168             goto out;
1169         ++nodep;
1170 
1171         area = simple_strtoul(buf, NULL, 10);
1172         node = simple_strtoul(nodep, NULL, 10);
1173 
1174         result = -EIO;
1175         if ((area > 63)||(node > 1023))
1176             goto out;
1177 
1178         dnaddr = cpu_to_le16((area << 10) | node);
1179 
1180         result = -EFAULT;
1181         if (put_user(dnaddr, (__le16 __user *)oldval))
1182             goto out;
1183 
1184         copied = sizeof(dnaddr);
1185     }
1186 
1187     if (newval && newlen) {
1188         __le16 dnaddr;
1189         char buf[15];
1190         int len;
1191 
1192         result = -EINVAL;
1193         if (newlen != sizeof(dnaddr))
1194             goto out;
1195 
1196         result = -EFAULT;
1197         if (get_user(dnaddr, (__le16 __user *)newval))
1198             goto out;
1199 
1200         len = scnprintf(buf, sizeof(buf), "%hu.%hu",
1201                 le16_to_cpu(dnaddr) >> 10,
1202                 le16_to_cpu(dnaddr) & 0x3ff);
1203 
1204         result = kernel_write(file, buf, len, 0);
1205         if (result < 0)
1206             goto out;
1207     }
1208 
1209     result = copied;
1210 out:
1211     return result;
1212 }
1213 
1214 static const struct bin_table *get_sysctl(const int *name, int nlen, char *path)
1215 {
1216     const struct bin_table *table = &bin_root_table[0];
1217     int ctl_name;
1218 
1219     /* The binary sysctl tables have a small maximum depth so
1220      * there is no danger of overflowing our path as it PATH_MAX
1221      * bytes long.
1222      */
1223     memcpy(path, "sys/", 4);
1224     path += 4;
1225 
1226 repeat:
1227     if (!nlen)
1228         return ERR_PTR(-ENOTDIR);
1229     ctl_name = *name;
1230     name++;
1231     nlen--;
1232     for ( ; table->convert; table++) {
1233         int len = 0;
1234 
1235         /*
1236          * For a wild card entry map from ifindex to network
1237          * device name.
1238          */
1239         if (!table->ctl_name) {
1240 #ifdef CONFIG_NET
1241             struct net *net = current->nsproxy->net_ns;
1242             struct net_device *dev;
1243             dev = dev_get_by_index(net, ctl_name);
1244             if (dev) {
1245                 len = strlen(dev->name);
1246                 memcpy(path, dev->name, len);
1247                 dev_put(dev);
1248             }
1249 #endif
1250         /* Use the well known sysctl number to proc name mapping */
1251         } else if (ctl_name == table->ctl_name) {
1252             len = strlen(table->procname);
1253             memcpy(path, table->procname, len);
1254         }
1255         if (len) {
1256             path += len;
1257             if (table->child) {
1258                 *path++ = '/';
1259                 table = table->child;
1260                 goto repeat;
1261             }
1262             *path = '\0';
1263             return table;
1264         }
1265     }
1266     return ERR_PTR(-ENOTDIR);
1267 }
1268 
1269 static char *sysctl_getname(const int *name, int nlen, const struct bin_table **tablep)
1270 {
1271     char *tmp, *result;
1272 
1273     result = ERR_PTR(-ENOMEM);
1274     tmp = __getname();
1275     if (tmp) {
1276         const struct bin_table *table = get_sysctl(name, nlen, tmp);
1277         result = tmp;
1278         *tablep = table;
1279         if (IS_ERR(table)) {
1280             __putname(tmp);
1281             result = ERR_CAST(table);
1282         }
1283     }
1284     return result;
1285 }
1286 
1287 static ssize_t binary_sysctl(const int *name, int nlen,
1288     void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
1289 {
1290     const struct bin_table *table = NULL;
1291     struct vfsmount *mnt;
1292     struct file *file;
1293     ssize_t result;
1294     char *pathname;
1295     int flags;
1296 
1297     pathname = sysctl_getname(name, nlen, &table);
1298     result = PTR_ERR(pathname);
1299     if (IS_ERR(pathname))
1300         goto out;
1301 
1302     /* How should the sysctl be accessed? */
1303     if (oldval && oldlen && newval && newlen) {
1304         flags = O_RDWR;
1305     } else if (newval && newlen) {
1306         flags = O_WRONLY;
1307     } else if (oldval && oldlen) {
1308         flags = O_RDONLY;
1309     } else {
1310         result = 0;
1311         goto out_putname;
1312     }
1313 
1314     mnt = task_active_pid_ns(current)->proc_mnt;
1315     file = file_open_root(mnt->mnt_root, mnt, pathname, flags, 0);
1316     result = PTR_ERR(file);
1317     if (IS_ERR(file))
1318         goto out_putname;
1319 
1320     result = table->convert(file, oldval, oldlen, newval, newlen);
1321 
1322     fput(file);
1323 out_putname:
1324     __putname(pathname);
1325 out:
1326     return result;
1327 }
1328 
1329 
1330 #else /* CONFIG_SYSCTL_SYSCALL */
1331 
1332 static ssize_t binary_sysctl(const int *name, int nlen,
1333     void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
1334 {
1335     return -ENOSYS;
1336 }
1337 
1338 #endif /* CONFIG_SYSCTL_SYSCALL */
1339 
1340 
1341 static void deprecated_sysctl_warning(const int *name, int nlen)
1342 {
1343     int i;
1344 
1345     /*
1346      * CTL_KERN/KERN_VERSION is used by older glibc and cannot
1347      * ever go away.
1348      */
1349     if (name[0] == CTL_KERN && name[1] == KERN_VERSION)
1350         return;
1351 
1352     if (printk_ratelimit()) {
1353         printk(KERN_INFO
1354             "warning: process `%s' used the deprecated sysctl "
1355             "system call with ", current->comm);
1356         for (i = 0; i < nlen; i++)
1357             printk(KERN_CONT "%d.", name[i]);
1358         printk(KERN_CONT "\n");
1359     }
1360     return;
1361 }
1362 
1363 #define WARN_ONCE_HASH_BITS 8
1364 #define WARN_ONCE_HASH_SIZE (1<<WARN_ONCE_HASH_BITS)
1365 
1366 static DECLARE_BITMAP(warn_once_bitmap, WARN_ONCE_HASH_SIZE);
1367 
1368 #define FNV32_OFFSET 2166136261U
1369 #define FNV32_PRIME 0x01000193
1370 
1371 /*
1372  * Print each legacy sysctl (approximately) only once.
1373  * To avoid making the tables non-const use a external
1374  * hash-table instead.
1375  * Worst case hash collision: 6, but very rarely.
1376  * NOTE! We don't use the SMP-safe bit tests. We simply
1377  * don't care enough.
1378  */
1379 static void warn_on_bintable(const int *name, int nlen)
1380 {
1381     int i;
1382     u32 hash = FNV32_OFFSET;
1383 
1384     for (i = 0; i < nlen; i++)
1385         hash = (hash ^ name[i]) * FNV32_PRIME;
1386     hash %= WARN_ONCE_HASH_SIZE;
1387     if (__test_and_set_bit(hash, warn_once_bitmap))
1388         return;
1389     deprecated_sysctl_warning(name, nlen);
1390 }
1391 
1392 static ssize_t do_sysctl(int __user *args_name, int nlen,
1393     void __user *oldval, size_t oldlen, void __user *newval, size_t newlen)
1394 {
1395     int name[CTL_MAXNAME];
1396     int i;
1397 
1398     /* Check args->nlen. */
1399     if (nlen < 0 || nlen > CTL_MAXNAME)
1400         return -ENOTDIR;
1401     /* Read in the sysctl name for simplicity */
1402     for (i = 0; i < nlen; i++)
1403         if (get_user(name[i], args_name + i))
1404             return -EFAULT;
1405 
1406     warn_on_bintable(name, nlen);
1407 
1408     return binary_sysctl(name, nlen, oldval, oldlen, newval, newlen);
1409 }
1410 
1411 SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
1412 {
1413     struct __sysctl_args tmp;
1414     size_t oldlen = 0;
1415     ssize_t result;
1416 
1417     if (copy_from_user(&tmp, args, sizeof(tmp)))
1418         return -EFAULT;
1419 
1420     if (tmp.oldval && !tmp.oldlenp)
1421         return -EFAULT;
1422 
1423     if (tmp.oldlenp && get_user(oldlen, tmp.oldlenp))
1424         return -EFAULT;
1425 
1426     result = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, oldlen,
1427                tmp.newval, tmp.newlen);
1428 
1429     if (result >= 0) {
1430         oldlen = result;
1431         result = 0;
1432     }
1433 
1434     if (tmp.oldlenp && put_user(oldlen, tmp.oldlenp))
1435         return -EFAULT;
1436 
1437     return result;
1438 }
1439 
1440 
1441 #ifdef CONFIG_COMPAT
1442 
1443 struct compat_sysctl_args {
1444     compat_uptr_t   name;
1445     int     nlen;
1446     compat_uptr_t   oldval;
1447     compat_uptr_t   oldlenp;
1448     compat_uptr_t   newval;
1449     compat_size_t   newlen;
1450     compat_ulong_t  __unused[4];
1451 };
1452 
1453 COMPAT_SYSCALL_DEFINE1(sysctl, struct compat_sysctl_args __user *, args)
1454 {
1455     struct compat_sysctl_args tmp;
1456     compat_size_t __user *compat_oldlenp;
1457     size_t oldlen = 0;
1458     ssize_t result;
1459 
1460     if (copy_from_user(&tmp, args, sizeof(tmp)))
1461         return -EFAULT;
1462 
1463     if (tmp.oldval && !tmp.oldlenp)
1464         return -EFAULT;
1465 
1466     compat_oldlenp = compat_ptr(tmp.oldlenp);
1467     if (compat_oldlenp && get_user(oldlen, compat_oldlenp))
1468         return -EFAULT;
1469 
1470     result = do_sysctl(compat_ptr(tmp.name), tmp.nlen,
1471                compat_ptr(tmp.oldval), oldlen,
1472                compat_ptr(tmp.newval), tmp.newlen);
1473 
1474     if (result >= 0) {
1475         oldlen = result;
1476         result = 0;
1477     }
1478 
1479     if (compat_oldlenp && put_user(oldlen, compat_oldlenp))
1480         return -EFAULT;
1481 
1482     return result;
1483 }
1484 
1485 #endif /* CONFIG_COMPAT */