mirror of
https://github.com/team-infusion-developers/android_kernel_samsung_msm8976.git
synced 2024-10-19 01:48:56 +00:00
0b4d414714
The semantic effect of insert_at_head is that it would allow new registered sysctl entries to override existing sysctl entries of the same name. Which is pain for caching and the proc interface never implemented. I have done an audit and discovered that none of the current users of register_sysctl care as (excpet for directories) they do not register duplicate sysctl entries. So this patch simply removes the support for overriding existing entries in the sys_sysctl interface since no one uses it or cares and it makes future enhancments harder. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Acked-by: Ralf Baechle <ralf@linux-mips.org> Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Russell King <rmk@arm.linux.org.uk> Cc: David Howells <dhowells@redhat.com> Cc: "Luck, Tony" <tony.luck@intel.com> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Andi Kleen <ak@muc.de> Cc: Jens Axboe <axboe@kernel.dk> Cc: Corey Minyard <minyard@acm.org> Cc: Neil Brown <neilb@suse.de> Cc: "John W. Linville" <linville@tuxdriver.com> Cc: James Bottomley <James.Bottomley@steeleye.com> Cc: Jan Kara <jack@ucw.cz> Cc: Trond Myklebust <trond.myklebust@fys.uio.no> Cc: Mark Fasheh <mark.fasheh@oracle.com> Cc: David Chinner <dgc@sgi.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: Patrick McHardy <kaber@trash.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
134 lines
2.5 KiB
C
134 lines
2.5 KiB
C
/* nf_sysctl.c netfilter sysctl registration/unregistation
|
|
*
|
|
* Copyright (c) 2006 Patrick McHardy <kaber@trash.net>
|
|
*/
|
|
#include <linux/module.h>
|
|
#include <linux/sysctl.h>
|
|
#include <linux/string.h>
|
|
#include <linux/slab.h>
|
|
|
|
static void
|
|
path_free(struct ctl_table *path, struct ctl_table *table)
|
|
{
|
|
struct ctl_table *t, *next;
|
|
|
|
for (t = path; t != NULL && t != table; t = next) {
|
|
next = t->child;
|
|
kfree(t);
|
|
}
|
|
}
|
|
|
|
static struct ctl_table *
|
|
path_dup(struct ctl_table *path, struct ctl_table *table)
|
|
{
|
|
struct ctl_table *t, *last = NULL, *tmp;
|
|
|
|
for (t = path; t != NULL; t = t->child) {
|
|
/* twice the size since path elements are terminated by an
|
|
* empty element */
|
|
tmp = kmemdup(t, 2 * sizeof(*t), GFP_KERNEL);
|
|
if (tmp == NULL) {
|
|
if (last != NULL)
|
|
path_free(path, table);
|
|
return NULL;
|
|
}
|
|
|
|
if (last != NULL)
|
|
last->child = tmp;
|
|
else
|
|
path = tmp;
|
|
last = tmp;
|
|
}
|
|
|
|
if (last != NULL)
|
|
last->child = table;
|
|
else
|
|
path = table;
|
|
|
|
return path;
|
|
}
|
|
|
|
struct ctl_table_header *
|
|
nf_register_sysctl_table(struct ctl_table *path, struct ctl_table *table)
|
|
{
|
|
struct ctl_table_header *header;
|
|
|
|
path = path_dup(path, table);
|
|
if (path == NULL)
|
|
return NULL;
|
|
header = register_sysctl_table(path);
|
|
if (header == NULL)
|
|
path_free(path, table);
|
|
return header;
|
|
}
|
|
EXPORT_SYMBOL_GPL(nf_register_sysctl_table);
|
|
|
|
void
|
|
nf_unregister_sysctl_table(struct ctl_table_header *header,
|
|
struct ctl_table *table)
|
|
{
|
|
struct ctl_table *path = header->ctl_table;
|
|
|
|
unregister_sysctl_table(header);
|
|
path_free(path, table);
|
|
}
|
|
EXPORT_SYMBOL_GPL(nf_unregister_sysctl_table);
|
|
|
|
/* net/netfilter */
|
|
static struct ctl_table nf_net_netfilter_table[] = {
|
|
{
|
|
.ctl_name = NET_NETFILTER,
|
|
.procname = "netfilter",
|
|
.mode = 0555,
|
|
},
|
|
{
|
|
.ctl_name = 0
|
|
}
|
|
};
|
|
struct ctl_table nf_net_netfilter_sysctl_path[] = {
|
|
{
|
|
.ctl_name = CTL_NET,
|
|
.procname = "net",
|
|
.mode = 0555,
|
|
.child = nf_net_netfilter_table,
|
|
},
|
|
{
|
|
.ctl_name = 0
|
|
}
|
|
};
|
|
EXPORT_SYMBOL_GPL(nf_net_netfilter_sysctl_path);
|
|
|
|
/* net/ipv4/netfilter */
|
|
static struct ctl_table nf_net_ipv4_netfilter_table[] = {
|
|
{
|
|
.ctl_name = NET_IPV4_NETFILTER,
|
|
.procname = "netfilter",
|
|
.mode = 0555,
|
|
},
|
|
{
|
|
.ctl_name = 0
|
|
}
|
|
};
|
|
static struct ctl_table nf_net_ipv4_table[] = {
|
|
{
|
|
.ctl_name = NET_IPV4,
|
|
.procname = "ipv4",
|
|
.mode = 0555,
|
|
.child = nf_net_ipv4_netfilter_table,
|
|
},
|
|
{
|
|
.ctl_name = 0
|
|
}
|
|
};
|
|
struct ctl_table nf_net_ipv4_netfilter_sysctl_path[] = {
|
|
{
|
|
.ctl_name = CTL_NET,
|
|
.procname = "net",
|
|
.mode = 0555,
|
|
.child = nf_net_ipv4_table,
|
|
},
|
|
{
|
|
.ctl_name = 0
|
|
}
|
|
};
|
|
EXPORT_SYMBOL_GPL(nf_net_ipv4_netfilter_sysctl_path);
|