Blame view
net/sysctl_net.c
2.44 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 5 6 |
/* -*- linux-c -*- * sysctl_net.c: sysctl interface to net subsystem. * * Begun April 1, 1996, Mike Shaver. * Added /proc/sys/net directories for each protocol family. [MS] * |
1da177e4c Linux-2.6.12-rc2 |
7 8 9 10 11 12 |
* Revision 1.2 1996/05/08 20:24:40 shaver * Added bits for NET_BRIDGE and the NET_IPV4_ARP stuff and * NET_IPV4_IP_FORWARD. * * */ |
1da177e4c Linux-2.6.12-rc2 |
13 |
#include <linux/mm.h> |
bc3b2d7fb net: Add export.h... |
14 |
#include <linux/export.h> |
1da177e4c Linux-2.6.12-rc2 |
15 |
#include <linux/sysctl.h> |
95bdfccb2 [NET]: Implement ... |
16 |
#include <linux/nsproxy.h> |
1da177e4c Linux-2.6.12-rc2 |
17 |
|
496a22b08 [NET]: Fix "sysct... |
18 |
#include <net/sock.h> |
1da177e4c Linux-2.6.12-rc2 |
19 |
#ifdef CONFIG_INET |
20380731b [NET]: Fix sparse... |
20 |
#include <net/ip.h> |
1da177e4c Linux-2.6.12-rc2 |
21 |
#endif |
1da177e4c Linux-2.6.12-rc2 |
22 |
#ifdef CONFIG_NET |
20380731b [NET]: Fix sparse... |
23 |
#include <linux/if_ether.h> |
1da177e4c Linux-2.6.12-rc2 |
24 |
#endif |
734550921 [PATCH] beginning... |
25 |
static struct ctl_table_set * |
95bdfccb2 [NET]: Implement ... |
26 27 |
net_ctl_header_lookup(struct ctl_table_root *root, struct nsproxy *namespaces) { |
734550921 [PATCH] beginning... |
28 29 30 31 32 33 |
return &namespaces->net_ns->sysctls; } static int is_seen(struct ctl_table_set *set) { return ¤t->nsproxy->net_ns->sysctls == set; |
95bdfccb2 [NET]: Implement ... |
34 |
} |
4ecb90090 sysctl: allow ove... |
35 36 37 38 39 40 41 42 43 44 45 46 |
/* Return standard mode bits for table entry. */ static int net_ctl_permissions(struct ctl_table_root *root, struct nsproxy *nsproxy, struct ctl_table *table) { /* Allow network administrator to have same access as root. */ if (capable(CAP_NET_ADMIN)) { int mode = (table->mode >> 6) & 7; return (mode << 6) | (mode << 3) | mode; } return table->mode; } |
95bdfccb2 [NET]: Implement ... |
47 48 |
static struct ctl_table_root net_sysctl_root = { .lookup = net_ctl_header_lookup, |
4ecb90090 sysctl: allow ove... |
49 |
.permissions = net_ctl_permissions, |
95bdfccb2 [NET]: Implement ... |
50 |
}; |
2c8c1e729 net: spread __net... |
51 |
static int __net_init sysctl_net_init(struct net *net) |
95bdfccb2 [NET]: Implement ... |
52 |
{ |
9eb47c26f sysctl: Add a roo... |
53 |
setup_sysctl_set(&net->sysctls, &net_sysctl_root, is_seen); |
95bdfccb2 [NET]: Implement ... |
54 55 |
return 0; } |
2c8c1e729 net: spread __net... |
56 |
static void __net_exit sysctl_net_exit(struct net *net) |
95bdfccb2 [NET]: Implement ... |
57 |
{ |
97324cd80 sysctl: Implement... |
58 |
retire_sysctl_set(&net->sysctls); |
95bdfccb2 [NET]: Implement ... |
59 60 61 62 63 64 |
} static struct pernet_operations sysctl_pernet_ops = { .init = sysctl_net_init, .exit = sysctl_net_exit, }; |
bc8a36942 net sysctl: Regis... |
65 |
static struct ctl_table_header *net_header; |
2ca794e5e net sysctl: Initi... |
66 |
__init int net_sysctl_init(void) |
95bdfccb2 [NET]: Implement ... |
67 |
{ |
bc8a36942 net sysctl: Regis... |
68 69 70 71 72 73 74 75 76 |
static struct ctl_table empty[1]; int ret = -ENOMEM; /* Avoid limitations in the sysctl implementation by * registering "/proc/sys/net" as an empty directory not in a * network namespace. */ net_header = register_sysctl("net", empty); if (!net_header) goto out; |
95bdfccb2 [NET]: Implement ... |
77 78 79 |
ret = register_pernet_subsys(&sysctl_pernet_ops); if (ret) goto out; |
bd295b56c sysctl: Remove th... |
80 |
register_sysctl_root(&net_sysctl_root); |
95bdfccb2 [NET]: Implement ... |
81 82 83 |
out: return ret; } |
95bdfccb2 [NET]: Implement ... |
84 |
|
ab41a2ca5 net: Implement re... |
85 86 87 88 89 90 |
struct ctl_table_header *register_net_sysctl(struct net *net, const char *path, struct ctl_table *table) { return __register_sysctl_table(&net->sysctls, path, table); } EXPORT_SYMBOL_GPL(register_net_sysctl); |
95bdfccb2 [NET]: Implement ... |
91 92 |
void unregister_net_sysctl_table(struct ctl_table_header *header) { |
ab59859de net: fix returnin... |
93 |
unregister_sysctl_table(header); |
95bdfccb2 [NET]: Implement ... |
94 95 |
} EXPORT_SYMBOL_GPL(unregister_net_sysctl_table); |