Commit 60a47a2e authored by Eric W. Biederman's avatar Eric W. Biederman

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: default avatarEric W. Biederman <ebiederm@xmission.com>
parent 0e47c99d
...@@ -1084,8 +1084,7 @@ static int insert_links(struct ctl_table_header *head) ...@@ -1084,8 +1084,7 @@ static int insert_links(struct ctl_table_header *head)
/** /**
* __register_sysctl_table - register a leaf sysctl table * __register_sysctl_table - register a leaf sysctl table
* @root: List of sysctl headers to register on * @set: Sysctl tree to register on
* @namespaces: Data to compute which lists of sysctl entries are visible
* @path: The path to the directory the sysctl table is in. * @path: The path to the directory the sysctl table is in.
* @table: the top-level table structure * @table: the top-level table structure
* *
...@@ -1126,26 +1125,24 @@ static int insert_links(struct ctl_table_header *head) ...@@ -1126,26 +1125,24 @@ static int insert_links(struct ctl_table_header *head)
* to the table header on success. * to the table header on success.
*/ */
struct ctl_table_header *__register_sysctl_table( struct ctl_table_header *__register_sysctl_table(
struct ctl_table_root *root, struct ctl_table_set *set,
struct nsproxy *namespaces,
const char *path, struct ctl_table *table) const char *path, struct ctl_table *table)
{ {
struct ctl_table_root *root = set->dir.header.root;
struct ctl_table_header *links = NULL; struct ctl_table_header *links = NULL;
struct ctl_table_header *header; struct ctl_table_header *header;
const char *name, *nextname; const char *name, *nextname;
struct ctl_table_set *set;
struct ctl_dir *dir; struct ctl_dir *dir;
header = kzalloc(sizeof(struct ctl_table_header), GFP_KERNEL); header = kzalloc(sizeof(struct ctl_table_header), GFP_KERNEL);
if (!header) if (!header)
return NULL; return NULL;
init_header(header, root, NULL, table); init_header(header, root, set, table);
if (sysctl_check_table(path, table)) if (sysctl_check_table(path, table))
goto fail; goto fail;
spin_lock(&sysctl_lock); spin_lock(&sysctl_lock);
header->set = set = lookup_header_set(root, namespaces);
dir = &set->dir; dir = &set->dir;
dir->header.nreg++; dir->header.nreg++;
spin_unlock(&sysctl_lock); spin_unlock(&sysctl_lock);
...@@ -1223,8 +1220,7 @@ static int count_subheaders(struct ctl_table *table) ...@@ -1223,8 +1220,7 @@ static int count_subheaders(struct ctl_table *table)
} }
static int register_leaf_sysctl_tables(const char *path, char *pos, static int register_leaf_sysctl_tables(const char *path, char *pos,
struct ctl_table_header ***subheader, struct ctl_table_header ***subheader, struct ctl_table_set *set,
struct ctl_table_root *root, struct nsproxy *namespaces,
struct ctl_table *table) struct ctl_table *table)
{ {
struct ctl_table *ctl_table_arg = NULL; struct ctl_table *ctl_table_arg = NULL;
...@@ -1261,7 +1257,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos, ...@@ -1261,7 +1257,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
/* Register everything except a directory full of subdirectories */ /* Register everything except a directory full of subdirectories */
if (nr_files || !nr_dirs) { if (nr_files || !nr_dirs) {
struct ctl_table_header *header; struct ctl_table_header *header;
header = __register_sysctl_table(root, namespaces, path, files); header = __register_sysctl_table(set, path, files);
if (!header) { if (!header) {
kfree(ctl_table_arg); kfree(ctl_table_arg);
goto out; goto out;
...@@ -1286,7 +1282,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos, ...@@ -1286,7 +1282,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
goto out; goto out;
err = register_leaf_sysctl_tables(path, child_pos, subheader, err = register_leaf_sysctl_tables(path, child_pos, subheader,
root, namespaces, entry->child); set, entry->child);
pos[0] = '\0'; pos[0] = '\0';
if (err) if (err)
goto out; goto out;
...@@ -1299,8 +1295,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos, ...@@ -1299,8 +1295,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
/** /**
* __register_sysctl_paths - register a sysctl table hierarchy * __register_sysctl_paths - register a sysctl table hierarchy
* @root: List of sysctl headers to register on * @set: Sysctl tree to register on
* @namespaces: Data to compute which lists of sysctl entries are visible
* @path: The path to the directory the sysctl table is in. * @path: The path to the directory the sysctl table is in.
* @table: the top-level table structure * @table: the top-level table structure
* *
...@@ -1310,8 +1305,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos, ...@@ -1310,8 +1305,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
* See __register_sysctl_table for more details. * See __register_sysctl_table for more details.
*/ */
struct ctl_table_header *__register_sysctl_paths( struct ctl_table_header *__register_sysctl_paths(
struct ctl_table_root *root, struct ctl_table_set *set,
struct nsproxy *namespaces,
const struct ctl_path *path, struct ctl_table *table) const struct ctl_path *path, struct ctl_table *table)
{ {
struct ctl_table *ctl_table_arg = table; struct ctl_table *ctl_table_arg = table;
...@@ -1337,7 +1331,7 @@ struct ctl_table_header *__register_sysctl_paths( ...@@ -1337,7 +1331,7 @@ struct ctl_table_header *__register_sysctl_paths(
table = table->child; table = table->child;
} }
if (nr_subheaders == 1) { if (nr_subheaders == 1) {
header = __register_sysctl_table(root, namespaces, new_path, table); header = __register_sysctl_table(set, new_path, table);
if (header) if (header)
header->ctl_table_arg = ctl_table_arg; header->ctl_table_arg = ctl_table_arg;
} else { } else {
...@@ -1351,7 +1345,7 @@ struct ctl_table_header *__register_sysctl_paths( ...@@ -1351,7 +1345,7 @@ struct ctl_table_header *__register_sysctl_paths(
header->ctl_table_arg = ctl_table_arg; header->ctl_table_arg = ctl_table_arg;
if (register_leaf_sysctl_tables(new_path, pos, &subheader, if (register_leaf_sysctl_tables(new_path, pos, &subheader,
root, namespaces, table)) set, table))
goto err_register_leaves; goto err_register_leaves;
} }
...@@ -1384,7 +1378,7 @@ struct ctl_table_header *__register_sysctl_paths( ...@@ -1384,7 +1378,7 @@ struct ctl_table_header *__register_sysctl_paths(
struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
struct ctl_table *table) struct ctl_table *table)
{ {
return __register_sysctl_paths(&sysctl_table_root, current->nsproxy, return __register_sysctl_paths(&sysctl_table_root.default_set,
path, table); path, table);
} }
EXPORT_SYMBOL(register_sysctl_paths); EXPORT_SYMBOL(register_sysctl_paths);
......
...@@ -1079,10 +1079,10 @@ extern void retire_sysctl_set(struct ctl_table_set *set); ...@@ -1079,10 +1079,10 @@ extern void retire_sysctl_set(struct ctl_table_set *set);
void register_sysctl_root(struct ctl_table_root *root); void register_sysctl_root(struct ctl_table_root *root);
struct ctl_table_header *__register_sysctl_table( struct ctl_table_header *__register_sysctl_table(
struct ctl_table_root *root, struct nsproxy *namespaces, struct ctl_table_set *set,
const char *path, struct ctl_table *table); const char *path, struct ctl_table *table);
struct ctl_table_header *__register_sysctl_paths( struct ctl_table_header *__register_sysctl_paths(
struct ctl_table_root *root, struct nsproxy *namespaces, struct ctl_table_set *set,
const struct ctl_path *path, struct ctl_table *table); const struct ctl_path *path, struct ctl_table *table);
struct ctl_table_header *register_sysctl_table(struct ctl_table * table); struct ctl_table_header *register_sysctl_table(struct ctl_table * table);
struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
......
...@@ -105,19 +105,15 @@ subsys_initcall(net_sysctl_init); ...@@ -105,19 +105,15 @@ subsys_initcall(net_sysctl_init);
struct ctl_table_header *register_net_sysctl_table(struct net *net, struct ctl_table_header *register_net_sysctl_table(struct net *net,
const struct ctl_path *path, struct ctl_table *table) const struct ctl_path *path, struct ctl_table *table)
{ {
struct nsproxy namespaces; return __register_sysctl_paths(&net->sysctls, path, table);
namespaces = *current->nsproxy;
namespaces.net_ns = net;
return __register_sysctl_paths(&net_sysctl_root,
&namespaces, path, table);
} }
EXPORT_SYMBOL_GPL(register_net_sysctl_table); EXPORT_SYMBOL_GPL(register_net_sysctl_table);
struct ctl_table_header *register_net_sysctl_rotable(const struct ctl_table_header *register_net_sysctl_rotable(const
struct ctl_path *path, struct ctl_table *table) struct ctl_path *path, struct ctl_table *table)
{ {
return __register_sysctl_paths(&net_sysctl_ro_root, return __register_sysctl_paths(&net_sysctl_ro_root.default_set,
&init_nsproxy, path, table); path, table);
} }
EXPORT_SYMBOL_GPL(register_net_sysctl_rotable); EXPORT_SYMBOL_GPL(register_net_sysctl_rotable);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment