diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2012-01-08 03:02:37 -0500 |
---|---|---|
committer | Eric W. Biederman <ebiederm@xmission.com> | 2012-01-24 19:40:30 -0500 |
commit | 60a47a2e823cbe6b609346bffff61a00c0c76470 (patch) | |
tree | b19ac63068757893d6f110cf31d27fb59942d005 | |
parent | 0e47c99d7fe25e0f3907d9f3401079169d904891 (diff) |
sysctl: Modify __register_sysctl_paths to take a set instead of a root and an nsproxy
An nsproxy argument here has always been awkard and now the nsproxy argument
is completely unnecessary so remove it, replacing it with the set we want
the registered tables to show up in.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
-rw-r--r-- | fs/proc/proc_sysctl.c | 30 | ||||
-rw-r--r-- | include/linux/sysctl.h | 4 | ||||
-rw-r--r-- | net/sysctl_net.c | 10 |
3 files changed, 17 insertions, 27 deletions
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index ec54a57c4690..e0d3e7e59cbd 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c | |||
@@ -1084,8 +1084,7 @@ out: | |||
1084 | 1084 | ||
1085 | /** | 1085 | /** |
1086 | * __register_sysctl_table - register a leaf sysctl table | 1086 | * __register_sysctl_table - register a leaf sysctl table |
1087 | * @root: List of sysctl headers to register on | 1087 | * @set: Sysctl tree to register on |
1088 | * @namespaces: Data to compute which lists of sysctl entries are visible | ||
1089 | * @path: The path to the directory the sysctl table is in. | 1088 | * @path: The path to the directory the sysctl table is in. |
1090 | * @table: the top-level table structure | 1089 | * @table: the top-level table structure |
1091 | * | 1090 | * |
@@ -1126,26 +1125,24 @@ out: | |||
1126 | * to the table header on success. | 1125 | * to the table header on success. |
1127 | */ | 1126 | */ |
1128 | struct ctl_table_header *__register_sysctl_table( | 1127 | struct ctl_table_header *__register_sysctl_table( |
1129 | struct ctl_table_root *root, | 1128 | struct ctl_table_set *set, |
1130 | struct nsproxy *namespaces, | ||
1131 | const char *path, struct ctl_table *table) | 1129 | const char *path, struct ctl_table *table) |
1132 | { | 1130 | { |
1131 | struct ctl_table_root *root = set->dir.header.root; | ||
1133 | struct ctl_table_header *links = NULL; | 1132 | struct ctl_table_header *links = NULL; |
1134 | struct ctl_table_header *header; | 1133 | struct ctl_table_header *header; |
1135 | const char *name, *nextname; | 1134 | const char *name, *nextname; |
1136 | struct ctl_table_set *set; | ||
1137 | struct ctl_dir *dir; | 1135 | struct ctl_dir *dir; |
1138 | 1136 | ||
1139 | header = kzalloc(sizeof(struct ctl_table_header), GFP_KERNEL); | 1137 | header = kzalloc(sizeof(struct ctl_table_header), GFP_KERNEL); |
1140 | if (!header) | 1138 | if (!header) |
1141 | return NULL; | 1139 | return NULL; |
1142 | 1140 | ||
1143 | init_header(header, root, NULL, table); | 1141 | init_header(header, root, set, table); |
1144 | if (sysctl_check_table(path, table)) | 1142 | if (sysctl_check_table(path, table)) |
1145 | goto fail; | 1143 | goto fail; |
1146 | 1144 | ||
1147 | spin_lock(&sysctl_lock); | 1145 | spin_lock(&sysctl_lock); |
1148 | header->set = set = lookup_header_set(root, namespaces); | ||
1149 | dir = &set->dir; | 1146 | dir = &set->dir; |
1150 | dir->header.nreg++; | 1147 | dir->header.nreg++; |
1151 | spin_unlock(&sysctl_lock); | 1148 | spin_unlock(&sysctl_lock); |
@@ -1223,8 +1220,7 @@ static int count_subheaders(struct ctl_table *table) | |||
1223 | } | 1220 | } |
1224 | 1221 | ||
1225 | static int register_leaf_sysctl_tables(const char *path, char *pos, | 1222 | static int register_leaf_sysctl_tables(const char *path, char *pos, |
1226 | struct ctl_table_header ***subheader, | 1223 | struct ctl_table_header ***subheader, struct ctl_table_set *set, |
1227 | struct ctl_table_root *root, struct nsproxy *namespaces, | ||
1228 | struct ctl_table *table) | 1224 | struct ctl_table *table) |
1229 | { | 1225 | { |
1230 | struct ctl_table *ctl_table_arg = NULL; | 1226 | struct ctl_table *ctl_table_arg = NULL; |
@@ -1261,7 +1257,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos, | |||
1261 | /* Register everything except a directory full of subdirectories */ | 1257 | /* Register everything except a directory full of subdirectories */ |
1262 | if (nr_files || !nr_dirs) { | 1258 | if (nr_files || !nr_dirs) { |
1263 | struct ctl_table_header *header; | 1259 | struct ctl_table_header *header; |
1264 | header = __register_sysctl_table(root, namespaces, path, files); | 1260 | header = __register_sysctl_table(set, path, files); |
1265 | if (!header) { | 1261 | if (!header) { |
1266 | kfree(ctl_table_arg); | 1262 | kfree(ctl_table_arg); |
1267 | goto out; | 1263 | goto out; |
@@ -1286,7 +1282,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos, | |||
1286 | goto out; | 1282 | goto out; |
1287 | 1283 | ||
1288 | err = register_leaf_sysctl_tables(path, child_pos, subheader, | 1284 | err = register_leaf_sysctl_tables(path, child_pos, subheader, |
1289 | root, namespaces, entry->child); | 1285 | set, entry->child); |
1290 | pos[0] = '\0'; | 1286 | pos[0] = '\0'; |
1291 | if (err) | 1287 | if (err) |
1292 | goto out; | 1288 | goto out; |
@@ -1299,8 +1295,7 @@ out: | |||
1299 | 1295 | ||
1300 | /** | 1296 | /** |
1301 | * __register_sysctl_paths - register a sysctl table hierarchy | 1297 | * __register_sysctl_paths - register a sysctl table hierarchy |
1302 | * @root: List of sysctl headers to register on | 1298 | * @set: Sysctl tree to register on |
1303 | * @namespaces: Data to compute which lists of sysctl entries are visible | ||
1304 | * @path: The path to the directory the sysctl table is in. | 1299 | * @path: The path to the directory the sysctl table is in. |
1305 | * @table: the top-level table structure | 1300 | * @table: the top-level table structure |
1306 | * | 1301 | * |
@@ -1310,8 +1305,7 @@ out: | |||
1310 | * See __register_sysctl_table for more details. | 1305 | * See __register_sysctl_table for more details. |
1311 | */ | 1306 | */ |
1312 | struct ctl_table_header *__register_sysctl_paths( | 1307 | struct ctl_table_header *__register_sysctl_paths( |
1313 | struct ctl_table_root *root, | 1308 | struct ctl_table_set *set, |
1314 | struct nsproxy *namespaces, | ||
1315 | const struct ctl_path *path, struct ctl_table *table) | 1309 | const struct ctl_path *path, struct ctl_table *table) |
1316 | { | 1310 | { |
1317 | struct ctl_table *ctl_table_arg = table; | 1311 | struct ctl_table *ctl_table_arg = table; |
@@ -1337,7 +1331,7 @@ struct ctl_table_header *__register_sysctl_paths( | |||
1337 | table = table->child; | 1331 | table = table->child; |
1338 | } | 1332 | } |
1339 | if (nr_subheaders == 1) { | 1333 | if (nr_subheaders == 1) { |
1340 | header = __register_sysctl_table(root, namespaces, new_path, table); | 1334 | header = __register_sysctl_table(set, new_path, table); |
1341 | if (header) | 1335 | if (header) |
1342 | header->ctl_table_arg = ctl_table_arg; | 1336 | header->ctl_table_arg = ctl_table_arg; |
1343 | } else { | 1337 | } else { |
@@ -1351,7 +1345,7 @@ struct ctl_table_header *__register_sysctl_paths( | |||
1351 | header->ctl_table_arg = ctl_table_arg; | 1345 | header->ctl_table_arg = ctl_table_arg; |
1352 | 1346 | ||
1353 | if (register_leaf_sysctl_tables(new_path, pos, &subheader, | 1347 | if (register_leaf_sysctl_tables(new_path, pos, &subheader, |
1354 | root, namespaces, table)) | 1348 | set, table)) |
1355 | goto err_register_leaves; | 1349 | goto err_register_leaves; |
1356 | } | 1350 | } |
1357 | 1351 | ||
@@ -1384,7 +1378,7 @@ err_register_leaves: | |||
1384 | struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, | 1378 | struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, |
1385 | struct ctl_table *table) | 1379 | struct ctl_table *table) |
1386 | { | 1380 | { |
1387 | return __register_sysctl_paths(&sysctl_table_root, current->nsproxy, | 1381 | return __register_sysctl_paths(&sysctl_table_root.default_set, |
1388 | path, table); | 1382 | path, table); |
1389 | } | 1383 | } |
1390 | EXPORT_SYMBOL(register_sysctl_paths); | 1384 | EXPORT_SYMBOL(register_sysctl_paths); |
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index 2a1446a96094..cec59415b3ce 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h | |||
@@ -1079,10 +1079,10 @@ extern void retire_sysctl_set(struct ctl_table_set *set); | |||
1079 | 1079 | ||
1080 | void register_sysctl_root(struct ctl_table_root *root); | 1080 | void register_sysctl_root(struct ctl_table_root *root); |
1081 | struct ctl_table_header *__register_sysctl_table( | 1081 | struct ctl_table_header *__register_sysctl_table( |
1082 | struct ctl_table_root *root, struct nsproxy *namespaces, | 1082 | struct ctl_table_set *set, |
1083 | const char *path, struct ctl_table *table); | 1083 | const char *path, struct ctl_table *table); |
1084 | struct ctl_table_header *__register_sysctl_paths( | 1084 | struct ctl_table_header *__register_sysctl_paths( |
1085 | struct ctl_table_root *root, struct nsproxy *namespaces, | 1085 | struct ctl_table_set *set, |
1086 | const struct ctl_path *path, struct ctl_table *table); | 1086 | const struct ctl_path *path, struct ctl_table *table); |
1087 | struct ctl_table_header *register_sysctl_table(struct ctl_table * table); | 1087 | struct ctl_table_header *register_sysctl_table(struct ctl_table * table); |
1088 | struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, | 1088 | struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, |
diff --git a/net/sysctl_net.c b/net/sysctl_net.c index e998c6448046..c3e65aebecc0 100644 --- a/net/sysctl_net.c +++ b/net/sysctl_net.c | |||
@@ -105,19 +105,15 @@ subsys_initcall(net_sysctl_init); | |||
105 | struct ctl_table_header *register_net_sysctl_table(struct net *net, | 105 | struct ctl_table_header *register_net_sysctl_table(struct net *net, |
106 | const struct ctl_path *path, struct ctl_table *table) | 106 | const struct ctl_path *path, struct ctl_table *table) |
107 | { | 107 | { |
108 | struct nsproxy namespaces; | 108 | return __register_sysctl_paths(&net->sysctls, path, table); |
109 | namespaces = *current->nsproxy; | ||
110 | namespaces.net_ns = net; | ||
111 | return __register_sysctl_paths(&net_sysctl_root, | ||
112 | &namespaces, path, table); | ||
113 | } | 109 | } |
114 | EXPORT_SYMBOL_GPL(register_net_sysctl_table); | 110 | EXPORT_SYMBOL_GPL(register_net_sysctl_table); |
115 | 111 | ||
116 | struct ctl_table_header *register_net_sysctl_rotable(const | 112 | struct ctl_table_header *register_net_sysctl_rotable(const |
117 | struct ctl_path *path, struct ctl_table *table) | 113 | struct ctl_path *path, struct ctl_table *table) |
118 | { | 114 | { |
119 | return __register_sysctl_paths(&net_sysctl_ro_root, | 115 | return __register_sysctl_paths(&net_sysctl_ro_root.default_set, |
120 | &init_nsproxy, path, table); | 116 | path, table); |
121 | } | 117 | } |
122 | EXPORT_SYMBOL_GPL(register_net_sysctl_rotable); | 118 | EXPORT_SYMBOL_GPL(register_net_sysctl_rotable); |
123 | 119 | ||