v1: sysctl header cookies + private children
Subsystems (38)
cover v1: sysctl header cookies + private children
Hi,
The first patches in this series add a 'cookie' to the struct ctl_table_header. This cookie is used to store some data and is passed to proc_handlers. The 'cookie' part series has already been posted on netdev/lkml, but it was dropped because sysctl has a bigger
problem: an inefficient algorithm to add new tables.
This is where part two comes along: private ctl_table_header nodes. Not all sysctl headers are the same: while some of them are at a high level and have lots of other headers attached to them, most other headers are children of another header and will never have a child attached to them. With this in mind, we designate some of these headers to be 'private children' (I don't really like this terminology
- I'm open to suggestions) of another header.
Performance suffers because every header is consulted:
- when we add a new header (to attach the new header somewhere)
- when lookup failed in a table: we consult every other header to see whether it was attached to this table.
Neither of these actions are performed for private children. With more header registered as private, the number of headers consulted in these steps lowers and performance is better.
Adding nodes for:
- /proc/sys/net/ipv4/conf/DEVNAME
- /proc/sys/net/ipv6/conf/DEVNAME
- /proc/sys/net/ipv4/neigh/DEVNAME
- /proc/sys/net/ipv6/neigh/DEVNAME
as private children has this effect:
$ time modprobe dummy numdummies=$n
Without these patches:
- n=5000 => 17:31 minutes
- n=2000 => 2:23 minutes
- n=1000 => 0:25 minutes
With these patches:
- n=5000 => 12.50 seconds
- n=2000 => 1.59 seconds
- n=1000 => 0.44 seconds
I'll follow up with another series adding the cookie in a few more places and removing some fields in ctl_table, but I'd like some feedback for these patches.
Patches are against 2.6.39-rc1.
Lucian Adrian Grijincu (24):
sysctl: net: call unregister_net_sysctl_table where needed
sysctl: cookie: add ctl_header_cookie
sysctl: cookie: pass ctl_header_cookie to proc_handler
sysctl: cookie: add netns_proc_dointvec and other netns_proc_*
proc_handlers
sysctl: cookie: share ip4_frags_ns_ctl_table between nets
sysctl: cookie: share netns_core_table between nets
sysctl: cookie: share ipv4_route_flush_table between nets
sysctl: cookie: share ipv4_net_table between nets
sysctl: cookie: share ip6_frags_ns_ctl_table between nets
sysctl: cookie: share ip6_ctl_table, ipv6_icmp_table and
ipv6_route_table between nets
sysctl: cookie: share acct_sysctl_table table between nets
sysctl: cookie: share event_sysctl_table between nets
sysctl: cookie: share nf_ct_sysctl_table between nets
sysctl: cookie: share unix_table between nets
sysctl: cookie: share xfrm_table between nets
sysctl: add support for private_children headers
sysctl: add register_net_sysctl_table_with_parent
sysctl: ipv4: register /proc/sys/net/ipv4/conf empty directory
sysctl: ipv4: register devinet tables as private children
sysctl: ipv6: register /proc/sys/net/ipv6/conf empty directory
sysctl: ipv6: register addrconf tables as private children
sysctl: ipv4: register /proc/sys/net/ipv4/neigh empty directory
sysctl: ipv6: register /proc/sys/net/ipv6/neigh empty directory
sysctl: neigh: ipv4 and ipv6 neigh tables as private children
arch/frv/kernel/pm.c | 22 ++-- arch/frv/kernel/sysctl.c | 4 +- arch/mips/lasat/sysctl.c | 28 +++--- arch/s390/appldata/appldata_base.c | 15 ++-- arch/s390/kernel/debug.c | 6 +- arch/s390/mm/cmm.c | 4 +- drivers/cdrom/cdrom.c | 12 +- drivers/char/random.c | 6 +- drivers/macintosh/mac_hid.c | 4 +- drivers/parport/procfs.c | 29 +++--- drivers/s390/char/sclp_async.c | 2 +- fs/dcache.c | 4 +- fs/drop_caches.c | 5 +- fs/file_table.c | 10 +- fs/fscache/main.c | 6 +- fs/inode.c | 6 +- fs/pipe.c | 4 +- fs/proc/proc_sysctl.c | 24 ++++- fs/quota/dquot.c | 5 +- fs/xfs/linux-2.6/xfs_sysctl.c | 10 +- include/linux/compaction.h | 6 +- include/linux/fs.h | 12 +- include/linux/ftrace.h | 4 +- include/linux/hugetlb.h | 13 ++- include/linux/kprobes.h | 6 +- include/linux/mm.h | 4 +- include/linux/mmzone.h | 23 ++-- include/linux/nmi.h | 4 +- include/linux/perf_event.h | 2 +- include/linux/pipe_fs_i.h | 2 +- include/linux/sched.h | 16 ++-- include/linux/security.h | 3 +- include/linux/swap.h | 4 +- include/linux/sysctl.h | 45 ++++++-- include/linux/writeback.h | 18 +-- include/net/ipv6.h | 8 +- include/net/ndisc.h | 7 +- include/net/neighbour.h | 9 +- include/net/net_namespace.h | 36 +++++++ include/net/netns/ipv4.h | 10 +- include/net/netns/ipv6.h | 4 +- ipc/ipc_sysctl.c | 21 ++-- ipc/mq_sysctl.c | 11 +- kernel/hung_task.c | 6 +- kernel/kprobes.c | 4 +- kernel/perf_event.c | 4 +- kernel/sched.c | 4 +- kernel/sched_fair.c | 4 +- kernel/sysctl.c | 171 +++++++++++++++++++++++-------- kernel/trace/ftrace.c | 4 +- kernel/trace/trace_stack.c | 4 +- kernel/utsname_sysctl.c | 6 +- kernel/watchdog.c | 11 +- mm/compaction.c | 8 +- mm/hugetlb.c | 24 +++-- mm/page-writeback.c | 24 ++--- mm/page_alloc.c | 25 ++--- mm/vmscan.c | 6 +- net/bridge/br_netfilter.c | 6 +- net/core/neighbour.c | 6 +- net/core/sysctl_net_core.c | 33 +----- net/decnet/dn_dev.c | 10 +- net/decnet/sysctl_net_decnet.c | 8 +- net/ipv4/arp.c | 71 ++++++++++++- net/ipv4/devinet.c | 52 +++++++--- net/ipv4/ip_fragment.c | 34 +----- net/ipv4/route.c | 49 +++------- net/ipv4/sysctl_net_ipv4.c | 78 ++++---------- net/ipv6/addrconf.c | 50 +++++++-- net/ipv6/af_inet6.c | 12 -- net/ipv6/icmp.c | 17 +--- net/ipv6/ndisc.c | 91 ++++++++++++---- net/ipv6/reassembly.c | 34 +----- net/ipv6/route.c | 60 +++-------- net/ipv6/sysctl_net_ipv6.c | 88 ++-------------- net/irda/irsysctl.c | 12 +- net/netfilter/ipvs/ip_vs_ctl.c | 12 +- net/netfilter/nf_conntrack_acct.c | 24 +---- net/netfilter/nf_conntrack_ecache.c | 30 +----- net/netfilter/nf_conntrack_standalone.c | 30 +----- net/netfilter/nf_log.c | 5 +- net/phonet/sysctl.c | 6 +- net/sunrpc/sysctl.c | 9 +- net/sunrpc/xprtrdma/svc_rdma.c | 2 +- net/sysctl_net.c | 46 ++++++++- net/unix/sysctl_net_unix.c | 22 +---- net/xfrm/xfrm_sysctl.c | 37 ++----- security/min_addr.c | 5 +- 88 files changed, 879 insertions(+), 839 deletions(-)
Signature · 1 line
1.7.5.rc0
PATCH 1/24 sysctl: net: call unregister_net_sysctl_table where needed
ctl_table_headers registered with register_net_sysctl_table should have been unregistered with the equivalent unregister_net_sysctl_table
--- net/ipv4/devinet.c | 2 +- net/ipv6/addrconf.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
net/ipv4/devinet.c +1 -1
@@ -1680,7 +1680,7 @@ static void __devinet_sysctl_unregister(struct ipv4_devconf *cnf)return ; cnf->sysctl =NULL ; -unregister_sysctl_table (t->sysctl_header); +unregister_net_sysctl_table (t->sysctl_header);kfree (t->dev_name);kfree (t); }
net/ipv6/addrconf.c +1 -1
@@ -4537,7 +4537,7 @@ static void __addrconf_sysctl_unregister(struct ipv6_devconf *p) t = p->sysctl; p->sysctl =NULL ; -unregister_sysctl_table (t->sysctl_header); +unregister_net_sysctl_table (t->sysctl_header);kfree (t->dev_name);kfree (t); }
Signature · 1 line
1.7.5.rc0
PATCH 1/24 sysctl: net: call unregister_net_sysctl_table where needed
In reply to Lucian Adrian Grijincuctl_table_headers registered with register_net_sysctl_table should have been unregistered with the equivalent unregister_net_sysctl_table
--- net/ipv4/devinet.c | 2 +- net/ipv6/addrconf.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
net/ipv4/devinet.c +1 -1
@@ -1680,7 +1680,7 @@ static void __devinet_sysctl_unregister(struct ipv4_devconf *cnf)return ; cnf->sysctl =NULL ; -unregister_sysctl_table (t->sysctl_header); +unregister_net_sysctl_table (t->sysctl_header);kfree (t->dev_name);kfree (t); }
net/ipv6/addrconf.c +1 -1
@@ -4537,7 +4537,7 @@ static void __addrconf_sysctl_unregister(struct ipv6_devconf *p) t = p->sysctl; p->sysctl =NULL ; -unregister_sysctl_table (t->sysctl_header); +unregister_net_sysctl_table (t->sysctl_header);kfree (t->dev_name);kfree (t); }
Signature · 1 line
1.7.5.rc0
PATCH 2/24 sysctl: cookie: add ctl_header_cookie
In reply to Lucian Adrian Grijincu--- include/linux/sysctl.h | 5 ++++- kernel/sysctl.c | 12 ++++++++---- net/sysctl_net.c | 6 +++--- 3 files changed, 15 insertions(+), 8 deletions(-)
include/linux/sysctl.h +4 -1
@@ -1054,6 +1054,9 @@ struct ctl_table_headerstruct ctl_table *attached_by;struct ctl_table *attached_to;struct ctl_table_header *parent; +/* Pointer to data that outlives this ctl_table_header. +* Caller responsible to free the cookie. */ +void *ctl_header_cookie; };/* struct ctl_path describes where in the hierarchy a table is added */
@@ -1064,7 +1067,7 @@ struct ctl_path {void register_sysctl_root (struct ctl_table_root *root);struct ctl_table_header *__register_sysctl_paths (struct ctl_table_root *root,struct nsproxy *namespaces, -const struct ctl_path *path,struct ctl_table *table); +const struct ctl_path *path,struct ctl_table *table,void *cookie);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 *table);
kernel/sysctl.c +8 -4
@@ -205,6 +205,7 @@ static struct ctl_table_header root_table_header = { .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),}}, .root = &sysctl_table_root, .set = &sysctl_table_root.default_set, + .ctl_header_cookie = NULL, };static struct ctl_table_root sysctl_table_root = { .root_list =LIST_HEAD_INIT (sysctl_table_root.root_list),
@@ -1781,6 +1782,9 @@ static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)* @namespaces: Data to compute which lists of sysctl entries are visible * @path: The path to the directory the sysctl table is in. * @table: the top-level table structure +* @cookie: Pointer to user provided data that must be accessible +* until unregister_sysctl_table. This cookie will be passed to the +* proc_handler. * * Register a sysctl table hierarchy. @table should be a filled in ctl_table * array. A completely 0 filled entry terminates the table.
@@ -1829,9 +1833,8 @@ static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)* to the table header on success. */ struct ctl_table_header *__register_sysctl_paths ( -struct ctl_table_root *root, -struct nsproxy *namespaces, -const struct ctl_path *path,struct ctl_table *table) +struct ctl_table_root *root,struct nsproxy *namespaces, +const struct ctl_path *path,struct ctl_table *table,void *cookie) {struct ctl_table_header *header;struct ctl_table *new, **prevp;
@@ -1878,6 +1881,7 @@ struct ctl_table_header *__register_sysctl_paths( header->root = root;sysctl_set_parent (NULL , header->ctl_table); header->count =1 ; + header->ctl_header_cookie = cookie;#ifdef CONFIG_SYSCTL_SYSCALL_CHECK if (sysctl_check_table (namespaces, header->ctl_table)) {kfree (header);
@@ -1918,7 +1922,7 @@ struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, struct ctl_table *table) {return __register_sysctl_paths (&sysctl_table_root, current->nsproxy, - path, table); + path, table,NULL ); }/**
net/sysctl_net.c +3 -3
@@ -109,8 +109,8 @@ struct ctl_table_header *register_net_sysctl_table(struct net *net,struct nsproxy namespaces; namespaces = *current->nsproxy; namespaces.net_ns = net; -return __register_sysctl_paths (&net_sysctl_root, - &namespaces, path, table); +return __register_sysctl_paths (&net_sysctl_root, &namespaces, path, + table,NULL ); }EXPORT_SYMBOL_GPL (register_net_sysctl_table);
@@ -118,7 +118,7 @@ struct ctl_table_header *register_net_sysctl_rotable(const struct ctl_path *path, struct ctl_table *table) { return __register_sysctl_paths(&net_sysctl_ro_root, - &init_nsproxy, path, table); + &init_nsproxy, path, table, NULL); }EXPORT_SYMBOL_GPL (register_net_sysctl_rotable);
Signature · 1 line
1.7.5.rc0
PATCH 2/24 sysctl: cookie: add ctl_header_cookie
In reply to Lucian Adrian Grijincu--- include/linux/sysctl.h | 5 ++++- kernel/sysctl.c | 12 ++++++++---- net/sysctl_net.c | 6 +++--- 3 files changed, 15 insertions(+), 8 deletions(-)
include/linux/sysctl.h +4 -1
@@ -1054,6 +1054,9 @@ struct ctl_table_headerstruct ctl_table *attached_by;struct ctl_table *attached_to;struct ctl_table_header *parent; +/* Pointer to data that outlives this ctl_table_header. +* Caller responsible to free the cookie. */ +void *ctl_header_cookie; };/* struct ctl_path describes where in the hierarchy a table is added */
@@ -1064,7 +1067,7 @@ struct ctl_path {void register_sysctl_root (struct ctl_table_root *root);struct ctl_table_header *__register_sysctl_paths (struct ctl_table_root *root,struct nsproxy *namespaces, -const struct ctl_path *path,struct ctl_table *table); +const struct ctl_path *path,struct ctl_table *table,void *cookie);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 *table);
kernel/sysctl.c +8 -4
@@ -205,6 +205,7 @@ static struct ctl_table_header root_table_header = { .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),}}, .root = &sysctl_table_root, .set = &sysctl_table_root.default_set, + .ctl_header_cookie = NULL, };static struct ctl_table_root sysctl_table_root = { .root_list =LIST_HEAD_INIT (sysctl_table_root.root_list),
@@ -1781,6 +1782,9 @@ static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)* @namespaces: Data to compute which lists of sysctl entries are visible * @path: The path to the directory the sysctl table is in. * @table: the top-level table structure +* @cookie: Pointer to user provided data that must be accessible +* until unregister_sysctl_table. This cookie will be passed to the +* proc_handler. * * Register a sysctl table hierarchy. @table should be a filled in ctl_table * array. A completely 0 filled entry terminates the table.
@@ -1829,9 +1833,8 @@ static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)* to the table header on success. */ struct ctl_table_header *__register_sysctl_paths ( -struct ctl_table_root *root, -struct nsproxy *namespaces, -const struct ctl_path *path,struct ctl_table *table) +struct ctl_table_root *root,struct nsproxy *namespaces, +const struct ctl_path *path,struct ctl_table *table,void *cookie) {struct ctl_table_header *header;struct ctl_table *new, **prevp;
@@ -1878,6 +1881,7 @@ struct ctl_table_header *__register_sysctl_paths( header->root = root;sysctl_set_parent (NULL , header->ctl_table); header->count =1 ; + header->ctl_header_cookie = cookie;#ifdef CONFIG_SYSCTL_SYSCALL_CHECK if (sysctl_check_table (namespaces, header->ctl_table)) {kfree (header);
@@ -1918,7 +1922,7 @@ struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path, struct ctl_table *table) {return __register_sysctl_paths (&sysctl_table_root, current->nsproxy, - path, table); + path, table,NULL ); }/**
net/sysctl_net.c +3 -3
@@ -109,8 +109,8 @@ struct ctl_table_header *register_net_sysctl_table(struct net *net,struct nsproxy namespaces; namespaces = *current->nsproxy; namespaces.net_ns = net; -return __register_sysctl_paths (&net_sysctl_root, - &namespaces, path, table); +return __register_sysctl_paths (&net_sysctl_root, &namespaces, path, + table,NULL ); }EXPORT_SYMBOL_GPL (register_net_sysctl_table);
@@ -118,7 +118,7 @@ struct ctl_table_header *register_net_sysctl_rotable(const struct ctl_path *path, struct ctl_table *table) { return __register_sysctl_paths(&net_sysctl_ro_root, - &init_nsproxy, path, table); + &init_nsproxy, path, table, NULL); }EXPORT_SYMBOL_GPL (register_net_sysctl_rotable);
Signature · 1 line
1.7.5.rc0
PATCH 3/24 sysctl: cookie: pass ctl_header_cookie to proc_handler
In reply to Lucian Adrian GrijincuThe bulk of this patch changes all proc_handlers in the kernel to receive the cookie.
--- arch/frv/kernel/pm.c | 22 ++++---- arch/frv/kernel/sysctl.c | 4 +- arch/mips/lasat/sysctl.c | 28 ++++++------ arch/s390/appldata/appldata_base.c | 15 +++--- arch/s390/kernel/debug.c | 6 +- arch/s390/mm/cmm.c | 4 +- drivers/cdrom/cdrom.c | 12 ++-- drivers/char/random.c | 6 +- drivers/macintosh/mac_hid.c | 4 +- drivers/parport/procfs.c | 29 +++++------ drivers/s390/char/sclp_async.c | 2 +- fs/dcache.c | 4 +- fs/drop_caches.c | 5 +- fs/file_table.c | 10 ++-- fs/fscache/main.c | 6 +- fs/inode.c | 6 +- fs/pipe.c | 4 +- fs/proc/proc_sysctl.c | 3 +- fs/quota/dquot.c | 5 +- fs/xfs/linux-2.6/xfs_sysctl.c | 10 ++-- include/linux/compaction.h | 6 ++- include/linux/fs.h | 12 ++-- include/linux/ftrace.h | 4 +- include/linux/hugetlb.h | 13 +++-- include/linux/kprobes.h | 6 +- include/linux/mm.h | 4 +- include/linux/mmzone.h | 23 +++++---- include/linux/nmi.h | 4 +- include/linux/perf_event.h | 2 +- include/linux/pipe_fs_i.h | 2 +- include/linux/sched.h | 16 +++--- include/linux/security.h | 3 +- include/linux/swap.h | 4 +- include/linux/sysctl.h | 30 ++++++++---- include/linux/writeback.h | 18 ++----- include/net/ndisc.h | 7 ++- ipc/ipc_sysctl.c | 21 +++++---- ipc/mq_sysctl.c | 11 ++-- kernel/hung_task.c | 6 +- kernel/kprobes.c | 4 +- kernel/perf_event.c | 4 +- kernel/sched.c | 4 +- kernel/sched_fair.c | 4 +- kernel/sysctl.c | 91 +++++++++++++++++++++++------------ kernel/trace/ftrace.c | 4 +- kernel/trace/trace_stack.c | 4 +- kernel/utsname_sysctl.c | 6 +- kernel/watchdog.c | 11 ++-- mm/compaction.c | 8 ++- mm/hugetlb.c | 24 +++++---- mm/page-writeback.c | 24 ++++------ mm/page_alloc.c | 25 +++++----- mm/vmscan.c | 6 +- net/bridge/br_netfilter.c | 6 +- net/core/sysctl_net_core.c | 5 +- net/decnet/dn_dev.c | 10 ++-- net/decnet/sysctl_net_decnet.c | 8 ++-- net/ipv4/devinet.c | 18 ++++---- net/ipv4/route.c | 6 +- net/ipv4/sysctl_net_ipv4.c | 25 +++++----- net/ipv6/addrconf.c | 12 ++-- net/ipv6/ndisc.c | 14 +++-- net/ipv6/route.c | 6 +- net/irda/irsysctl.c | 12 ++-- net/netfilter/ipvs/ip_vs_ctl.c | 12 ++-- net/netfilter/nf_log.c | 5 +- net/phonet/sysctl.c | 6 +- net/sunrpc/sysctl.c | 9 ++-- net/sunrpc/xprtrdma/svc_rdma.c | 2 +- security/min_addr.c | 5 +- 70 files changed, 405 insertions(+), 352 deletions(-)
arch/frv/kernel/pm.c +11 -11
@@ -150,8 +150,8 @@ static int user_atoi(char __user *ubuf, size_t len)/* * Send us to sleep. */ -static int sysctl_pm_do_suspend (ctl_table *ctl,int write, -void __user *buffer,size_t *lenp,loff_t *fpos) +static int sysctl_pm_do_suspend (ctl_table *ctl,int write,void __user *buffer, +size_t *lenp,loff_t *fpos,void *cookie) {int retval, mode;
@@ -198,13 +198,13 @@ static int try_set_cmode(int new_cmode) } -static int cmode_procctl (ctl_table *ctl,int write, -void __user *buffer,size_t *lenp,loff_t *fpos) +static int cmode_procctl (ctl_table *ctl,int write,void __user *buffer, +size_t *lenp,loff_t *fpos,void *cookie) {int new_cmode;if (!write) -return proc_dointvec (ctl, write, buffer, lenp, fpos); +return proc_dointvec (ctl, write, buffer, lenp, fpos,NULL ); new_cmode =user_atoi (buffer, *lenp);
@@ -270,26 +270,26 @@ static int try_set_cm(int new_cm)return 0 ; } -static int p0_procctl (ctl_table *ctl,int write, -void __user *buffer,size_t *lenp,loff_t *fpos) +static int p0_procctl (ctl_table *ctl,int write,void __user *buffer, +size_t *lenp,loff_t *fpos,void *cookie) {int new_p0;if (!write) -return proc_dointvec (ctl, write, buffer, lenp, fpos); +return proc_dointvec (ctl, write, buffer, lenp, fpos,NULL ); new_p0 =user_atoi (buffer, *lenp);return try_set_p0 (new_p0)?:*lenp; } -static int cm_procctl (ctl_table *ctl,int write, -void __user *buffer,size_t *lenp,loff_t *fpos) +static int cm_procctl (ctl_table *ctl,int write,void __user *buffer, +size_t *lenp,loff_t *fpos,void *cookie) {int new_cm;if (!write) -return proc_dointvec (ctl, write, buffer, lenp, fpos); +return proc_dointvec (ctl, write, buffer, lenp, fpos,NULL ); new_cm =user_atoi (buffer, *lenp);
arch/frv/kernel/sysctl.c +2 -2
@@ -48,7 +48,7 @@ static void frv_change_dcache_mode(unsigned long newmode)*/ static int procctl_frv_cachemode (ctl_table *table,int write,void __user *buffer,size_t *lenp, -loff_t *ppos) +loff_t *ppos,void *cookie) {unsigned long hsr0;char buff[8 ];
@@ -123,7 +123,7 @@ static int procctl_frv_cachemode(ctl_table *table, int write,#ifdef CONFIG_MMU static int procctl_frv_pin_cxnr (ctl_table *table,int write,void __user *buffer,size_t *lenp, -loff_t *ppos) +loff_t *ppos,void *cookie) {pid_t pid;char buff[16 ], *p;
arch/mips/lasat/sysctl.c +14 -14
@@ -39,12 +39,12 @@/* And the same for proc */ -int proc_dolasatstring (ctl_table *table,int write, -void *buffer,size_t *lenp,loff_t *ppos) +int proc_dolasatstring (ctl_table *table,int write,void *buffer, +size_t *lenp,loff_t *ppos,void *cookie) {int r; - r =proc_dostring (table, write, buffer, lenp, ppos); + r =proc_dostring (table, write, buffer, lenp, ppos,NULL );if ((!write) || r)return r;
@@ -54,12 +54,12 @@ int proc_dolasatstring(ctl_table *table, int write, }/* proc function to write EEPROM after changing int entry */ -int proc_dolasatint (ctl_table *table,int write, -void *buffer,size_t *lenp,loff_t *ppos) +int proc_dolasatint (ctl_table *table,int write,void *buffer, +size_t *lenp,loff_t *ppos,void *cookie) {int r; - r =proc_dointvec (table, write, buffer, lenp, ppos); + r =proc_dointvec (table, write, buffer, lenp, ppos,NULL );if ((!write) || r)return r;
@@ -72,8 +72,8 @@ int proc_dolasatint(ctl_table *table, int write,static int rtctmp;/* proc function to read/write RealTime Clock */ -int proc_dolasatrtc (ctl_table *table,int write, -void *buffer,size_t *lenp,loff_t *ppos) +int proc_dolasatrtc (ctl_table *table,int write,void *buffer, +size_t *lenp,loff_t *ppos,void *cookie) {struct timespec ts;int r;
@@ -85,7 +85,7 @@ int proc_dolasatrtc(ctl_table *table, int write,if (rtctmp <0 ) rtctmp =0 ; } - r =proc_dointvec (table, write, buffer, lenp, ppos); + r =proc_dointvec (table, write, buffer, lenp, ppos,NULL );if (r)return r;
@@ -97,8 +97,8 @@ int proc_dolasatrtc(ctl_table *table, int write,#endif #ifdef CONFIG_INET -int proc_lasat_ip (ctl_table *table,int write, -void *buffer,size_t *lenp,loff_t *ppos) +int proc_lasat_ip (ctl_table *table,int write,void *buffer, +size_t *lenp,loff_t *ppos,void *cookie) {unsigned int ip;char *p, c;
@@ -157,12 +157,12 @@ int proc_lasat_ip(ctl_table *table, int write, }#endif -int proc_lasat_prid (ctl_table *table,int write, -void *buffer,size_t *lenp,loff_t *ppos) +int proc_lasat_prid (ctl_table *table,int write,void *buffer, +size_t *lenp,loff_t *ppos,void *cookie) {int r; - r =proc_dointvec (table, write, buffer, lenp, ppos); + r =proc_dointvec (table, write, buffer, lenp, ppos,NULL );if (r <0 )return r;if (write) {
arch/s390/appldata/appldata_base.c +8 -7
@@ -51,10 +51,11 @@ static struct platform_device *appldata_pdev;*/ static const char appldata_proc_name[APPLDATA_PROC_NAME_LENGTH ] ="appldata" ;static int appldata_timer_handler (ctl_table *ctl,int write, -void __user *buffer,size_t *lenp,loff_t *ppos); +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie);static int appldata_interval_handler (ctl_table *ctl,int write, -void __user *buffer, -size_t *lenp,loff_t *ppos); +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie);static struct ctl_table_header *appldata_sysctl_header;static struct ctl_table appldata_table[] = {
@@ -246,8 +247,8 @@ __appldata_vtimer_setup(int cmd)* Start/Stop timer, show status of timer (0 = not active, 1 = active) */ static int -appldata_timer_handler (ctl_table *ctl,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +appldata_timer_handler (ctl_table *ctl,int write,void __user *buffer, +size_t *lenp,loff_t *ppos,void *cookie) {int len;char buf[2 ];
@@ -334,8 +335,8 @@ out:* monitoring (0 = not in process, 1 = in process) */ static int -appldata_generic_handler (ctl_table *ctl,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +appldata_generic_handler (ctl_table *ctl,int write,void __user *buffer, +size_t *lenp,loff_t *ppos,void *cookie) {struct appldata_ops *ops =NULL , *tmp_ops;int rc, len, found;
arch/s390/kernel/debug.c +3 -3
@@ -884,11 +884,11 @@ static int debug_active=1;* if debug_active is already off */ static int -s390dbf_procactive (ctl_table *table,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +s390dbf_procactive (ctl_table *table,int write,void __user *buffer, +size_t *lenp,loff_t *ppos,void *cookie) {if (!write || debug_stoppable || !debug_active) -return proc_dointvec (table, write, buffer, lenp, ppos); +return proc_dointvec (table, write, buffer, lenp, ppos,NULL );else return 0 ; }
arch/s390/mm/cmm.c +2 -2
@@ -254,7 +254,7 @@ static int cmm_skip_blanks(char *cp, char **endp)static struct ctl_table cmm_table[];static int cmm_pages_handler (ctl_table *ctl,int write,void __user *buffer, -size_t *lenp,loff_t *ppos) +size_t *lenp,loff_t *ppos,void *cookie) {char buf[16 ], *p;long nr;
@@ -294,7 +294,7 @@ static int cmm_pages_handler(ctl_table *ctl, int write, void __user *buffer, }static int cmm_timeout_handler (ctl_table *ctl,int write,void __user *buffer, -size_t *lenp,loff_t *ppos) +size_t *lenp,loff_t *ppos,void *cookie) {char buf[64 ], *p;long nr, seconds;
drivers/cdrom/cdrom.c +6 -6
@@ -3469,8 +3469,8 @@ static int cdrom_print_info(const char *header, int val, char *info,return 0 ; } -static int cdrom_sysctl_info (ctl_table *ctl,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +static int cdrom_sysctl_info (ctl_table *ctl,int write,void __user *buffer, +size_t *lenp,loff_t *ppos,void *cookie) {int pos;char *info = cdrom_sysctl_settings.info;
@@ -3546,7 +3546,7 @@ static int cdrom_sysctl_info(ctl_table *ctl, int write, goto done; doit:mutex_unlock (&cdrom_mutex); -return proc_dostring (ctl, write, buffer, lenp, ppos); +return proc_dostring (ctl, write, buffer, lenp, ppos,NULL ); done:pr_info ("info buffer too small\n" ); goto doit;
@@ -3582,12 +3582,12 @@ static void cdrom_update_settings(void)mutex_unlock (&cdrom_mutex); } -static int cdrom_sysctl_handler (ctl_table *ctl,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +static int cdrom_sysctl_handler (ctl_table *ctl,int write,void __user *buffer, +size_t *lenp,loff_t *ppos,void *cookie) {int ret; - ret =proc_dointvec (ctl, write, buffer, lenp, ppos); + ret =proc_dointvec (ctl, write, buffer, lenp, ppos,NULL );if (write) {
drivers/char/random.c +3 -3
@@ -1227,8 +1227,8 @@ static char sysctl_bootid[16];* as an ASCII string in the standard UUID format. If accesses via the * sysctl system call, it is returned as 16 bytes of binary data. */ -static int proc_do_uuid (ctl_table *table,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +static int proc_do_uuid (ctl_table *table,int write,void __user *buffer, +size_t *lenp,loff_t *ppos,void *cookie) {ctl_table fake_table;unsigned char buf[64 ], tmp_uuid[16 ], *uuid;
@@ -1246,7 +1246,7 @@ static int proc_do_uuid(ctl_table *table, int write, fake_table.data = buf; fake_table.maxlen =sizeof (buf); -return proc_dostring (&fake_table, write, buffer, lenp, ppos); +return proc_dostring (&fake_table, write, buffer, lenp, ppos,NULL ); }static int sysctl_poolsize =INPUT_POOL_WORDS *32 ;
drivers/macintosh/mac_hid.c +2 -2
@@ -183,7 +183,7 @@ static void mac_hid_stop_emulation(void)static int mac_hid_toggle_emumouse (ctl_table *table,int write,void __user *buffer,size_t *lenp, -loff_t *ppos) +loff_t *ppos,void *cookie) {int *valp = table->data;int old_val = *valp;
@@ -193,7 +193,7 @@ static int mac_hid_toggle_emumouse(ctl_table *table, int write,if (rc)return rc; - rc =proc_dointvec (table, write, buffer, lenp, ppos); + rc =proc_dointvec (table, write, buffer, lenp, ppos,NULL );if (rc ==0 && write && *valp != old_val) {if (*valp ==1 )
drivers/parport/procfs.c +13 -16
@@ -31,8 +31,8 @@#define PARPORT_MIN_SPINTIME_VALUE 1#define PARPORT_MAX_SPINTIME_VALUE 1000 -static int do_active_device (ctl_table *table,int write, -void __user *result,size_t *lenp,loff_t *ppos) +static int do_active_device (ctl_table *table,int write,void __user *result, +size_t *lenp,loff_t *ppos,void *cookie) {struct parport *port = (struct parport *)table->extra1;char buffer[256 ];
@@ -68,8 +68,8 @@ static int do_active_device(ctl_table *table, int write, }#ifdef CONFIG_PARPORT_1284 -static int do_autoprobe (ctl_table *table,int write, -void __user *result,size_t *lenp,loff_t *ppos) +static int do_autoprobe (ctl_table *table,int write,void __user *result, +size_t *lenp,loff_t *ppos,void *cookie) {struct parport_device_info *info = table->extra2;const char *str;
@@ -110,9 +110,9 @@ static int do_autoprobe(ctl_table *table, int write, }#endif /* IEEE1284.3 support. */ -static int do_hardware_base_addr (ctl_table *table,int write, -void __user *result, -size_t *lenp,loff_t *ppos) +static int do_hardware_base_addr (ctl_table *table,int write, +void __user *result,size_t *lenp, +loff_t *ppos,void *cookie) {struct parport *port = (struct parport *)table->extra1;char buffer[20 ];
@@ -138,9 +138,8 @@ static int do_hardware_base_addr (ctl_table *table, int write,return copy_to_user (result, buffer, len) ? -EFAULT :0 ; } -static int do_hardware_irq (ctl_table *table,int write, -void __user *result, -size_t *lenp,loff_t *ppos) +static int do_hardware_irq (ctl_table *table,int write,void __user *result, +size_t *lenp,loff_t *ppos,void *cookie) {struct parport *port = (struct parport *)table->extra1;char buffer[20 ];
@@ -166,9 +165,8 @@ static int do_hardware_irq (ctl_table *table, int write,return copy_to_user (result, buffer, len) ? -EFAULT :0 ; } -static int do_hardware_dma (ctl_table *table,int write, -void __user *result, -size_t *lenp,loff_t *ppos) +static int do_hardware_dma (ctl_table *table,int write,void __user *result, +size_t *lenp,loff_t *ppos,void *cookie) {struct parport *port = (struct parport *)table->extra1;char buffer[20 ];
@@ -194,9 +192,8 @@ static int do_hardware_dma (ctl_table *table, int write,return copy_to_user (result, buffer, len) ? -EFAULT :0 ; } -static int do_hardware_modes (ctl_table *table,int write, -void __user *result, -size_t *lenp,loff_t *ppos) +static int do_hardware_modes (ctl_table *table,int write,void __user *result, +size_t *lenp,loff_t *ppos,void *cookie) {struct parport *port = (struct parport *)table->extra1;char buffer[40 ];
drivers/s390/char/sclp_async.c +1 -1
@@ -65,7 +65,7 @@ static struct notifier_block call_home_panic_nb = {static int proc_handler_callhome (struct ctl_table *ctl,int write,void __user *buffer,size_t *count, -loff_t *ppos) +loff_t *ppos,void *cookie) {unsigned long val;int len, rc;
fs/dcache.c +2 -2
@@ -140,10 +140,10 @@ static int get_nr_dentry(void) }int proc_nr_dentry (ctl_table *table,int write,void __user *buffer, -size_t *lenp,loff_t *ppos) +size_t *lenp,loff_t *ppos,void *cookie) { dentry_stat.nr_dentry =get_nr_dentry (); -return proc_dointvec (table, write, buffer, lenp, ppos); +return proc_dointvec (table, write, buffer, lenp, ppos,NULL ); }#endif
fs/drop_caches.c +3 -2
@@ -47,11 +47,12 @@ static void drop_slab(void) }int drop_caches_sysctl_handler (ctl_table *table,int write, -void __user *buffer,size_t *length,loff_t *ppos) +void __user *buffer,size_t *length, +loff_t *ppos,void *cookie) {int ret; - ret =proc_dointvec_minmax (table, write, buffer, length, ppos); + ret =proc_dointvec_minmax (table, write, buffer, length, ppos,NULL );if (ret)return ret;if (write) {
fs/file_table.c +5 -5
@@ -78,15 +78,15 @@ EXPORT_SYMBOL_GPL(get_max_files);* Handle nr_files sysctl */ #if defined(CONFIG_SYSCTL ) && defined(CONFIG_PROC_FS ) -int proc_nr_files (ctl_table *table,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +int proc_nr_files (ctl_table *table,int write,void __user *buffer, +size_t *lenp,loff_t *ppos,void *cookie) { files_stat.nr_files =get_nr_files (); -return proc_doulongvec_minmax (table, write, buffer, lenp, ppos); +return proc_doulongvec_minmax (table, write, buffer, lenp, ppos,NULL ); }#else -int proc_nr_files (ctl_table *table,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +int proc_nr_files (ctl_table *table,int write,void __user *buffer, +size_t *lenp,loff_t *ppos,void *cookie) {return -ENOSYS ; }
fs/fscache/main.c +3 -3
@@ -54,14 +54,14 @@ static unsigned fscache_op_max_active = 2;static struct ctl_table_header *fscache_sysctl_header;static int fscache_max_active_sysctl (struct ctl_table *table,int write, -void __user *buffer, -size_t *lenp,loff_t *ppos) +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie) {struct workqueue_struct **wqp = table->extra1;unsigned int *datap = table->data;int ret; - ret =proc_dointvec (table, write, buffer, lenp, ppos); + ret =proc_dointvec (table, write, buffer, lenp, ppos,NULL );if (ret ==0 )workqueue_set_max_active (*wqp, *datap);return ret;
fs/inode.c +3 -3
@@ -158,11 +158,11 @@ int get_nr_dirty_inodes(void)* Handle nr_inode sysctl */ #ifdef CONFIG_SYSCTL -int proc_nr_inodes (ctl_table *table,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +int proc_nr_inodes (ctl_table *table,int write,void __user *buffer, +size_t *lenp,loff_t *ppos,void *cookie) { inodes_stat.nr_inodes =get_nr_inodes (); -return proc_dointvec (table, write, buffer, lenp, ppos); +return proc_dointvec (table, write, buffer, lenp, ppos,NULL ); }#endif
fs/pipe.c +2 -2
@@ -1186,11 +1186,11 @@ static inline unsigned int round_pipe_size(unsigned int size)* will return an error. */ int pipe_proc_fn (struct ctl_table *table,int write,void __user *buf, -size_t *lenp,loff_t *ppos) +size_t *lenp,loff_t *ppos,void *cookie) {int ret; - ret =proc_dointvec_minmax (table, write, buf, lenp, ppos); + ret =proc_dointvec_minmax (table, write, buf, lenp, ppos,NULL );if (ret <0 || !write)return ret;
fs/proc/proc_sysctl.c +2 -1
@@ -155,7 +155,8 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,/* careful: calling conventions are nasty here */ res = count; - error = table->proc_handler (table, write, buf, &res, ppos); + error = table->proc_handler (table, write, buf, &res, + ppos, head->ctl_header_cookie);if (!error) error = res; out:
fs/quota/dquot.c +3 -2
@@ -2517,14 +2517,15 @@ const struct quotactl_ops dquot_quotactl_ops = {EXPORT_SYMBOL (dquot_quotactl_ops);static int do_proc_dqstats (struct ctl_table *table,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie) {unsigned int type = (int *)table->data - dqstats.stat;/* Update global table */ dqstats.stat[type] =percpu_counter_sum_positive (&dqstats.counter[type]); -return proc_dointvec (table, write, buffer, lenp, ppos); +return proc_dointvec (table, write, buffer, lenp, ppos,NULL ); }static ctl_table fs_dqstats_table[] = {
fs/xfs/linux-2.6/xfs_sysctl.c +6 -4
@@ -29,12 +29,13 @@ xfs_stats_clear_proc_handler(int write, void __user *buffer, size_t *lenp, - loff_t *ppos) + loff_t *ppos, + void *cookie) { int c, ret, *valp = ctl->data;__uint32_t vn_active; - ret =proc_dointvec_minmax (ctl, write, buffer, lenp, ppos); + ret =proc_dointvec_minmax (ctl, write, buffer, lenp, ppos,NULL );if (!ret && write && *valp) {xfs_notice (NULL ,"Clearing xfsstats" );
@@ -59,11 +60,12 @@ xfs_panic_mask_proc_handler(int write, void __user *buffer, size_t *lenp, - loff_t *ppos) + loff_t *ppos, + void *cookie) { int ret, *valp = ctl->data; - ret =proc_dointvec_minmax (ctl, write, buffer, lenp, ppos); + ret =proc_dointvec_minmax (ctl, write, buffer, lenp, ppos,NULL );if (!ret && write) { xfs_panic_mask = *valp;#ifdef DEBUG
include/linux/compaction.h +4 -2
@@ -14,10 +14,12 @@#ifdef CONFIG_COMPACTION extern int sysctl_compact_memory;extern int sysctl_compaction_handler (struct ctl_table *table,int write, -void __user *buffer,size_t *length,loff_t *ppos); +void __user *buffer,size_t *length, +loff_t *ppos,void *cookie);extern int sysctl_extfrag_threshold;extern int sysctl_extfrag_handler (struct ctl_table *table,int write, -void __user *buffer,size_t *length,loff_t *ppos); +void __user *buffer,size_t *length, +loff_t *ppos,void *cookie);extern int fragmentation_index (struct zone *zone,unsigned int order); extern unsigned long try_to_compact_pages(struct zonelist *zonelist,
include/linux/fs.h +6 -6
@@ -2562,12 +2562,12 @@ ssize_t simple_attr_write(struct file *file, const char __user *buf, size_t len, loff_t *ppos);struct ctl_table ; -int proc_nr_files (struct ctl_table *table,int write, -void __user *buffer,size_t *lenp,loff_t *ppos); -int proc_nr_dentry (struct ctl_table *table,int write, -void __user *buffer,size_t *lenp,loff_t *ppos); -int proc_nr_inodes (struct ctl_table *table,int write, -void __user *buffer,size_t *lenp,loff_t *ppos); +int proc_nr_files (struct ctl_table *table,int write,void __user *buffer, +size_t *lenp,loff_t *ppos,void *cookie); +int proc_nr_dentry (struct ctl_table *table,int write,void __user *buffer, +size_t *lenp,loff_t *ppos,void *cookie); +int proc_nr_inodes (struct ctl_table *table,int write,void __user *buffer, +size_t *lenp,loff_t *ppos,void *cookie);int __init get_filesystem_list (char *buf);#define __FMODE_EXEC ((__force int) FMODE_EXEC)
include/linux/ftrace.h +2 -2
@@ -25,7 +25,7 @@ extern int ftrace_enabled;extern int ftrace_enable_sysctl (struct ctl_table *table,int write,void __user *buffer,size_t *lenp, -loff_t *ppos); +loff_t *ppos,void *cookie);typedef void (*ftrace_func_t )(unsigned long ip,unsigned long parent_ip);
@@ -104,7 +104,7 @@ extern int stack_tracer_enabled;int stack_trace_sysctl (struct ctl_table *table,int write,void __user *buffer,size_t *lenp, -loff_t *ppos); +loff_t *ppos,void *cookie);#endif struct ftrace_func_command {
include/linux/hugetlb.h +8 -5
@@ -16,13 +16,16 @@ struct user_struct;int PageHuge (struct page *page);void reset_vma_resv_huge_pages (struct vm_area_struct *vma); -int hugetlb_sysctl_handler (struct ctl_table *,int ,void __user *,size_t *,loff_t *); -int hugetlb_overcommit_handler (struct ctl_table *,int ,void __user *,size_t *,loff_t *); -int hugetlb_treat_movable_handler (struct ctl_table *,int ,void __user *,size_t *,loff_t *); +int hugetlb_sysctl_handler (struct ctl_table *,int ,void __user *, +size_t *,loff_t *,void *); +int hugetlb_overcommit_handler (struct ctl_table *,int ,void __user *, +size_t *,loff_t *,void *); +int hugetlb_treat_movable_handler (struct ctl_table *,int ,void __user *, +size_t *,loff_t *,void *);#ifdef CONFIG_NUMA -int hugetlb_mempolicy_sysctl_handler (struct ctl_table *,int , -void __user *,size_t *,loff_t *); +int hugetlb_mempolicy_sysctl_handler (struct ctl_table *,int ,void __user *, +size_t *,loff_t *,void *);#endif int copy_hugetlb_page_range (struct mm_struct *,struct mm_struct *,struct vm_area_struct *);
include/linux/kprobes.h +3 -3
@@ -288,9 +288,9 @@ extern void opt_pre_handler(struct kprobe *p, struct pt_regs *regs);#ifdef CONFIG_SYSCTL extern int sysctl_kprobes_optimization; -extern int proc_kprobes_optimization_handler (struct ctl_table *table, -int write,void __user *buffer, -size_t *length,loff_t *ppos); +extern int proc_kprobes_optimization_handler (struct ctl_table *table,int write, +void __user *buffer,size_t *len, +loff_t *ppos,void *cookie);#endif #endif /* CONFIG_OPTPROBES */
include/linux/mm.h +2 -2
@@ -1602,8 +1602,8 @@ int in_gate_area_no_mm(unsigned long addr);#define in_gate_area (mm, addr) ({(void)mm; in_gate_area_no_mm(addr);})#endif /* __HAVE_ARCH_GATE_AREA */ -int drop_caches_sysctl_handler (struct ctl_table *,int , -void __user *,size_t *,loff_t *); +int drop_caches_sysctl_handler (struct ctl_table *,int ,void __user *, +size_t *,loff_t *,void *);unsigned long shrink_slab (unsigned long scanned,gfp_t gfp_mask,unsigned long lru_pages);
include/linux/mmzone.h +12 -11
@@ -764,20 +764,21 @@ static inline int is_dma(struct zone *zone)/* These two functions are used to setup the per zone pages min values */ struct ctl_table ; -int min_free_kbytes_sysctl_handler (struct ctl_table *,int , -void __user *,size_t *,loff_t *); +int min_free_kbytes_sysctl_handler (struct ctl_table *,int ,void __user *, +size_t *,loff_t *,void *);extern int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES -1 ]; -int lowmem_reserve_ratio_sysctl_handler (struct ctl_table *,int , -void __user *,size_t *,loff_t *); +int lowmem_reserve_ratio_sysctl_handler (struct ctl_table *,int ,void __user *, +size_t *,loff_t *,void *);int percpu_pagelist_fraction_sysctl_handler (struct ctl_table *,int , -void __user *,size_t *,loff_t *); +void __user *,size_t *, +loff_t *,void *);int sysctl_min_unmapped_ratio_sysctl_handler (struct ctl_table *,int , -void __user *,size_t *,loff_t *); -int sysctl_min_slab_ratio_sysctl_handler (struct ctl_table *,int , -void __user *,size_t *,loff_t *); - -extern int numa_zonelist_order_handler (struct ctl_table *,int , -void __user *,size_t *,loff_t *); +void __user *,size_t *, +loff_t *,void *); +int sysctl_min_slab_ratio_sysctl_handler (struct ctl_table *,int ,void __user *, +size_t *,loff_t *,void *); +int numa_zonelist_order_handler (struct ctl_table *,int ,void __user *, +size_t *,loff_t *,void *);extern char numa_zonelist_order[];#define NUMA_ZONELIST_ORDER_LEN 16/* string buffer size */
include/linux/nmi.h +2 -2
@@ -48,8 +48,8 @@ int hw_nmi_is_cpu_stuck(struct pt_regs *);u64 hw_nmi_get_sample_period (void );extern int watchdog_enabled;struct ctl_table ; -extern int proc_dowatchdog_enabled (struct ctl_table *,int , -void __user *,size_t *,loff_t *); +extern int proc_dowatchdog_enabled (struct ctl_table *,int ,void __user *, +size_t *,loff_t *,void *);#endif #endif
include/linux/perf_event.h +1 -1
@@ -1119,7 +1119,7 @@ extern int sysctl_perf_event_sample_rate;extern int perf_proc_update_handler (struct ctl_table *table,int write,void __user *buffer,size_t *lenp, -loff_t *ppos); +loff_t *ppos,void *cookie);static inline bool perf_paranoid_tracepoint_raw (void ) {
include/linux/pipe_fs_i.h +1 -1
@@ -141,7 +141,7 @@ void pipe_unlock(struct pipe_inode_info *);void pipe_double_lock (struct pipe_inode_info *,struct pipe_inode_info *);extern unsigned int pipe_max_size, pipe_min_size; -int pipe_proc_fn (struct ctl_table *,int ,void __user *,size_t *,loff_t *); +int pipe_proc_fn (struct ctl_table *,int ,void __user *,size_t *,loff_t *,void *);/* Drop the inode semaphore and wait for a pipe event, atomically */
include/linux/sched.h +8 -8
@@ -312,8 +312,8 @@ extern void touch_softlockup_watchdog(void);extern void touch_softlockup_watchdog_sync (void );extern void touch_all_softlockup_watchdogs (void );extern int proc_dowatchdog_thresh (struct ctl_table *table,int write, -void __user *buffer, -size_t *lenp,loff_t *ppos); +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie);extern unsigned int softlockup_panic;extern int softlockup_thresh;void lockup_detector_init (void );
@@ -338,8 +338,8 @@ extern unsigned long sysctl_hung_task_check_count;extern unsigned long sysctl_hung_task_timeout_secs;extern unsigned long sysctl_hung_task_warnings;extern int proc_dohung_task_timeout_secs (struct ctl_table *table,int write, -void __user *buffer, -size_t *lenp,loff_t *ppos); +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie);#else /* Avoid need for ifdefs elsewhere in the code */ enum { sysctl_hung_task_timeout_secs =0 };
@@ -1929,8 +1929,8 @@ extern unsigned int sysctl_timer_migration;extern unsigned int sysctl_sched_shares_window;int sched_proc_update_handler (struct ctl_table *table,int write, -void __user *buffer,size_t *length, -loff_t *ppos); +void __user *buffer,size_t *length, +loff_t *ppos,void *cookie);#endif #ifdef CONFIG_SCHED_DEBUG static inline unsigned int get_sysctl_timer_migration (void )
@@ -1947,8 +1947,8 @@ extern unsigned int sysctl_sched_rt_period;extern int sysctl_sched_rt_runtime;int sched_rt_handler (struct ctl_table *table,int write, -void __user *buffer,size_t *lenp, -loff_t *ppos); +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie);#ifdef CONFIG_SCHED_AUTOGROUP extern unsigned int sysctl_sched_autogroup_enabled;
include/linux/security.h +2 -1
@@ -144,7 +144,8 @@ static inline unsigned long round_hint_to_min(unsigned long hint) return hint; }extern int mmap_min_addr_handler (struct ctl_table *table,int write, -void __user *buffer,size_t *lenp,loff_t *ppos); +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie);#endif #ifdef CONFIG_SECURITY
include/linux/swap.h +2 -2
@@ -281,8 +281,8 @@ extern int page_evictable(struct page *page, struct vm_area_struct *vma);extern void scan_mapping_unevictable_pages (struct address_space *);extern unsigned long scan_unevictable_pages; -extern int scan_unevictable_handler (struct ctl_table *,int , -void __user *,size_t *,loff_t *); +extern int scan_unevictable_handler (struct ctl_table *,int ,void __user *, +size_t *,loff_t *,void *);#ifdef CONFIG_NUMA extern int scan_unevictable_register_node (struct node *node);extern void scan_unevictable_unregister_node (struct node *node);
include/linux/sysctl.h +20 -10
@@ -963,26 +963,36 @@ extern int sysctl_perm(struct ctl_table_root *root,typedef struct ctl_table ctl_table ;typedef int proc_handler (struct ctl_table *ctl,int write, -void __user *buffer,size_t *lenp,loff_t *ppos); +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie);extern int proc_dostring (struct ctl_table *,int , -void __user *,size_t *,loff_t *); +void __user *,size_t *, +loff_t *,void *);extern int proc_dointvec (struct ctl_table *,int , -void __user *,size_t *,loff_t *); +void __user *,size_t *, +loff_t *,void *);extern int proc_dointvec_minmax (struct ctl_table *,int , -void __user *,size_t *,loff_t *); +void __user *,size_t *, +loff_t *,void *);extern int proc_dointvec_jiffies (struct ctl_table *,int , -void __user *,size_t *,loff_t *); +void __user *,size_t *, +loff_t *,void *);extern int proc_dointvec_userhz_jiffies (struct ctl_table *,int , -void __user *,size_t *,loff_t *); +void __user *,size_t *, +loff_t *,void *);extern int proc_dointvec_ms_jiffies (struct ctl_table *,int , -void __user *,size_t *,loff_t *); +void __user *,size_t *, +loff_t *,void *);extern int proc_doulongvec_minmax (struct ctl_table *,int , -void __user *,size_t *,loff_t *); +void __user *,size_t *, +loff_t *,void *);extern int proc_doulongvec_ms_jiffies_minmax (struct ctl_table *table,int , -void __user *,size_t *,loff_t *); +void __user *,size_t *, +loff_t *,void *);extern int proc_do_large_bitmap (struct ctl_table *,int , -void __user *,size_t *,loff_t *); +void __user *,size_t *, +loff_t *,void *);/* * Register a set of sysctl names by calling register_sysctl_table
include/linux/writeback.h +6 -12
@@ -108,21 +108,15 @@ extern int laptop_mode;extern unsigned long determine_dirtyable_memory (void );extern int dirty_background_ratio_handler (struct ctl_table *table,int write, -void __user *buffer,size_t *lenp, -loff_t *ppos); +void __user *buffer,size_t *lenp,loff_t *ppos,void *cookie);extern int dirty_background_bytes_handler (struct ctl_table *table,int write, -void __user *buffer,size_t *lenp, -loff_t *ppos); +void __user *buffer,size_t *lenp,loff_t *ppos,void *cookie);extern int dirty_ratio_handler (struct ctl_table *table,int write, -void __user *buffer,size_t *lenp, -loff_t *ppos); +void __user *buffer,size_t *lenp,loff_t *ppos,void *cookie);extern int dirty_bytes_handler (struct ctl_table *table,int write, -void __user *buffer,size_t *lenp, -loff_t *ppos); - -struct ctl_table ; -int dirty_writeback_centisecs_handler (struct ctl_table *,int , -void __user *,size_t *,loff_t *); +void __user *buffer,size_t *lenp,loff_t *ppos,void *cookie); +extern int dirty_writeback_centisecs_handler (struct ctl_table *table,int write, +void __user *buffer,size_t *lenp,loff_t *ppos,void *cookie);void global_dirty_limits (unsigned long *pbackground,unsigned long *pdirty); unsigned long bdi_dirty_limit(struct backing_dev_info *bdi,
include/net/ndisc.h +5 -2
@@ -137,10 +137,13 @@ extern int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl,int write, void __user *buffer, size_t *lenp, - loff_t *ppos); + loff_t *ppos, + void *cookie); +int ndisc_ifinfo_sysctl_strategy (ctl_table *ctl,void __user *oldval,size_t __user *oldlenp, -void __user *newval,size_t newlen); +void __user *newval,size_t newlen, +void *cookie);#endif extern void inet6_ifinfo_notify(int event,
ipc/ipc_sysctl.c +12 -9
@@ -27,18 +27,19 @@ static void *get_ipc(ctl_table *table) }#ifdef CONFIG_PROC_SYSCTL -static int proc_ipc_dointvec (ctl_table *table,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +static int proc_ipc_dointvec (ctl_table *table,int write,void __user *buffer, +size_t *lenp,loff_t *ppos,void *cookie) {struct ctl_table ipc_table;memcpy (&ipc_table, table,sizeof (ipc_table)); ipc_table.data =get_ipc (table); -return proc_dointvec (&ipc_table, write, buffer, lenp, ppos); +return proc_dointvec (&ipc_table, write, buffer, lenp, ppos,NULL ); }static int proc_ipc_callback_dointvec (ctl_table *table,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie) {struct ctl_table ipc_table;size_t lenp_bef = *lenp;
@@ -47,7 +48,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,memcpy (&ipc_table, table,sizeof (ipc_table)); ipc_table.data =get_ipc (table); - rc =proc_dointvec (&ipc_table, write, buffer, lenp, ppos); + rc =proc_dointvec (&ipc_table, write, buffer, lenp, ppos,NULL );if (write && !rc && lenp_bef == *lenp)/*
@@ -61,14 +62,15 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write, }static int proc_ipc_doulongvec_minmax (ctl_table *table,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie) {struct ctl_table ipc_table;memcpy (&ipc_table, table,sizeof (ipc_table)); ipc_table.data =get_ipc (table);return proc_doulongvec_minmax (&ipc_table, write, buffer, - lenp, ppos); + lenp, ppos,NULL ); }/*
@@ -95,7 +97,8 @@ static void ipc_auto_callback(int val) }static int proc_ipcauto_dointvec_minmax (ctl_table *table,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie) {struct ctl_table ipc_table;size_t lenp_bef = *lenp;
@@ -106,7 +109,7 @@ static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write, ipc_table.data =get_ipc (table); oldval = *((int *)(ipc_table.data)); - rc =proc_dointvec_minmax (&ipc_table, write, buffer, lenp, ppos); + rc =proc_dointvec_minmax (&ipc_table, write, buffer, lenp, ppos,NULL );if (write && !rc && lenp_bef == *lenp) {int newval = *((int *)(ipc_table.data));
ipc/mq_sysctl.c +6 -5
@@ -31,25 +31,26 @@ static void *get_mq(ctl_table *table)return which; } -static int proc_mq_dointvec (ctl_table *table,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +static int proc_mq_dointvec (ctl_table *table,int write,void __user *buffer, +size_t *lenp,loff_t *ppos,void *cookie) {struct ctl_table mq_table;memcpy (&mq_table, table,sizeof (mq_table)); mq_table.data =get_mq (table); -return proc_dointvec (&mq_table, write, buffer, lenp, ppos); +return proc_dointvec (&mq_table, write, buffer, lenp, ppos,NULL ); }static int proc_mq_dointvec_minmax (ctl_table *table,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie) {struct ctl_table mq_table;memcpy (&mq_table, table,sizeof (mq_table)); mq_table.data =get_mq (table);return proc_dointvec_minmax (&mq_table, write, buffer, - lenp, ppos); + lenp, ppos,NULL ); }#else #define proc_mq_dointvec NULL
kernel/hung_task.c +3 -3
@@ -171,12 +171,12 @@ static unsigned long timeout_jiffies(unsigned long timeout)* Process updating of timeout sysctl */ int proc_dohung_task_timeout_secs (struct ctl_table *table,int write, -void __user *buffer, -size_t *lenp,loff_t *ppos) +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie) {int ret; - ret =proc_doulongvec_minmax (table, write, buffer, lenp, ppos); + ret =proc_doulongvec_minmax (table, write, buffer, lenp, ppos,NULL );if (ret || !write) goto out;
kernel/kprobes.c +2 -2
@@ -826,13 +826,13 @@ static void __kprobes unoptimize_all_kprobes(void)int sysctl_kprobes_optimization;int proc_kprobes_optimization_handler (struct ctl_table *table,int write,void __user *buffer,size_t *length, -loff_t *ppos) +loff_t *ppos,void *cookie) {int ret;mutex_lock (&kprobe_mutex); sysctl_kprobes_optimization = kprobes_allow_optimization ?1 :0 ; - ret =proc_dointvec_minmax (table, write, buffer, length, ppos); + ret =proc_dointvec_minmax (table, write, buffer, length, ppos,NULL );if (sysctl_kprobes_optimization)optimize_all_kprobes ();
kernel/perf_event.c +2 -2
@@ -158,9 +158,9 @@ static int max_samples_per_tick __read_mostly =int perf_proc_update_handler (struct ctl_table *table,int write,void __user *buffer,size_t *lenp, -loff_t *ppos) +loff_t *ppos,void *cookie) { -int ret =proc_dointvec (table, write, buffer, lenp, ppos); +int ret =proc_dointvec (table, write, buffer, lenp, ppos,NULL );if (ret || !write)return ret;
kernel/sched.c +2 -2
@@ -8982,7 +8982,7 @@ static int sched_rt_global_constraints(void)int sched_rt_handler (struct ctl_table *table,int write,void __user *buffer,size_t *lenp, -loff_t *ppos) +loff_t *ppos,void *cookie) {int ret;int old_period, old_runtime;
@@ -8992,7 +8992,7 @@ int sched_rt_handler(struct ctl_table *table, int write, old_period = sysctl_sched_rt_period; old_runtime = sysctl_sched_rt_runtime; - ret =proc_dointvec (table, write, buffer, lenp, ppos); + ret =proc_dointvec (table, write, buffer, lenp, ppos,NULL );if (!ret && write) { ret =sched_rt_global_constraints ();
kernel/sched_fair.c +2 -2
@@ -448,9 +448,9 @@ static struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq)int sched_proc_update_handler (struct ctl_table *table,int write,void __user *buffer,size_t *lenp, -loff_t *ppos) +loff_t *ppos,void *cookie) { -int ret =proc_dointvec_minmax (table, write, buffer, lenp, ppos); +int ret =proc_dointvec_minmax (table, write, buffer, lenp, ppos,NULL );int factor =get_update_sysctl_factor ();if (ret || !write)
kernel/sysctl.c +60 -31
288 lines not on this page · raw message
kernel/trace/ftrace.c +2 -2
@@ -3178,7 +3178,7 @@ int unregister_ftrace_function(struct ftrace_ops *ops)int ftrace_enable_sysctl (struct ctl_table *table,int write,void __user *buffer,size_t *lenp, -loff_t *ppos) +loff_t *ppos,void *cookie) {int ret;
@@ -3187,7 +3187,7 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,mutex_lock (&ftrace_lock); - ret =proc_dointvec (table, write, buffer, lenp, ppos); + ret =proc_dointvec (table, write, buffer, lenp, ppos,NULL );if (ret || !write || (last_ftrace_enabled == !!ftrace_enabled)) goto out;
kernel/trace/trace_stack.c +2 -2
@@ -322,13 +322,13 @@ static const struct file_operations stack_trace_fops = {int stack_trace_sysctl (struct ctl_table *table,int write,void __user *buffer,size_t *lenp, -loff_t *ppos) +loff_t *ppos,void *cookie) {int ret;mutex_lock (&stack_sysctl_mutex); - ret =proc_dointvec (table, write, buffer, lenp, ppos); + ret =proc_dointvec (table, write, buffer, lenp, ppos,NULL );if (ret || !write || (last_stack_tracer_enabled == !!stack_tracer_enabled))
kernel/utsname_sysctl.c +3 -3
@@ -42,14 +42,14 @@ static void put_uts(ctl_table *table, int write, void *which)* Special case of dostring for the UTS structure. This has locks * to observe. Should this be in kernel/sys.c ???? */ -static int proc_do_uts_string (ctl_table *table,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +static int proc_do_uts_string (ctl_table *table,int write,void __user *buffer, +size_t *lenp,loff_t *ppos,void *cookie) {struct ctl_table uts_table;int r;memcpy (&uts_table, table,sizeof (uts_table)); uts_table.data =get_uts (table, write); - r =proc_dostring (&uts_table,write,buffer,lenp, ppos); + r =proc_dostring (&uts_table,write,buffer,lenp, ppos,NULL );put_uts (table, write, uts_table.data);return r; }
kernel/watchdog.c +6 -5
@@ -502,9 +502,10 @@ static void watchdog_disable_all_cpus(void)*/ int proc_dowatchdog_enabled (struct ctl_table *table,int write, -void __user *buffer,size_t *length,loff_t *ppos) +void __user *buffer,size_t *length, +loff_t *ppos,void *cookie) { -proc_dointvec (table, write, buffer, length, ppos); +proc_dointvec (table, write, buffer, length, ppos,NULL );if (write) {if (watchdog_enabled)
@@ -516,10 +517,10 @@ int proc_dowatchdog_enabled(struct ctl_table *table, int write, }int proc_dowatchdog_thresh (struct ctl_table *table,int write, -void __user *buffer, -size_t *lenp,loff_t *ppos) +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie) { -return proc_dointvec_minmax (table, write, buffer, lenp, ppos); +return proc_dointvec_minmax (table, write, buffer, lenp, ppos,NULL ); }#endif /* CONFIG_SYSCTL */
mm/compaction.c +5 -3
@@ -676,7 +676,8 @@ int sysctl_compact_memory;/* This is the entry point for compacting all nodes via /proc/sys/vm */ int sysctl_compaction_handler (struct ctl_table *table,int write, -void __user *buffer,size_t *length,loff_t *ppos) +void __user *buffer,size_t *length, +loff_t *ppos,void *cookie) {if (write)return compact_nodes ();
@@ -685,9 +686,10 @@ int sysctl_compaction_handler(struct ctl_table *table, int write, }int sysctl_extfrag_handler (struct ctl_table *table,int write, -void __user *buffer,size_t *length,loff_t *ppos) +void __user *buffer,size_t *length, +loff_t *ppos,void *cookie) { -proc_dointvec_minmax (table, write, buffer, length, ppos); +proc_dointvec_minmax (table, write, buffer, length, ppos,NULL );return 0 ; }
mm/hugetlb.c +13 -11
@@ -1879,7 +1879,7 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy, table->data = &tmp; table->maxlen =sizeof (unsigned long ); - ret =proc_doulongvec_minmax (table, write, buffer, length, ppos); + ret =proc_doulongvec_minmax (table, write, buffer, length, ppos,NULL );if (ret) goto out;
@@ -1901,27 +1901,29 @@ out: }int hugetlb_sysctl_handler (struct ctl_table *table,int write, -void __user *buffer,size_t *length,loff_t *ppos) +void __user *buffer,size_t *length, +loff_t *ppos,void *cookie) {return hugetlb_sysctl_handler_common (false, table, write, - buffer, length, ppos); + buffer, length, ppos); }#ifdef CONFIG_NUMA int hugetlb_mempolicy_sysctl_handler (struct ctl_table *table,int write, -void __user *buffer,size_t *length,loff_t *ppos) +void __user *buffer,size_t *length, +loff_t *ppos,void *cookie) {return hugetlb_sysctl_handler_common (true, table, write, - buffer, length, ppos); + buffer, length, ppos); }#endif /* CONFIG_NUMA */ int hugetlb_treat_movable_handler (struct ctl_table *table,int write, -void __user *buffer, -size_t *length,loff_t *ppos) +void __user *buffer,size_t *length, +loff_t *ppos,void *cookie) { -proc_dointvec (table, write, buffer, length, ppos); +proc_dointvec (table, write, buffer, length, ppos,NULL );if (hugepages_treat_as_movable) htlb_alloc_mask =GFP_HIGHUSER_MOVABLE ;else
@@ -1930,8 +1932,8 @@ int hugetlb_treat_movable_handler(struct ctl_table *table, int write, }int hugetlb_overcommit_handler (struct ctl_table *table,int write, -void __user *buffer, -size_t *length,loff_t *ppos) +void __user *buffer,size_t *length, +loff_t *ppos,void *cookie) {struct hstate *h = &default_hstate;unsigned long tmp;
@@ -1944,7 +1946,7 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write, table->data = &tmp; table->maxlen =sizeof (unsigned long ); - ret =proc_doulongvec_minmax (table, write, buffer, length, ppos); + ret =proc_doulongvec_minmax (table, write, buffer, length, ppos,NULL );if (ret) goto out;
mm/page-writeback.c +10 -14
@@ -159,37 +159,34 @@ static void update_completion_period(void) }int dirty_background_ratio_handler (struct ctl_table *table,int write, -void __user *buffer,size_t *lenp, -loff_t *ppos) +void __user *buffer,size_t *lenp,loff_t *ppos,void *cookie) {int ret; - ret =proc_dointvec_minmax (table, write, buffer, lenp, ppos); + ret =proc_dointvec_minmax (table, write, buffer, lenp, ppos,NULL );if (ret ==0 && write) dirty_background_bytes =0 ;return ret; }int dirty_background_bytes_handler (struct ctl_table *table,int write, -void __user *buffer,size_t *lenp, -loff_t *ppos) +void __user *buffer,size_t *lenp,loff_t *ppos,void *cookie) {int ret; - ret =proc_doulongvec_minmax (table, write, buffer, lenp, ppos); + ret =proc_doulongvec_minmax (table, write, buffer, lenp, ppos,NULL );if (ret ==0 && write) dirty_background_ratio =0 ;return ret; }int dirty_ratio_handler (struct ctl_table *table,int write, -void __user *buffer,size_t *lenp, -loff_t *ppos) +void __user *buffer,size_t *lenp,loff_t *ppos,void *cookie) {int old_ratio = vm_dirty_ratio;int ret; - ret =proc_dointvec_minmax (table, write, buffer, lenp, ppos); + ret =proc_dointvec_minmax (table, write, buffer, lenp, ppos,NULL );if (ret ==0 && write && vm_dirty_ratio != old_ratio) {update_completion_period (); vm_dirty_bytes =0 ;
@@ -199,13 +196,12 @@ int dirty_ratio_handler(struct ctl_table *table, int write,int dirty_bytes_handler (struct ctl_table *table,int write, -void __user *buffer,size_t *lenp, -loff_t *ppos) +void __user *buffer,size_t *lenp,loff_t *ppos,void *cookie) {unsigned long old_bytes = vm_dirty_bytes;int ret; - ret =proc_doulongvec_minmax (table, write, buffer, lenp, ppos); + ret =proc_doulongvec_minmax (table, write, buffer, lenp, ppos,NULL );if (ret ==0 && write && vm_dirty_bytes != old_bytes) {update_completion_period (); vm_dirty_ratio =0 ;
@@ -684,9 +680,9 @@ void throttle_vm_writeout(gfp_t gfp_mask)* sysctl handler for /proc/sys/vm/dirty_writeback_centisecs */ int dirty_writeback_centisecs_handler (ctl_table *table,int write, -void __user *buffer,size_t *length,loff_t *ppos) +void __user *buffer,size_t *lenp,loff_t *ppos,void *cookie) { -proc_dointvec (table, write, buffer, length, ppos); +proc_dointvec (table, write, buffer, lenp, ppos,NULL );bdi_arm_supers_timer ();return 0 ; }
mm/page_alloc.c +12 -13
@@ -2721,8 +2721,7 @@ early_param("numa_zonelist_order", setup_numa_zonelist_order);* sysctl handler for numa_zonelist_order */ int numa_zonelist_order_handler (ctl_table *table,int write, -void __user *buffer,size_t *length, -loff_t *ppos) +void __user *buffer,size_t *length,loff_t *ppos,void *cookie) {char saved_string[NUMA_ZONELIST_ORDER_LEN ];int ret;
@@ -2731,7 +2730,7 @@ int numa_zonelist_order_handler(ctl_table *table, int write,mutex_lock (&zl_order_mutex);if (write)strcpy (saved_string, (char *)table->data); - ret =proc_dostring (table, write, buffer, length, ppos); + ret =proc_dostring (table, write, buffer, length, ppos,NULL );if (ret) goto out;if (write) {
@@ -5142,9 +5141,9 @@ module_init(init_per_zone_wmark_min)* changes. */ int min_free_kbytes_sysctl_handler (ctl_table *table,int write, -void __user *buffer,size_t *length,loff_t *ppos) +void __user *buffer,size_t *length,loff_t *ppos,void *cookie) { -proc_dointvec (table, write, buffer, length, ppos); +proc_dointvec (table, write, buffer, length, ppos,NULL );if (write)setup_per_zone_wmarks ();return 0 ;
@@ -5152,12 +5151,12 @@ int min_free_kbytes_sysctl_handler(ctl_table *table, int write,#ifdef CONFIG_NUMA int sysctl_min_unmapped_ratio_sysctl_handler (ctl_table *table,int write, -void __user *buffer,size_t *length,loff_t *ppos) +void __user *buffer,size_t *length,loff_t *ppos,void *cookie) {struct zone *zone;int rc; - rc =proc_dointvec_minmax (table, write, buffer, length, ppos); + rc =proc_dointvec_minmax (table, write, buffer, length, ppos,NULL );if (rc)return rc;
@@ -5168,12 +5167,12 @@ int sysctl_min_unmapped_ratio_sysctl_handler(ctl_table *table, int write, }int sysctl_min_slab_ratio_sysctl_handler (ctl_table *table,int write, -void __user *buffer,size_t *length,loff_t *ppos) +void __user *buffer,size_t *length,loff_t *ppos,void *cookie) {struct zone *zone;int rc; - rc =proc_dointvec_minmax (table, write, buffer, length, ppos); + rc =proc_dointvec_minmax (table, write, buffer, length, ppos,NULL );if (rc)return rc;
@@ -5194,9 +5193,9 @@ int sysctl_min_slab_ratio_sysctl_handler(ctl_table *table, int write,* if in function of the boot time zone sizes. */ int lowmem_reserve_ratio_sysctl_handler (ctl_table *table,int write, -void __user *buffer,size_t *length,loff_t *ppos) +void __user *buffer,size_t *length,loff_t *ppos,void *cookie) { -proc_dointvec_minmax (table, write, buffer, length, ppos); +proc_dointvec_minmax (table, write, buffer, length, ppos,NULL );setup_per_zone_lowmem_reserve ();return 0 ; }
@@ -5208,13 +5207,13 @@ int lowmem_reserve_ratio_sysctl_handler(ctl_table *table, int write,*/ int percpu_pagelist_fraction_sysctl_handler (ctl_table *table,int write, -void __user *buffer,size_t *length,loff_t *ppos) +void __user *buffer,size_t *length,loff_t *ppos,void *cookie) {struct zone *zone;unsigned int cpu;int ret; - ret =proc_dointvec_minmax (table, write, buffer, length, ppos); + ret =proc_dointvec_minmax (table, write, buffer, length, ppos,NULL );if (!write || (ret == -EINVAL ))return ret;for_each_populated_zone (zone) {
mm/vmscan.c +3 -3
@@ -3273,10 +3273,10 @@ static void scan_all_zones_unevictable_pages(void)unsigned long scan_unevictable_pages;int scan_unevictable_handler (struct ctl_table *table,int write, -void __user *buffer, -size_t *length,loff_t *ppos) +void __user *buffer,size_t *length, +loff_t *ppos,void *cookie) { -proc_doulongvec_minmax (table, write, buffer, length, ppos); +proc_doulongvec_minmax (table, write, buffer, length, ppos,NULL );if (write && *(unsigned long *)table->data)scan_all_zones_unevictable_pages ();
net/bridge/br_netfilter.c +3 -3
@@ -932,12 +932,12 @@ static struct nf_hook_ops br_nf_ops[] __read_mostly = {#ifdef CONFIG_SYSCTL static -int brnf_sysctl_call_tables (ctl_table * ctl,int write, -void __user * buffer,size_t * lenp,loff_t * ppos) +int brnf_sysctl_call_tables (ctl_table * ctl,int write,void __user * buffer, +size_t * lenp,loff_t * ppos,void * cookie) {int ret; - ret =proc_dointvec (ctl, write, buffer, lenp, ppos); + ret =proc_dointvec (ctl, write, buffer, lenp, ppos,NULL );if (write && *(int *)(ctl->data)) *(int *)(ctl->data) =1 ;
net/core/sysctl_net_core.c +3 -2
@@ -20,7 +20,8 @@#ifdef CONFIG_RPS static int rps_sock_flow_sysctl (ctl_table *table,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie) {unsigned int orig_size, size;int ret, i;
@@ -38,7 +39,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write, lockdep_is_held(&sock_flow_mutex)); size = orig_size = orig_sock_table ? orig_sock_table->mask +1 :0 ; - ret =proc_dointvec (&tmp, write, buffer, lenp, ppos); + ret =proc_dointvec (&tmp, write, buffer, lenp, ppos,NULL );if (write) {if (size) {
net/decnet/dn_dev.c +5 -5
@@ -159,8 +159,8 @@ static int max_t3[] = { 8191 }; /* Must fit in 16 bits when multiplied by BCT3MUstatic int min_priority[1 ];static int max_priority[] = {127 };/* From DECnet spec */ -static int dn_forwarding_proc (ctl_table *,int , -void __user *,size_t *,loff_t *); +static int dn_forwarding_proc (ctl_table *,int ,void __user *, +size_t *,loff_t *,void *); static struct dn_dev_sysctl_table { struct ctl_table_header *sysctl_header; ctl_table dn_dev_vars[5];
@@ -255,8 +255,8 @@ static void dn_dev_sysctl_unregister(struct dn_dev_parms *parms) }static int dn_forwarding_proc (ctl_table *table,int write, -void __user *buffer, -size_t *lenp,loff_t *ppos) +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie) {#ifdef CONFIG_DECNET_ROUTER struct net_device *dev = table->extra1;
@@ -270,7 +270,7 @@ static int dn_forwarding_proc(ctl_table *table, int write, dn_db =rcu_dereference_raw (dev->dn_ptr); old = dn_db->parms.forwarding; - err =proc_dointvec (table, write, buffer, lenp, ppos); + err =proc_dointvec (table, write, buffer, lenp, ppos,NULL );if ((err >=0 ) && write) {if (dn_db->parms.forwarding <0 )
net/decnet/sysctl_net_decnet.c +4 -4
@@ -132,8 +132,8 @@ static int parse_addr(__le16 *addr, char *str) }static int dn_node_address_handler (ctl_table *table,int write, -void __user *buffer, -size_t *lenp,loff_t *ppos) +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie) {char addr[DN_ASCBUF_LEN ];size_t len;
@@ -183,8 +183,8 @@ static int dn_node_address_handler(ctl_table *table, int write, }static int dn_def_dev_handler (ctl_table *table,int write, -void __user *buffer, -size_t *lenp,loff_t *ppos) +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie) {size_t len;struct net_device *dev;
net/ipv4/devinet.c +9 -9
@@ -1487,10 +1487,10 @@ static void inet_forward_change(struct net *net) }static int devinet_conf_proc (ctl_table *ctl,int write, -void __user *buffer, -size_t *lenp,loff_t *ppos) +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie) { -int ret =proc_dointvec (ctl, write, buffer, lenp, ppos); +int ret =proc_dointvec (ctl, write, buffer, lenp, ppos,NULL );if (write) {struct ipv4_devconf *cnf = ctl->extra1;
@@ -1507,13 +1507,13 @@ static int devinet_conf_proc(ctl_table *ctl, int write, }static int devinet_sysctl_forward (ctl_table *ctl,int write, -void __user *buffer, -size_t *lenp,loff_t *ppos) +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie) {int *valp = ctl->data;int val = *valp;loff_t pos = *ppos; -int ret =proc_dointvec (ctl, write, buffer, lenp, ppos); +int ret =proc_dointvec (ctl, write, buffer, lenp, ppos,NULL );if (write && *valp != val) {struct net *net = ctl->extra2;
@@ -1542,12 +1542,12 @@ static int devinet_sysctl_forward(ctl_table *ctl, int write, }static int ipv4_doint_and_flush (ctl_table *ctl,int write, -void __user *buffer, -size_t *lenp,loff_t *ppos) +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie) {int *valp = ctl->data;int val = *valp; -int ret =proc_dointvec (ctl, write, buffer, lenp, ppos); +int ret =proc_dointvec (ctl, write, buffer, lenp, ppos,NULL );struct net *net = ctl->extra2;if (write && *valp != val)
net/ipv4/route.c +3 -3
@@ -3009,8 +3009,8 @@ void ip_rt_multicast_event(struct in_device *in_dev)#ifdef CONFIG_SYSCTL static int ipv4_sysctl_rtcache_flush (ctl_table *__ctl,int write, -void __user *buffer, -size_t *lenp,loff_t *ppos) +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie) {if (write) {int flush_delay;
@@ -3019,7 +3019,7 @@ static int ipv4_sysctl_rtcache_flush(ctl_table *__ctl, int write,memcpy (&ctl, __ctl,sizeof (ctl)); ctl.data = &flush_delay; -proc_dointvec (&ctl, write, buffer, lenp, ppos); +proc_dointvec (&ctl, write, buffer, lenp, ppos,NULL ); net = (struct net *)__ctl->extra1;rt_cache_flush (net, flush_delay);
net/ipv4/sysctl_net_ipv4.c +12 -13
@@ -42,8 +42,8 @@ static void set_local_port_range(int range[2])/* Validate changes from /proc interface. */ static int ipv4_local_port_range (ctl_table *table,int write, -void __user *buffer, -size_t *lenp,loff_t *ppos) +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie) {int ret;int range[2 ];
@@ -56,7 +56,7 @@ static int ipv4_local_port_range(ctl_table *table, int write, };inet_get_local_port_range (range, range +1 ); - ret =proc_dointvec_minmax (&tmp, write, buffer, lenp, ppos); + ret =proc_dointvec_minmax (&tmp, write, buffer, lenp, ppos,NULL );if (write && ret ==0 ) {if (range[1 ] < range[0 ])
@@ -69,7 +69,8 @@ static int ipv4_local_port_range(ctl_table *table, int write, }static int proc_tcp_congestion_control (ctl_table *ctl,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie) {char val[TCP_CA_NAME_MAX ];ctl_table tbl = {
@@ -80,16 +81,15 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,tcp_get_default_congestion_control (val); - ret =proc_dostring (&tbl, write, buffer, lenp, ppos); + ret =proc_dostring (&tbl, write, buffer, lenp, ppos,NULL );if (write && ret ==0 ) ret =tcp_set_default_congestion_control (val);return ret; } -static int proc_tcp_available_congestion_control (ctl_table *ctl, -int write, +static int proc_tcp_available_congestion_control (ctl_table *ctl,int write,void __user *buffer,size_t *lenp, -loff_t *ppos) +loff_t *ppos,void *cookie) {ctl_table tbl = { .maxlen =TCP_CA_BUF_MAX , };int ret;
@@ -98,15 +98,14 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,if (!tbl.data)return -ENOMEM ;tcp_get_available_congestion_control (tbl.data,TCP_CA_BUF_MAX ); - ret =proc_dostring (&tbl, write, buffer, lenp, ppos); + ret =proc_dostring (&tbl, write, buffer, lenp, ppos,NULL );kfree (tbl.data);return ret; } -static int proc_allowed_congestion_control (ctl_table *ctl, -int write, +static int proc_allowed_congestion_control (ctl_table *ctl,int write,void __user *buffer,size_t *lenp, -loff_t *ppos) +loff_t *ppos,void *cookie) {ctl_table tbl = { .maxlen =TCP_CA_BUF_MAX };int ret;
@@ -116,7 +115,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,return -ENOMEM ;tcp_get_allowed_congestion_control (tbl.data, tbl.maxlen); - ret =proc_dostring (&tbl, write, buffer, lenp, ppos); + ret =proc_dostring (&tbl, write, buffer, lenp, ppos,NULL );if (write && ret ==0 ) ret =tcp_set_allowed_congestion_control (tbl.data);kfree (tbl.data);
net/ipv6/addrconf.c +6 -6
@@ -4156,15 +4156,15 @@ static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)#ifdef CONFIG_SYSCTL static -int addrconf_sysctl_forward (ctl_table *ctl,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +int addrconf_sysctl_forward (ctl_table *ctl,int write,void __user *buffer, +size_t *lenp,loff_t *ppos,void *cookie) {int *valp = ctl->data;int val = *valp;loff_t pos = *ppos;int ret; - ret =proc_dointvec (ctl, write, buffer, lenp, ppos); + ret =proc_dointvec (ctl, write, buffer, lenp, ppos,NULL );if (write) ret =addrconf_fixup_forwarding (ctl, valp, val);
@@ -4229,15 +4229,15 @@ static int addrconf_disable_ipv6(struct ctl_table *table, int *p, int old) }static -int addrconf_sysctl_disable (ctl_table *ctl,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +int addrconf_sysctl_disable (ctl_table *ctl,int write,void __user *buffer, +size_t *lenp,loff_t *ppos,void *cookie) {int *valp = ctl->data;int val = *valp;loff_t pos = *ppos;int ret; - ret =proc_dointvec (ctl, write, buffer, lenp, ppos); + ret =proc_dointvec (ctl, write, buffer, lenp, ppos,NULL );if (write) ret =addrconf_disable_ipv6 (ctl, valp, val);
net/ipv6/ndisc.c +8 -6
@@ -1751,7 +1751,9 @@ static void ndisc_warn_deprecated_sysctl(struct ctl_table *ctl, } } -int ndisc_ifinfo_sysctl_change (struct ctl_table *ctl,int write,void __user *buffer,size_t *lenp,loff_t *ppos) +int ndisc_ifinfo_sysctl_change (struct ctl_table *ctl,int write, +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie) {struct net_device *dev = ctl->extra1;struct inet6_dev *idev;
@@ -1762,16 +1764,16 @@ int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write, void __user *bundisc_warn_deprecated_sysctl (ctl,"syscall" , dev ? dev->name :"default" );if (strcmp (ctl->procname,"retrans_time" ) ==0 ) - ret =proc_dointvec (ctl, write, buffer, lenp, ppos); + ret =proc_dointvec (ctl, write, buffer, lenp, ppos,NULL );else if (strcmp (ctl->procname,"base_reachable_time" ) ==0 ) - ret =proc_dointvec_jiffies (ctl, write, - buffer, lenp, ppos); + ret =proc_dointvec_jiffies (ctl, write, buffer, + lenp, ppos,NULL );else if ((strcmp (ctl->procname,"retrans_time_ms" ) ==0 ) || (strcmp (ctl->procname,"base_reachable_time_ms" ) ==0 )) - ret =proc_dointvec_ms_jiffies (ctl, write, - buffer, lenp, ppos); + ret =proc_dointvec_ms_jiffies (ctl, write, buffer, + lenp, ppos,NULL );else ret =-1 ;
net/ipv6/route.c +3 -3
@@ -2593,8 +2593,8 @@ static const struct file_operations rt6_stats_seq_fops = {#ifdef CONFIG_SYSCTL static -int ipv6_sysctl_rtcache_flush (ctl_table *ctl,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +int ipv6_sysctl_rtcache_flush (ctl_table *ctl,int write,void __user *buffer, +size_t *lenp,loff_t *ppos,void *cookie) {struct net *net;int delay;
@@ -2603,7 +2603,7 @@ int ipv6_sysctl_rtcache_flush(ctl_table *ctl, int write, net = (struct net *)ctl->extra1; delay = net->ipv6.sysctl.flush_delay; -proc_dointvec (ctl, write, buffer, lenp, ppos); +proc_dointvec (ctl, write, buffer, lenp, ppos,NULL );fib6_run_gc (delay <=0 ? ~0UL : (unsigned long )delay, net);return 0 ; }
net/irda/irsysctl.c +6 -6
@@ -73,12 +73,12 @@ static int min_lap_keepalive_time = 100; /* 100us *//* For other sysctl, I've no idea of the range. Maybe Dag could help * us on that - Jean II */ -static int do_devname (ctl_table *table,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +static int do_devname (ctl_table *table,int write,void __user *buffer, +size_t *lenp,loff_t *ppos,void *cookie) {int ret; - ret =proc_dostring (table, write, buffer, lenp, ppos); + ret =proc_dostring (table, write, buffer, lenp, ppos,NULL );if (ret ==0 && write) {struct ias_value *val;
@@ -90,12 +90,12 @@ static int do_devname(ctl_table *table, int write, } -static int do_discovery (ctl_table *table,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +static int do_discovery (ctl_table *table,int write,void __user *buffer, +size_t *lenp,loff_t *ppos,void *cookie) {int ret; - ret =proc_dointvec (table, write, buffer, lenp, ppos); + ret =proc_dointvec (table, write, buffer, lenp, ppos,NULL );if (ret)return ret;
net/netfilter/ipvs/ip_vs_ctl.c +6 -6
@@ -1514,15 +1514,15 @@ static int ip_vs_zero_all(struct net *net)#ifdef CONFIG_SYSCTL static int -proc_do_defense_mode (ctl_table *table,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +proc_do_defense_mode (ctl_table *table,int write,void __user *buffer, +size_t *lenp,loff_t *ppos,void *cookie) {struct net *net = current->nsproxy->net_ns;int *valp = table->data;int val = *valp;int rc; - rc =proc_dointvec (table, write, buffer, lenp, ppos); + rc =proc_dointvec (table, write, buffer, lenp, ppos,NULL );if (write && (*valp != val)) {if ((*valp <0 ) || (*valp >3 )) {/* Restore the correct value */
@@ -1535,8 +1535,8 @@ proc_do_defense_mode(ctl_table *table, int write, }static int -proc_do_sync_threshold (ctl_table *table,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +proc_do_sync_threshold (ctl_table *table,int write,void __user *buffer, +size_t *lenp,loff_t *ppos,void *cookie) {int *valp = table->data;int val[2 ];
@@ -1545,7 +1545,7 @@ proc_do_sync_threshold(ctl_table *table, int write,/* backup the value first */ memcpy (val, valp,sizeof (val)); - rc =proc_dointvec (table, write, buffer, lenp, ppos); + rc =proc_dointvec (table, write, buffer, lenp, ppos,NULL );if (write && (valp[0 ] <0 || valp[1 ] <0 || valp[0 ] >= valp[1 ])) {/* Restore the correct value */ memcpy (valp, val,sizeof (val));
net/netfilter/nf_log.c +3 -2
@@ -226,7 +226,8 @@ static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];static struct ctl_table_header *nf_log_dir_header;static int nf_log_proc_dostring (ctl_table *table,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie) {const struct nf_logger *logger;char buf[NFLOGGER_NAME_LEN ];
@@ -260,7 +261,7 @@ static int nf_log_proc_dostring(ctl_table *table, int write, table->data ="NONE" ; else table->data = logger->name; - r =proc_dostring (table, write, buffer, lenp, ppos); + r =proc_dostring (table, write, buffer, lenp, ppos,NULL );mutex_unlock (&nf_log_mutex); }
net/phonet/sysctl.c +3 -3
@@ -57,8 +57,8 @@ void phonet_get_local_port_range(int *min, int *max) }static int proc_local_port_range (ctl_table *table,int write, -void __user *buffer, -size_t *lenp,loff_t *ppos) +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie) {int ret;int range[2 ] = {local_port_range[0 ], local_port_range[1 ]};
@@ -70,7 +70,7 @@ static int proc_local_port_range(ctl_table *table, int write, .extra2 = &local_port_range_max, }; - ret =proc_dointvec_minmax (&tmp, write, buffer, lenp, ppos); + ret =proc_dointvec_minmax (&tmp, write, buffer, lenp, ppos,NULL );if (write && ret ==0 ) {if (range[1 ] < range[0 ])
net/sunrpc/sysctl.c +4 -5
@@ -56,8 +56,8 @@ rpc_unregister_sysctl(void) } } -static int proc_do_xprt (ctl_table *table,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +static int proc_do_xprt (ctl_table *table,int write,void __user *buffer, +size_t *lenp,loff_t *ppos,void *cookie) {char tmpbuf[256 ];size_t len;
@@ -70,9 +70,8 @@ static int proc_do_xprt(ctl_table *table, int write,return simple_read_from_buffer (buffer, *lenp, ppos, tmpbuf, len); } -static int -proc_dodebug (ctl_table *table,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +static int proc_dodebug (ctl_table *table,int write,void __user *buffer, +size_t *lenp,loff_t *ppos,void *cookie) {char tmpbuf[20 ], c, *s;char __user *p;
net/sunrpc/xprtrdma/svc_rdma.c +1 -1
@@ -85,7 +85,7 @@ struct workqueue_struct *svc_rdma_wq;*/ static int read_reset_stat (ctl_table *table,int write,void __user *buffer,size_t *lenp, -loff_t *ppos) +loff_t *ppos,void *cookie) {atomic_t *stat = (atomic_t *)table->data;
security/min_addr.c +3 -2
@@ -29,14 +29,15 @@ static void update_mmap_min_addr(void)* calls update_mmap_min_addr() so non MAP_FIXED hints get rounded properly */ int mmap_min_addr_handler (struct ctl_table *table,int write, -void __user *buffer,size_t *lenp,loff_t *ppos) +void __user *buffer,size_t *lenp, +loff_t *ppos,void *cookie) {int ret;if (write && !capable (CAP_SYS_RAWIO ))return -EPERM ; - ret =proc_doulongvec_minmax (table, write, buffer, lenp, ppos); + ret =proc_doulongvec_minmax (table, write, buffer, lenp, ppos,NULL );update_mmap_min_addr ();
Signature · 1 line
1.7.5.rc0
PATCH 4/24 sysctl: cookie: add netns_proc_dointvec and other netns_proc_* proc_handlers
In reply to Lucian Adrian GrijincuUse these handlers when you want to change a netns dependant variable. The following restrictions apply:
- these handlers must receive as cookie a 'struct net*'
- the data field of ctl_table* must be at a constant offset from the init_net structure. e.g.: &init_net.member1.member2..memberN
- these handlers will call their equivalent handler with a ctl_table with data of the form: net->member1.member2..memberN
--- include/net/net_namespace.h | 33 +++++++++++++++++++++++++++++++++ net/sysctl_net.c | 22 ++++++++++++++++++++++ 2 files changed, 55 insertions(+), 0 deletions(-)
include/net/net_namespace.h +33 -0
@@ -278,4 +278,37 @@ extern struct ctl_table_header *register_net_sysctl_rotable( const struct ctl_path *path, struct ctl_table *table);extern void unregister_net_sysctl_table (struct ctl_table_header *header); + + +/* +* Use these handlers when you want to change a netns dependant +* variable. The following restrictions apply: +* +* - these handlers must receive as cookie a 'struct net*' +* +* - the data field of ctl_table* must be at a constant offset from +* the init_net structure. e.g.: &init_net.member1.member2..memberN +* +* - these handlers will call their equivalent handler with a +* ctl_table with data of the form: net->member1.member2..memberN +*/ +extern int netns_proc_dostring (struct ctl_table *, +int ,void __user *,size_t *,loff_t *,void *net); +extern int netns_proc_dointvec (struct ctl_table *,int , +void __user *,size_t *,loff_t *,void *net); +extern int netns_proc_dointvec_minmax (struct ctl_table *,int , +void __user *,size_t *,loff_t *,void *net); +extern int netns_proc_dointvec_jiffies (struct ctl_table *,int , +void __user *,size_t *,loff_t *,void *net); +extern int netns_proc_dointvec_userhz_jiffies (struct ctl_table *,int , +void __user *,size_t *,loff_t *,void *net); +extern int netns_proc_dointvec_ms_jiffies (struct ctl_table *,int , +void __user *,size_t *,loff_t *,void *net); +extern int netns_proc_doulongvec_minmax (struct ctl_table *,int , +void __user *,size_t *,loff_t *,void *net); +extern int netns_proc_doulongvec_ms_jiffies_minmax (struct ctl_table *table,int , +void __user *,size_t *,loff_t *,void *net); +extern int netns_proc_do_large_bitmap (struct ctl_table *,int , +void __user *,size_t *,loff_t *,void *net); +#endif /* __NET_NET_NAMESPACE_H */
net/sysctl_net.c +22 -0
@@ -127,3 +127,25 @@ void unregister_net_sysctl_table(struct ctl_table_header *header)unregister_sysctl_table (header); }EXPORT_SYMBOL_GPL (unregister_net_sysctl_table); + + + +#define EXPORT_NETNS_PROC_HANDLER (handler) \ + int netns_##handler(struct ctl_table *table, int write, \ + void __user *buffer, size_t *lenp, \ + loff_t *ppos, void *net) \ + { \ + struct ctl_table t = *table; \ + t.data += (char *)net - (char *)&init_net; \ + return handler(&t, write, buffer, lenp, ppos, NULL); \ + } \ + EXPORT_SYMBOL_GPL(netns_##handler); + +EXPORT_NETNS_PROC_HANDLER (proc_dointvec); +EXPORT_NETNS_PROC_HANDLER (proc_dointvec_minmax); +EXPORT_NETNS_PROC_HANDLER (proc_dointvec_jiffies); +EXPORT_NETNS_PROC_HANDLER (proc_dointvec_userhz_jiffies); +EXPORT_NETNS_PROC_HANDLER (proc_dointvec_ms_jiffies); +EXPORT_NETNS_PROC_HANDLER (proc_doulongvec_minmax) +EXPORT_NETNS_PROC_HANDLER (proc_doulongvec_ms_jiffies_minmax); +EXPORT_NETNS_PROC_HANDLER (proc_do_large_bitmap);
Signature · 1 line
1.7.5.rc0
PATCH 5/24 sysctl: cookie: share ip4_frags_ns_ctl_table between nets
In reply to Lucian Adrian GrijincuWe were creating a copy of this table was to set ctl_table->data to point to data from within the newly created 'struct net*'.
The netns_proc_* handlers do this dynamically.
Also change register_net_sysctl_table() to send the net as a cookie.
--- net/ipv4/ip_fragment.c | 34 ++++++---------------------------- net/sysctl_net.c | 2 +- 2 files changed, 7 insertions(+), 29 deletions(-)
net/ipv4/ip_fragment.c +6 -28
@@ -677,21 +677,21 @@ static struct ctl_table ip4_frags_ns_ctl_table[] = { .data = &init_net.ipv4.frags.high_thresh, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec }, { .procname = "ipfrag_low_thresh", .data = &init_net.ipv4.frags.low_thresh, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec }, { .procname = "ipfrag_time", .data = &init_net.ipv4.frags.timeout, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec_jiffies, + .proc_handler = netns_proc_dointvec_jiffies, }, { } };
@@ -717,41 +717,19 @@ static struct ctl_table ip4_frags_ctl_table[] = {static int __net_init ip4_frags_ns_ctl_register (struct net *net) { -struct ctl_table *table;struct ctl_table_header *hdr; - - table = ip4_frags_ns_ctl_table; -if (!net_eq (net, &init_net)) { - table =kmemdup (table,sizeof (ip4_frags_ns_ctl_table),GFP_KERNEL ); -if (table ==NULL ) - goto err_alloc; - - table[0 ].data = &net->ipv4.frags.high_thresh; - table[1 ].data = &net->ipv4.frags.low_thresh; - table[2 ].data = &net->ipv4.frags.timeout; - } - - hdr =register_net_sysctl_table (net, net_ipv4_ctl_path, table); + hdr =register_net_sysctl_table (net, net_ipv4_ctl_path, + ip4_frags_ns_ctl_table);if (hdr ==NULL ) - goto err_reg; +return -ENOMEM ; net->ipv4.frags_hdr = hdr;return 0 ; - -err_reg: -if (!net_eq (net, &init_net)) -kfree (table); -err_alloc: -return -ENOMEM ; } static void __net_exit ip4_frags_ns_ctl_unregister(struct net *net) { -struct ctl_table *table; - - table = net->ipv4.frags_hdr->ctl_table_arg;unregister_net_sysctl_table (net->ipv4.frags_hdr); -kfree (table); }static void ip4_frags_ctl_register (void )
net/sysctl_net.c +1 -1
@@ -110,7 +110,7 @@ struct ctl_table_header *register_net_sysctl_table(struct net *net, namespaces = *current->nsproxy; namespaces.net_ns = net;return __register_sysctl_paths (&net_sysctl_root, &namespaces, path, - table,NULL ); + table, net); }EXPORT_SYMBOL_GPL (register_net_sysctl_table);
Signature · 1 line
1.7.5.rc0
PATCH 4/24 sysctl: cookie: add netns_proc_dointvec and other netns_proc_* proc_handlers
In reply to Lucian Adrian GrijincuUse these handlers when you want to change a netns dependant variable. The following restrictions apply:
- these handlers must receive as cookie a 'struct net*'
- the data field of ctl_table* must be at a constant offset from the init_net structure. e.g.: &init_net.member1.member2..memberN
- these handlers will call their equivalent handler with a ctl_table with data of the form: net->member1.member2..memberN
--- include/net/net_namespace.h | 33 +++++++++++++++++++++++++++++++++ net/sysctl_net.c | 22 ++++++++++++++++++++++ 2 files changed, 55 insertions(+), 0 deletions(-)
include/net/net_namespace.h +33 -0
@@ -278,4 +278,37 @@ extern struct ctl_table_header *register_net_sysctl_rotable( const struct ctl_path *path, struct ctl_table *table);extern void unregister_net_sysctl_table (struct ctl_table_header *header); + + +/* +* Use these handlers when you want to change a netns dependant +* variable. The following restrictions apply: +* +* - these handlers must receive as cookie a 'struct net*' +* +* - the data field of ctl_table* must be at a constant offset from +* the init_net structure. e.g.: &init_net.member1.member2..memberN +* +* - these handlers will call their equivalent handler with a +* ctl_table with data of the form: net->member1.member2..memberN +*/ +extern int netns_proc_dostring (struct ctl_table *, +int ,void __user *,size_t *,loff_t *,void *net); +extern int netns_proc_dointvec (struct ctl_table *,int , +void __user *,size_t *,loff_t *,void *net); +extern int netns_proc_dointvec_minmax (struct ctl_table *,int , +void __user *,size_t *,loff_t *,void *net); +extern int netns_proc_dointvec_jiffies (struct ctl_table *,int , +void __user *,size_t *,loff_t *,void *net); +extern int netns_proc_dointvec_userhz_jiffies (struct ctl_table *,int , +void __user *,size_t *,loff_t *,void *net); +extern int netns_proc_dointvec_ms_jiffies (struct ctl_table *,int , +void __user *,size_t *,loff_t *,void *net); +extern int netns_proc_doulongvec_minmax (struct ctl_table *,int , +void __user *,size_t *,loff_t *,void *net); +extern int netns_proc_doulongvec_ms_jiffies_minmax (struct ctl_table *table,int , +void __user *,size_t *,loff_t *,void *net); +extern int netns_proc_do_large_bitmap (struct ctl_table *,int , +void __user *,size_t *,loff_t *,void *net); +#endif /* __NET_NET_NAMESPACE_H */
net/sysctl_net.c +22 -0
@@ -127,3 +127,25 @@ void unregister_net_sysctl_table(struct ctl_table_header *header)unregister_sysctl_table (header); }EXPORT_SYMBOL_GPL (unregister_net_sysctl_table); + + + +#define EXPORT_NETNS_PROC_HANDLER (handler) \ + int netns_##handler(struct ctl_table *table, int write, \ + void __user *buffer, size_t *lenp, \ + loff_t *ppos, void *net) \ + { \ + struct ctl_table t = *table; \ + t.data += (char *)net - (char *)&init_net; \ + return handler(&t, write, buffer, lenp, ppos, NULL); \ + } \ + EXPORT_SYMBOL_GPL(netns_##handler); + +EXPORT_NETNS_PROC_HANDLER (proc_dointvec); +EXPORT_NETNS_PROC_HANDLER (proc_dointvec_minmax); +EXPORT_NETNS_PROC_HANDLER (proc_dointvec_jiffies); +EXPORT_NETNS_PROC_HANDLER (proc_dointvec_userhz_jiffies); +EXPORT_NETNS_PROC_HANDLER (proc_dointvec_ms_jiffies); +EXPORT_NETNS_PROC_HANDLER (proc_doulongvec_minmax) +EXPORT_NETNS_PROC_HANDLER (proc_doulongvec_ms_jiffies_minmax); +EXPORT_NETNS_PROC_HANDLER (proc_do_large_bitmap);
Signature · 1 line
1.7.5.rc0
PATCH 6/24 sysctl: cookie: share netns_core_table between nets
In reply to Lucian Adrian Grijincu--- net/core/sysctl_net_core.c | 28 +++------------------------- 1 files changed, 3 insertions(+), 25 deletions(-)
net/core/sysctl_net_core.c +3 -25
@@ -183,7 +183,7 @@ static struct ctl_table netns_core_table[] = { .data = &init_net.core.sysctl_somaxconn, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec, }, { } };
@@ -196,41 +196,19 @@ __net_initdata struct ctl_path net_core_path[] = {static __net_init int sysctl_core_net_init (struct net *net) { -struct ctl_table *tbl; - net->core.sysctl_somaxconn =SOMAXCONN ; - tbl = netns_core_table; -if (!net_eq (net, &init_net)) { - tbl =kmemdup (tbl,sizeof (netns_core_table),GFP_KERNEL ); -if (tbl ==NULL ) - goto err_dup; - - tbl[0 ].data = &net->core.sysctl_somaxconn; - } - net->core.sysctl_hdr =register_net_sysctl_table (net, - net_core_path, tbl); + net_core_path, netns_core_table);if (net->core.sysctl_hdr ==NULL ) - goto err_reg; +return -ENOMEM ;return 0 ; - -err_reg: -if (tbl != netns_core_table) -kfree (tbl); -err_dup: -return -ENOMEM ; } static __net_exit void sysctl_core_net_exit(struct net *net) { -struct ctl_table *tbl; - - tbl = net->core.sysctl_hdr->ctl_table_arg;unregister_net_sysctl_table (net->core.sysctl_hdr); -BUG_ON (tbl == netns_core_table); -kfree (tbl); }static __net_initdata struct pernet_operations sysctl_core_ops = {
Signature · 1 line
1.7.5.rc0
PATCH 7/24 sysctl: cookie: share ipv4_route_flush_table between nets
In reply to Lucian Adrian Grijincu--- net/ipv4/route.c | 30 ++++-------------------------- 1 files changed, 4 insertions(+), 26 deletions(-)
net/ipv4/route.c +4 -26
@@ -3015,13 +3015,12 @@ static int ipv4_sysctl_rtcache_flush(ctl_table *__ctl, int write,if (write) {int flush_delay;ctl_table ctl; -struct net *net; +struct net *net = (struct net *) cookie;memcpy (&ctl, __ctl,sizeof (ctl)); ctl.data = &flush_delay;proc_dointvec (&ctl, write, buffer, lenp, ppos,NULL ); - net = (struct net *)__ctl->extra1;rt_cache_flush (net, flush_delay);return 0 ; }
@@ -3176,37 +3175,16 @@ static __net_initdata struct ctl_path ipv4_route_path[] = {static __net_init int sysctl_route_net_init (struct net *net) { -struct ctl_table *tbl; - - tbl = ipv4_route_flush_table; -if (!net_eq (net, &init_net)) { - tbl =kmemdup (tbl,sizeof (ipv4_route_flush_table),GFP_KERNEL ); -if (tbl ==NULL ) - goto err_dup; - } - tbl[0 ].extra1 = net; - - net->ipv4.route_hdr = -register_net_sysctl_table (net, ipv4_route_path, tbl); + net->ipv4.route_hdr =register_net_sysctl_table (net, + ipv4_route_path, ipv4_route_flush_table);if (net->ipv4.route_hdr ==NULL ) - goto err_reg; +return -ENOMEM ;return 0 ; - -err_reg: -if (tbl != ipv4_route_flush_table) -kfree (tbl); -err_dup: -return -ENOMEM ; } static __net_exit void sysctl_route_net_exit(struct net *net) { -struct ctl_table *tbl; - - tbl = net->ipv4.route_hdr->ctl_table_arg;unregister_net_sysctl_table (net->ipv4.route_hdr); -BUG_ON (tbl == ipv4_route_flush_table); -kfree (tbl); }static __net_initdata struct pernet_operations sysctl_route_ops = {
Signature · 1 line
1.7.5.rc0
PATCH 6/24 sysctl: cookie: share netns_core_table between nets
In reply to Lucian Adrian Grijincu--- net/core/sysctl_net_core.c | 28 +++------------------------- 1 files changed, 3 insertions(+), 25 deletions(-)
net/core/sysctl_net_core.c +3 -25
@@ -183,7 +183,7 @@ static struct ctl_table netns_core_table[] = { .data = &init_net.core.sysctl_somaxconn, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec, }, { } };
@@ -196,41 +196,19 @@ __net_initdata struct ctl_path net_core_path[] = {static __net_init int sysctl_core_net_init (struct net *net) { -struct ctl_table *tbl; - net->core.sysctl_somaxconn =SOMAXCONN ; - tbl = netns_core_table; -if (!net_eq (net, &init_net)) { - tbl =kmemdup (tbl,sizeof (netns_core_table),GFP_KERNEL ); -if (tbl ==NULL ) - goto err_dup; - - tbl[0 ].data = &net->core.sysctl_somaxconn; - } - net->core.sysctl_hdr =register_net_sysctl_table (net, - net_core_path, tbl); + net_core_path, netns_core_table);if (net->core.sysctl_hdr ==NULL ) - goto err_reg; +return -ENOMEM ;return 0 ; - -err_reg: -if (tbl != netns_core_table) -kfree (tbl); -err_dup: -return -ENOMEM ; } static __net_exit void sysctl_core_net_exit(struct net *net) { -struct ctl_table *tbl; - - tbl = net->core.sysctl_hdr->ctl_table_arg;unregister_net_sysctl_table (net->core.sysctl_hdr); -BUG_ON (tbl == netns_core_table); -kfree (tbl); }static __net_initdata struct pernet_operations sysctl_core_ops = {
Signature · 1 line
1.7.5.rc0
PATCH 8/24 sysctl: cookie: share ipv4_net_table between nets
In reply to Lucian Adrian Grijincu--- net/ipv4/sysctl_net_ipv4.c | 53 +++++++------------------------------------ 1 files changed, 9 insertions(+), 44 deletions(-)
net/ipv4/sysctl_net_ipv4.c +9 -44
@@ -635,49 +635,49 @@ static struct ctl_table ipv4_net_table[] = { .data = &init_net.ipv4.sysctl_icmp_echo_ignore_all, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec, }, { .procname = "icmp_echo_ignore_broadcasts", .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec, }, { .procname = "icmp_ignore_bogus_error_responses", .data = &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec, }, { .procname = "icmp_errors_use_inbound_ifaddr", .data = &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec, }, { .procname = "icmp_ratelimit", .data = &init_net.ipv4.sysctl_icmp_ratelimit, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec_ms_jiffies, + .proc_handler = netns_proc_dointvec_ms_jiffies, }, { .procname = "icmp_ratemask", .data = &init_net.ipv4.sysctl_icmp_ratemask, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec, }, { .procname = "rt_cache_rebuild_count", .data = &init_net.ipv4.sysctl_rt_cache_rebuild_count, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec, }, { } };
@@ -691,53 +691,18 @@ EXPORT_SYMBOL_GPL(net_ipv4_ctl_path);static __net_init int ipv4_sysctl_init_net (struct net *net) { -struct ctl_table *table; - - table = ipv4_net_table; -if (!net_eq (net, &init_net)) { - table =kmemdup (table,sizeof (ipv4_net_table),GFP_KERNEL ); -if (table ==NULL ) - goto err_alloc; - - table[0 ].data = - &net->ipv4.sysctl_icmp_echo_ignore_all; - table[1 ].data = - &net->ipv4.sysctl_icmp_echo_ignore_broadcasts; - table[2 ].data = - &net->ipv4.sysctl_icmp_ignore_bogus_error_responses; - table[3 ].data = - &net->ipv4.sysctl_icmp_errors_use_inbound_ifaddr; - table[4 ].data = - &net->ipv4.sysctl_icmp_ratelimit; - table[5 ].data = - &net->ipv4.sysctl_icmp_ratemask; - table[6 ].data = - &net->ipv4.sysctl_rt_cache_rebuild_count; - } - net->ipv4.sysctl_rt_cache_rebuild_count =4 ; net->ipv4.ipv4_hdr =register_net_sysctl_table (net, - net_ipv4_ctl_path, table); + net_ipv4_ctl_path, ipv4_net_table);if (net->ipv4.ipv4_hdr ==NULL ) - goto err_reg; - +return -ENOMEM ;return 0 ; - -err_reg: -if (!net_eq (net, &init_net)) -kfree (table); -err_alloc: -return -ENOMEM ; } static __net_exit void ipv4_sysctl_exit_net(struct net *net) { -struct ctl_table *table; - - table = net->ipv4.ipv4_hdr->ctl_table_arg;unregister_net_sysctl_table (net->ipv4.ipv4_hdr); -kfree (table); }static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
Signature · 1 line
1.7.5.rc0
PATCH 9/24 sysctl: cookie: share ip6_frags_ns_ctl_table between nets
In reply to Lucian Adrian Grijincu--- net/ipv6/reassembly.c | 34 ++++++---------------------------- 1 files changed, 6 insertions(+), 28 deletions(-)
net/ipv6/reassembly.c +6 -28
@@ -600,21 +600,21 @@ static struct ctl_table ip6_frags_ns_ctl_table[] = { .data = &init_net.ipv6.frags.high_thresh, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec, }, { .procname = "ip6frag_low_thresh", .data = &init_net.ipv6.frags.low_thresh, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec, }, { .procname = "ip6frag_time", .data = &init_net.ipv6.frags.timeout, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec_jiffies, + .proc_handler = netns_proc_dointvec_jiffies, }, { } };
@@ -632,42 +632,20 @@ static struct ctl_table ip6_frags_ctl_table[] = {static int __net_init ip6_frags_ns_sysctl_register (struct net *net) { -struct ctl_table *table;struct ctl_table_header *hdr; - table = ip6_frags_ns_ctl_table; -if (!net_eq (net, &init_net)) { - table =kmemdup (table,sizeof (ip6_frags_ns_ctl_table),GFP_KERNEL ); -if (table ==NULL ) - goto err_alloc; - - table[0 ].data = &net->ipv6.frags.high_thresh; - table[1 ].data = &net->ipv6.frags.low_thresh; - table[2 ].data = &net->ipv6.frags.timeout; - } - - hdr =register_net_sysctl_table (net, net_ipv6_ctl_path, table); + hdr =register_net_sysctl_table (net, net_ipv6_ctl_path, + ip6_frags_ns_ctl_table);if (hdr ==NULL ) - goto err_reg; +return -ENOMEM ; net->ipv6.sysctl.frags_hdr = hdr;return 0 ; - -err_reg: -if (!net_eq (net, &init_net)) -kfree (table); -err_alloc: -return -ENOMEM ; } static void __net_exit ip6_frags_ns_sysctl_unregister(struct net *net) { -struct ctl_table *table; - - table = net->ipv6.sysctl.frags_hdr->ctl_table_arg;unregister_net_sysctl_table (net->ipv6.sysctl.frags_hdr); -if (!net_eq (net, &init_net)) -kfree (table); }static struct ctl_table_header *ip6_ctl_header;
Signature · 1 line
1.7.5.rc0
PATCH 8/24 sysctl: cookie: share ipv4_net_table between nets
In reply to Lucian Adrian Grijincu--- net/ipv4/sysctl_net_ipv4.c | 53 +++++++------------------------------------ 1 files changed, 9 insertions(+), 44 deletions(-)
net/ipv4/sysctl_net_ipv4.c +9 -44
@@ -635,49 +635,49 @@ static struct ctl_table ipv4_net_table[] = { .data = &init_net.ipv4.sysctl_icmp_echo_ignore_all, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec, }, { .procname = "icmp_echo_ignore_broadcasts", .data = &init_net.ipv4.sysctl_icmp_echo_ignore_broadcasts, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec, }, { .procname = "icmp_ignore_bogus_error_responses", .data = &init_net.ipv4.sysctl_icmp_ignore_bogus_error_responses, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec, }, { .procname = "icmp_errors_use_inbound_ifaddr", .data = &init_net.ipv4.sysctl_icmp_errors_use_inbound_ifaddr, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec, }, { .procname = "icmp_ratelimit", .data = &init_net.ipv4.sysctl_icmp_ratelimit, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec_ms_jiffies, + .proc_handler = netns_proc_dointvec_ms_jiffies, }, { .procname = "icmp_ratemask", .data = &init_net.ipv4.sysctl_icmp_ratemask, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec, }, { .procname = "rt_cache_rebuild_count", .data = &init_net.ipv4.sysctl_rt_cache_rebuild_count, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec, }, { } };
@@ -691,53 +691,18 @@ EXPORT_SYMBOL_GPL(net_ipv4_ctl_path);static __net_init int ipv4_sysctl_init_net (struct net *net) { -struct ctl_table *table; - - table = ipv4_net_table; -if (!net_eq (net, &init_net)) { - table =kmemdup (table,sizeof (ipv4_net_table),GFP_KERNEL ); -if (table ==NULL ) - goto err_alloc; - - table[0 ].data = - &net->ipv4.sysctl_icmp_echo_ignore_all; - table[1 ].data = - &net->ipv4.sysctl_icmp_echo_ignore_broadcasts; - table[2 ].data = - &net->ipv4.sysctl_icmp_ignore_bogus_error_responses; - table[3 ].data = - &net->ipv4.sysctl_icmp_errors_use_inbound_ifaddr; - table[4 ].data = - &net->ipv4.sysctl_icmp_ratelimit; - table[5 ].data = - &net->ipv4.sysctl_icmp_ratemask; - table[6 ].data = - &net->ipv4.sysctl_rt_cache_rebuild_count; - } - net->ipv4.sysctl_rt_cache_rebuild_count =4 ; net->ipv4.ipv4_hdr =register_net_sysctl_table (net, - net_ipv4_ctl_path, table); + net_ipv4_ctl_path, ipv4_net_table);if (net->ipv4.ipv4_hdr ==NULL ) - goto err_reg; - +return -ENOMEM ;return 0 ; - -err_reg: -if (!net_eq (net, &init_net)) -kfree (table); -err_alloc: -return -ENOMEM ; } static __net_exit void ipv4_sysctl_exit_net(struct net *net) { -struct ctl_table *table; - - table = net->ipv4.ipv4_hdr->ctl_table_arg;unregister_net_sysctl_table (net->ipv4.ipv4_hdr); -kfree (table); }static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
Signature · 1 line
1.7.5.rc0
PATCH 10/24 sysctl: cookie: share ip6_ctl_table, ipv6_icmp_table and ipv6_route_table between nets
In reply to Lucian Adrian Grijincu--- include/net/ipv6.h | 6 +--- net/ipv6/icmp.c | 17 +----------- net/ipv6/route.c | 58 +++++++++++------------------------------ net/ipv6/sysctl_net_ipv6.c | 61 ++++++-------------------------------------- 4 files changed, 28 insertions(+), 114 deletions(-)
include/net/ipv6.h +2 -4
@@ -656,11 +656,9 @@ static inline int snmp6_unregister_dev(struct inet6_dev *idev) { return 0; }#endif #ifdef CONFIG_SYSCTL -extern ctl_table ipv6_route_table_template[]; -extern ctl_table ipv6_icmp_table_template[]; +extern ctl_table ipv6_route_table[]; +extern ctl_table ipv6_icmp_table[]; -extern struct ctl_table *ipv6_icmp_sysctl_init (struct net *net); -extern struct ctl_table *ipv6_route_sysctl_init (struct net *net);extern int ipv6_sysctl_register (void );extern void ipv6_sysctl_unregister (void );extern int ipv6_static_sysctl_register (void );
net/ipv6/icmp.c +2 -15
@@ -954,29 +954,16 @@ int icmpv6_err_convert(u8 type, u8 code, int *err)EXPORT_SYMBOL (icmpv6_err_convert);#ifdef CONFIG_SYSCTL -ctl_table ipv6_icmp_table_template[] = { +ctl_table ipv6_icmp_table[] = { { .procname ="ratelimit" , .data = &init_net.ipv6.sysctl.icmpv6_time, .maxlen =sizeof (int ), .mode =0644 , - .proc_handler = proc_dointvec_ms_jiffies, + .proc_handler = netns_proc_dointvec_ms_jiffies, }, { }, }; -struct ctl_table *__net_init ipv6_icmp_sysctl_init (struct net *net) -{ -struct ctl_table *table; - - table =kmemdup (ipv6_icmp_table_template, -sizeof (ipv6_icmp_table_template), -GFP_KERNEL ); - -if (table) - table[0 ].data = &net->ipv6.sysctl.icmpv6_time; - -return table; -}#endif
net/ipv6/route.c +16 -42
136 lines not on this page · raw message
net/ipv6/sysctl_net_ipv6.c +8 -53
95 lines not on this page · raw message
Signature · 1 line
1.7.5.rc0
PATCH 11/24 sysctl: cookie: share acct_sysctl_table table between nets
In reply to Lucian Adrian Grijincu--- net/netfilter/nf_conntrack_acct.c | 24 +++--------------------- 1 files changed, 3 insertions(+), 21 deletions(-)
net/netfilter/nf_conntrack_acct.c +3 -21
@@ -29,7 +29,7 @@ static struct ctl_table acct_sysctl_table[] = { .data = &init_net.ct.sysctl_acct, .maxlen = sizeof(unsigned int), .mode = 0644, - .proc_handler = proc_dointvec, + .proc_handler = netns_proc_dointvec, }, {} };
@@ -59,36 +59,18 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {#ifdef CONFIG_SYSCTL static int nf_conntrack_acct_init_sysctl (struct net *net) { -struct ctl_table *table; - - table =kmemdup (acct_sysctl_table,sizeof (acct_sysctl_table), -GFP_KERNEL ); -if (!table) - goto out; - - table[0 ].data = &net->ct.sysctl_acct; - net->ct.acct_sysctl_header =register_net_sysctl_table (net, - nf_net_netfilter_sysctl_path, table); + nf_net_netfilter_sysctl_path, acct_sysctl_table);if (!net->ct.acct_sysctl_header) {printk (KERN_ERR "nf_conntrack_acct: can't register to sysctl.\n" ); - goto out_register; +return -ENOMEM ; }return 0 ; - -out_register: -kfree (table); -out: -return -ENOMEM ; }static void nf_conntrack_acct_fini_sysctl (struct net *net) { -struct ctl_table *table; - - table = net->ct.acct_sysctl_header->ctl_table_arg;unregister_net_sysctl_table (net->ct.acct_sysctl_header); -kfree (table); }#else static int nf_conntrack_acct_init_sysctl (struct net *net)
Signature · 1 line
1.7.5.rc0
PATCH 12/24 sysctl: cookie: share event_sysctl_table between nets
In reply to Lucian Adrian Grijincu--- net/netfilter/nf_conntrack_ecache.c | 30 +++++------------------------- 1 files changed, 5 insertions(+), 25 deletions(-)
net/netfilter/nf_conntrack_ecache.c +5 -25
@@ -163,14 +163,14 @@ static struct ctl_table event_sysctl_table[] = { .data = &init_net.ct.sysctl_events, .maxlen = sizeof(unsigned int), .mode = 0644, - .proc_handler = proc_dointvec, + .proc_handler = netns_proc_dointvec, }, { .procname = "nf_conntrack_events_retry_timeout", .data = &init_net.ct.sysctl_events_retry_timeout, .maxlen = sizeof(unsigned int), .mode = 0644, - .proc_handler = proc_dointvec_jiffies, + .proc_handler = netns_proc_dointvec_jiffies, }, {} };
@@ -185,38 +185,18 @@ static struct nf_ct_ext_type event_extend __read_mostly = {#ifdef CONFIG_SYSCTL static int nf_conntrack_event_init_sysctl (struct net *net) { -struct ctl_table *table; - - table =kmemdup (event_sysctl_table,sizeof (event_sysctl_table), -GFP_KERNEL ); -if (!table) - goto out; - - table[0 ].data = &net->ct.sysctl_events; - table[1 ].data = &net->ct.sysctl_events_retry_timeout; - - net->ct.event_sysctl_header = -register_net_sysctl_table (net, - nf_net_netfilter_sysctl_path, table); + net->ct.event_sysctl_header =register_net_sysctl_table (net, + nf_net_netfilter_sysctl_path, event_sysctl_table);if (!net->ct.event_sysctl_header) {printk (KERN_ERR "nf_ct_event: can't register to sysctl.\n" ); - goto out_register; +return -ENOMEM ; }return 0 ; - -out_register: -kfree (table); -out: -return -ENOMEM ; }static void nf_conntrack_event_fini_sysctl (struct net *net) { -struct ctl_table *table; - - table = net->ct.event_sysctl_header->ctl_table_arg;unregister_net_sysctl_table (net->ct.event_sysctl_header); -kfree (table); }#else static int nf_conntrack_event_init_sysctl (struct net *net)
Signature · 1 line
1.7.5.rc0
PATCH 10/24 sysctl: cookie: share ip6_ctl_table, ipv6_icmp_table and ipv6_route_table between nets
In reply to Lucian Adrian Grijincu--- include/net/ipv6.h | 6 +--- net/ipv6/icmp.c | 17 +----------- net/ipv6/route.c | 58 +++++++++++------------------------------ net/ipv6/sysctl_net_ipv6.c | 61 ++++++-------------------------------------- 4 files changed, 28 insertions(+), 114 deletions(-)
include/net/ipv6.h +2 -4
@@ -656,11 +656,9 @@ static inline int snmp6_unregister_dev(struct inet6_dev *idev) { return 0; }#endif #ifdef CONFIG_SYSCTL -extern ctl_table ipv6_route_table_template[]; -extern ctl_table ipv6_icmp_table_template[]; +extern ctl_table ipv6_route_table[]; +extern ctl_table ipv6_icmp_table[]; -extern struct ctl_table *ipv6_icmp_sysctl_init (struct net *net); -extern struct ctl_table *ipv6_route_sysctl_init (struct net *net);extern int ipv6_sysctl_register (void );extern void ipv6_sysctl_unregister (void );extern int ipv6_static_sysctl_register (void );
net/ipv6/icmp.c +2 -15
@@ -954,29 +954,16 @@ int icmpv6_err_convert(u8 type, u8 code, int *err)EXPORT_SYMBOL (icmpv6_err_convert);#ifdef CONFIG_SYSCTL -ctl_table ipv6_icmp_table_template[] = { +ctl_table ipv6_icmp_table[] = { { .procname ="ratelimit" , .data = &init_net.ipv6.sysctl.icmpv6_time, .maxlen =sizeof (int ), .mode =0644 , - .proc_handler = proc_dointvec_ms_jiffies, + .proc_handler = netns_proc_dointvec_ms_jiffies, }, { }, }; -struct ctl_table *__net_init ipv6_icmp_sysctl_init (struct net *net) -{ -struct ctl_table *table; - - table =kmemdup (ipv6_icmp_table_template, -sizeof (ipv6_icmp_table_template), -GFP_KERNEL ); - -if (table) - table[0 ].data = &net->ipv6.sysctl.icmpv6_time; - -return table; -}#endif
net/ipv6/route.c +16 -42
136 lines not on this page · raw message
net/ipv6/sysctl_net_ipv6.c +8 -53
95 lines not on this page · raw message
Signature · 1 line
1.7.5.rc0
PATCH 11/24 sysctl: cookie: share acct_sysctl_table table between nets
In reply to Lucian Adrian Grijincu--- net/netfilter/nf_conntrack_acct.c | 24 +++--------------------- 1 files changed, 3 insertions(+), 21 deletions(-)
net/netfilter/nf_conntrack_acct.c +3 -21
@@ -29,7 +29,7 @@ static struct ctl_table acct_sysctl_table[] = { .data = &init_net.ct.sysctl_acct, .maxlen = sizeof(unsigned int), .mode = 0644, - .proc_handler = proc_dointvec, + .proc_handler = netns_proc_dointvec, }, {} };
@@ -59,36 +59,18 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {#ifdef CONFIG_SYSCTL static int nf_conntrack_acct_init_sysctl (struct net *net) { -struct ctl_table *table; - - table =kmemdup (acct_sysctl_table,sizeof (acct_sysctl_table), -GFP_KERNEL ); -if (!table) - goto out; - - table[0 ].data = &net->ct.sysctl_acct; - net->ct.acct_sysctl_header =register_net_sysctl_table (net, - nf_net_netfilter_sysctl_path, table); + nf_net_netfilter_sysctl_path, acct_sysctl_table);if (!net->ct.acct_sysctl_header) {printk (KERN_ERR "nf_conntrack_acct: can't register to sysctl.\n" ); - goto out_register; +return -ENOMEM ; }return 0 ; - -out_register: -kfree (table); -out: -return -ENOMEM ; }static void nf_conntrack_acct_fini_sysctl (struct net *net) { -struct ctl_table *table; - - table = net->ct.acct_sysctl_header->ctl_table_arg;unregister_net_sysctl_table (net->ct.acct_sysctl_header); -kfree (table); }#else static int nf_conntrack_acct_init_sysctl (struct net *net)
Signature · 1 line
1.7.5.rc0
PATCH 13/24 sysctl: cookie: share nf_ct_sysctl_table between nets
In reply to Lucian Adrian GrijincuAlso, minor reordering at unregister: unregister sysctls in reverse order of registering.
--- net/netfilter/nf_conntrack_standalone.c | 30 ++++++------------------------ 1 files changed, 6 insertions(+), 24 deletions(-)
net/netfilter/nf_conntrack_standalone.c +6 -24
@@ -420,28 +420,28 @@ static ctl_table nf_ct_sysctl_table[] = { .data = &init_net.ct.count, .maxlen = sizeof(int), .mode = 0444, - .proc_handler = proc_dointvec, + .proc_handler = netns_proc_dointvec, }, { .procname = "nf_conntrack_buckets", .data = &init_net.ct.htable_size, .maxlen = sizeof(unsigned int), .mode = 0444, - .proc_handler = proc_dointvec, + .proc_handler = netns_proc_dointvec, }, { .procname = "nf_conntrack_checksum", .data = &init_net.ct.sysctl_checksum, .maxlen = sizeof(unsigned int), .mode = 0644, - .proc_handler = proc_dointvec, + .proc_handler = netns_proc_dointvec, }, { .procname = "nf_conntrack_log_invalid", .data = &init_net.ct.sysctl_log_invalid, .maxlen = sizeof(unsigned int), .mode = 0644, - .proc_handler = proc_dointvec_minmax, + .proc_handler = netns_proc_dointvec_minmax, .extra1 = &log_invalid_proto_min, .extra2 = &log_invalid_proto_max, },
@@ -475,8 +475,6 @@ static struct ctl_path nf_ct_path[] = {static int nf_conntrack_standalone_init_sysctl (struct net *net) { -struct ctl_table *table; -if (net_eq (net, &init_net)) { nf_ct_netfilter_header =register_sysctl_paths (nf_ct_path, nf_ct_netfilter_table);
@@ -484,26 +482,14 @@ static int nf_conntrack_standalone_init_sysctl(struct net *net) goto out; } - table =kmemdup (nf_ct_sysctl_table,sizeof (nf_ct_sysctl_table), -GFP_KERNEL ); -if (!table) - goto out_kmemdup; - - table[1 ].data = &net->ct.count; - table[2 ].data = &net->ct.htable_size; - table[3 ].data = &net->ct.sysctl_checksum; - table[4 ].data = &net->ct.sysctl_log_invalid; - net->ct.sysctl_header =register_net_sysctl_table (net, - nf_net_netfilter_sysctl_path, table); + nf_net_netfilter_sysctl_path, nf_ct_sysctl_table);if (!net->ct.sysctl_header) goto out_unregister_netfilter;return 0 ; out_unregister_netfilter: -kfree (table); -out_kmemdup:if (net_eq (net, &init_net))unregister_sysctl_table (nf_ct_netfilter_header); out:
@@ -513,13 +499,9 @@ out:static void nf_conntrack_standalone_fini_sysctl (struct net *net) { -struct ctl_table *table; - +unregister_net_sysctl_table (net->ct.sysctl_header);if (net_eq (net, &init_net))unregister_sysctl_table (nf_ct_netfilter_header); - table = net->ct.sysctl_header->ctl_table_arg; -unregister_net_sysctl_table (net->ct.sysctl_header); -kfree (table); }#else static int nf_conntrack_standalone_init_sysctl (struct net *net)
Signature · 1 line
1.7.5.rc0
PATCH 14/24 sysctl: cookie: share unix_table between nets
In reply to Lucian Adrian Grijincu--- net/unix/sysctl_net_unix.c | 22 +++------------------- 1 files changed, 3 insertions(+), 19 deletions(-)
net/unix/sysctl_net_unix.c +3 -19
@@ -21,7 +21,7 @@ static ctl_table unix_table[] = { .data = &init_net.unx.sysctl_max_dgram_qlen, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec, }, { } };
@@ -34,30 +34,14 @@ static struct ctl_path unix_path[] = {int __net_init unix_sysctl_register (struct net *net) { -struct ctl_table *table; - - table =kmemdup (unix_table,sizeof (unix_table),GFP_KERNEL ); -if (table ==NULL ) - goto err_alloc; - - table[0 ].data = &net->unx.sysctl_max_dgram_qlen; - net->unx.ctl =register_net_sysctl_table (net, unix_path, table); + net->unx.ctl =register_net_sysctl_table (net, unix_path, unix_table);if (net->unx.ctl ==NULL ) - goto err_reg; +return -ENOMEM ;return 0 ; - -err_reg: -kfree (table); -err_alloc: -return -ENOMEM ; }void unix_sysctl_unregister (struct net *net) { -struct ctl_table *table; - - table = net->unx.ctl->ctl_table_arg;unregister_sysctl_table (net->unx.ctl); -kfree (table); }
Signature · 1 line
1.7.5.rc0
PATCH 13/24 sysctl: cookie: share nf_ct_sysctl_table between nets
In reply to Lucian Adrian GrijincuAlso, minor reordering at unregister: unregister sysctls in reverse order of registering.
--- net/netfilter/nf_conntrack_standalone.c | 30 ++++++------------------------ 1 files changed, 6 insertions(+), 24 deletions(-)
net/netfilter/nf_conntrack_standalone.c +6 -24
@@ -420,28 +420,28 @@ static ctl_table nf_ct_sysctl_table[] = { .data = &init_net.ct.count, .maxlen = sizeof(int), .mode = 0444, - .proc_handler = proc_dointvec, + .proc_handler = netns_proc_dointvec, }, { .procname = "nf_conntrack_buckets", .data = &init_net.ct.htable_size, .maxlen = sizeof(unsigned int), .mode = 0444, - .proc_handler = proc_dointvec, + .proc_handler = netns_proc_dointvec, }, { .procname = "nf_conntrack_checksum", .data = &init_net.ct.sysctl_checksum, .maxlen = sizeof(unsigned int), .mode = 0644, - .proc_handler = proc_dointvec, + .proc_handler = netns_proc_dointvec, }, { .procname = "nf_conntrack_log_invalid", .data = &init_net.ct.sysctl_log_invalid, .maxlen = sizeof(unsigned int), .mode = 0644, - .proc_handler = proc_dointvec_minmax, + .proc_handler = netns_proc_dointvec_minmax, .extra1 = &log_invalid_proto_min, .extra2 = &log_invalid_proto_max, },
@@ -475,8 +475,6 @@ static struct ctl_path nf_ct_path[] = {static int nf_conntrack_standalone_init_sysctl (struct net *net) { -struct ctl_table *table; -if (net_eq (net, &init_net)) { nf_ct_netfilter_header =register_sysctl_paths (nf_ct_path, nf_ct_netfilter_table);
@@ -484,26 +482,14 @@ static int nf_conntrack_standalone_init_sysctl(struct net *net) goto out; } - table =kmemdup (nf_ct_sysctl_table,sizeof (nf_ct_sysctl_table), -GFP_KERNEL ); -if (!table) - goto out_kmemdup; - - table[1 ].data = &net->ct.count; - table[2 ].data = &net->ct.htable_size; - table[3 ].data = &net->ct.sysctl_checksum; - table[4 ].data = &net->ct.sysctl_log_invalid; - net->ct.sysctl_header =register_net_sysctl_table (net, - nf_net_netfilter_sysctl_path, table); + nf_net_netfilter_sysctl_path, nf_ct_sysctl_table);if (!net->ct.sysctl_header) goto out_unregister_netfilter;return 0 ; out_unregister_netfilter: -kfree (table); -out_kmemdup:if (net_eq (net, &init_net))unregister_sysctl_table (nf_ct_netfilter_header); out:
@@ -513,13 +499,9 @@ out:static void nf_conntrack_standalone_fini_sysctl (struct net *net) { -struct ctl_table *table; - +unregister_net_sysctl_table (net->ct.sysctl_header);if (net_eq (net, &init_net))unregister_sysctl_table (nf_ct_netfilter_header); - table = net->ct.sysctl_header->ctl_table_arg; -unregister_net_sysctl_table (net->ct.sysctl_header); -kfree (table); }#else static int nf_conntrack_standalone_init_sysctl (struct net *net)
Signature · 1 line
1.7.5.rc0
PATCH 15/24 sysctl: cookie: share xfrm_table between nets
In reply to Lucian Adrian Grijincu--- net/xfrm/xfrm_sysctl.c | 37 +++++++++++-------------------------- 1 files changed, 11 insertions(+), 26 deletions(-)
net/xfrm/xfrm_sysctl.c +11 -26
@@ -15,63 +15,48 @@ static void __net_init __xfrm_sysctl_init(struct net *net)static struct ctl_table xfrm_table[] = { { .procname ="xfrm_aevent_etime" , + .data = &init_net.xfrm.sysctl_aevent_etime, .maxlen =sizeof (u32), .mode =0644 , - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec, }, { .procname ="xfrm_aevent_rseqth" , + .data = &init_net.xfrm.sysctl_aevent_rseqth, .maxlen =sizeof (u32), .mode =0644 , - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec, }, { .procname ="xfrm_larval_drop" , + .data = &init_net.xfrm.sysctl_larval_drop, .maxlen =sizeof (int ), .mode =0644 , - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec, }, { .procname ="xfrm_acq_expires" , + .data = &init_net.xfrm.sysctl_acq_expires, .maxlen =sizeof (int ), .mode =0644 , - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec, }, {} };int __net_init xfrm_sysctl_init (struct net *net) { -struct ctl_table *table; -__xfrm_sysctl_init (net); - - table =kmemdup (xfrm_table,sizeof (xfrm_table),GFP_KERNEL ); -if (!table) - goto out_kmemdup; - table[0 ].data = &net->xfrm.sysctl_aevent_etime; - table[1 ].data = &net->xfrm.sysctl_aevent_rseqth; - table[2 ].data = &net->xfrm.sysctl_larval_drop; - table[3 ].data = &net->xfrm.sysctl_acq_expires; - - net->xfrm.sysctl_hdr =register_net_sysctl_table (net, net_core_path, table); + net->xfrm.sysctl_hdr =register_net_sysctl_table (net, + net_core_path, xfrm_table);if (!net->xfrm.sysctl_hdr) - goto out_register; +return -ENOMEM ;return 0 ; - -out_register: -kfree (table); -out_kmemdup: -return -ENOMEM ; } void __net_exit xfrm_sysctl_fini(struct net *net) { -struct ctl_table *table; - - table = net->xfrm.sysctl_hdr->ctl_table_arg;unregister_net_sysctl_table (net->xfrm.sysctl_hdr); -kfree (table); }#else int __net_init xfrm_sysctl_init (struct net *net)
Signature · 1 line
1.7.5.rc0
PATCH 15/24 sysctl: cookie: share xfrm_table between nets
In reply to Lucian Adrian Grijincu--- net/xfrm/xfrm_sysctl.c | 37 +++++++++++-------------------------- 1 files changed, 11 insertions(+), 26 deletions(-)
net/xfrm/xfrm_sysctl.c +11 -26
@@ -15,63 +15,48 @@ static void __net_init __xfrm_sysctl_init(struct net *net)static struct ctl_table xfrm_table[] = { { .procname ="xfrm_aevent_etime" , + .data = &init_net.xfrm.sysctl_aevent_etime, .maxlen =sizeof (u32), .mode =0644 , - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec, }, { .procname ="xfrm_aevent_rseqth" , + .data = &init_net.xfrm.sysctl_aevent_rseqth, .maxlen =sizeof (u32), .mode =0644 , - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec, }, { .procname ="xfrm_larval_drop" , + .data = &init_net.xfrm.sysctl_larval_drop, .maxlen =sizeof (int ), .mode =0644 , - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec, }, { .procname ="xfrm_acq_expires" , + .data = &init_net.xfrm.sysctl_acq_expires, .maxlen =sizeof (int ), .mode =0644 , - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec, }, {} };int __net_init xfrm_sysctl_init (struct net *net) { -struct ctl_table *table; -__xfrm_sysctl_init (net); - - table =kmemdup (xfrm_table,sizeof (xfrm_table),GFP_KERNEL ); -if (!table) - goto out_kmemdup; - table[0 ].data = &net->xfrm.sysctl_aevent_etime; - table[1 ].data = &net->xfrm.sysctl_aevent_rseqth; - table[2 ].data = &net->xfrm.sysctl_larval_drop; - table[3 ].data = &net->xfrm.sysctl_acq_expires; - - net->xfrm.sysctl_hdr =register_net_sysctl_table (net, net_core_path, table); + net->xfrm.sysctl_hdr =register_net_sysctl_table (net, + net_core_path, xfrm_table);if (!net->xfrm.sysctl_hdr) - goto out_register; +return -ENOMEM ;return 0 ; - -out_register: -kfree (table); -out_kmemdup: -return -ENOMEM ; } void __net_exit xfrm_sysctl_fini(struct net *net) { -struct ctl_table *table; - - table = net->xfrm.sysctl_hdr->ctl_table_arg;unregister_net_sysctl_table (net->xfrm.sysctl_hdr); -kfree (table); }#else int __net_init xfrm_sysctl_init (struct net *net)
Signature · 1 line
1.7.5.rc0
PATCH 16/24 sysctl: add support for private_children headers
In reply to Lucian Adrian GrijincuProblem:
- some subsystems register a lot of sysctl tables in a well known place. e.g. all the '/proc/sys/net/ipv4/conf/$DEVNAME' headers under '/proc/sys/net/ipv4/conf/'.
- each time we look for a header we search the list of all headers in it's set (each network namespace specific headers gets it's own set)
When to use private_children:
- when you have registered the parent node of the table you're registering, and you know no other node with a path closer to the one you're registering will be registered.
- when you don't want to register another table underneath the header you're registering
- when you don't need to check for duplicate table names (you have external logic that prevents duplicates).
Advantages of private_children usage:
- the private children are not checked for duplicates
- the private children will be attached to the specified parent. We don't compute the parent by checking with all headers in the set.
- the private children list will only be accessed if the specified parent was accessed. All non-private headers in the set are iterated over when looking for headers attached to another header.
Private headers bring these benefits:
- fast insertion time: O(1) [no duplicate check, fixed parent]
- fast lookup time: only search the parent and it's private_children Not looking over the list of all headers.
- fewer headers in the per-set list of headers => overall reduced insertion/lookup times
Notes for reviewers: there is also room for improvement:
- The cost of checking the list of private children can be very low by limiting the cases where private children may be used:
For example:
p = find_in_table(table, name);
if (!p)
for (h = sysctl_private_child_next(NULL, head); h;
h = sysctl_private_child_next(h, head)) { ... }can be converted into:
if (table->procname)
p = find_in_table(table, name);
else
for (h = sysctl_private_child_next(NULL, head); h;
h = sysctl_private_child_next(h, head)) { ... }If only headers that point to empty directories are allowed to hold private children, and all private children are located in the deepest element of the path, we can use the second variant.
I didn't limit the usability of private children in this patch, because someone else may find use for them in contexts that I have not foreseen, but all of the patches that follow in this series respect this restriction: e.g.:
- the parent header is an empty dir /proc/sys/net/ipv4/conf/
- all children are of the for /proc/sys/net/ipv4/conf/DEVNAME. No private child is registered at a level higher that 'conf'.
Another optimisation would be to replace the linked list of private children with a hashtable: this would lower the lookup times, but would cost more memory and complicate the disposal logic.
--- fs/proc/proc_sysctl.c | 21 ++++++++++++++ include/linux/sysctl.h | 12 +++++++- kernel/sysctl.c | 72 +++++++++++++++++++++++++++++++++++++++++------ net/sysctl_net.c | 4 +- 4 files changed, 96 insertions(+), 13 deletions(-)
fs/proc/proc_sysctl.c +21 -0
@@ -99,6 +99,16 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry, p =find_in_table (table, name);if (!p) { +for (h =sysctl_private_child_next (NULL , head); h; + h =sysctl_private_child_next (h, head)) { +if (h->attached_to != table) +continue ; + p =find_in_table (h->attached_by, name); +if (p) +break ; + } + } +if (!p) {for (h =sysctl_head_next (NULL ); h; h =sysctl_head_next (h)) {if (h->attached_to != table)continue ;
@@ -280,6 +290,17 @@ static int proc_sys_readdir(struct file *filp, void *dirent, filldir_t filldir)if (ret) goto out; +for (h =sysctl_private_child_next (NULL , head); h; + h =sysctl_private_child_next (h, head)) { +if (h->attached_to != table) +continue ; + ret =scan (h, h->attached_by, &pos, filp, dirent, filldir); +if (ret) { +sysctl_head_finish (h); +break ; + } + } +for (h =sysctl_head_next (NULL ); h; h =sysctl_head_next (h)) {if (h->attached_to != table)continue ;
include/linux/sysctl.h +11 -1
@@ -956,6 +956,8 @@ extern struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *);extern struct ctl_table_header *sysctl_head_next (struct ctl_table_header *prev);extern struct ctl_table_header *__sysctl_head_next (struct nsproxy *namespaces,struct ctl_table_header *prev); +extern struct ctl_table_header *sysctl_private_child_next ( +struct ctl_table_header *prev,struct ctl_table_header *parent);extern void sysctl_head_finish (struct ctl_table_header *prev);extern int sysctl_perm (struct ctl_table_root *root,struct ctl_table *table,int op);
@@ -1067,6 +1069,13 @@ struct ctl_table_header/* Pointer to data that outlives this ctl_table_header. * Caller responsible to free the cookie. */ void *ctl_header_cookie; + +/* List of other headers that are 'children' of this header: +* - the children must be freed before this header +* - the children are assumed to be unique (no duplicate checks) +* - the children are not listed under attached_to/attached_by +* - you cannot attach another node under a private child. */ +struct list_head private_children; };/* struct ctl_path describes where in the hierarchy a table is added */
@@ -1077,7 +1086,8 @@ struct ctl_path {void register_sysctl_root (struct ctl_table_root *root);struct ctl_table_header *__register_sysctl_paths (struct ctl_table_root *root,struct nsproxy *namespaces, -const struct ctl_path *path,struct ctl_table *table,void *cookie); +const struct ctl_path *path,struct ctl_table *table, +void *cookie,struct ctl_table_header *private_parent);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 *table);
kernel/sysctl.c +62 -10
126 lines not on this page · raw message
net/sysctl_net.c +2 -2
@@ -110,7 +110,7 @@ struct ctl_table_header *register_net_sysctl_table(struct net *net, namespaces = *current->nsproxy; namespaces.net_ns = net;return __register_sysctl_paths (&net_sysctl_root, &namespaces, path, - table, net); + table, net,NULL ); }EXPORT_SYMBOL_GPL (register_net_sysctl_table);
@@ -118,7 +118,7 @@ struct ctl_table_header *register_net_sysctl_rotable(const struct ctl_path *path, struct ctl_table *table) { return __register_sysctl_paths(&net_sysctl_ro_root, - &init_nsproxy, path, table, NULL); + &init_nsproxy, path, table, NULL, NULL); }EXPORT_SYMBOL_GPL (register_net_sysctl_rotable);
Signature · 1 line
1.7.5.rc0
PATCH 17/24 sysctl: add register_net_sysctl_table_with_parent
In reply to Lucian Adrian Grijincu--- include/net/net_namespace.h | 3 +++ net/sysctl_net.c | 20 +++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-)
include/net/net_namespace.h +3 -0
@@ -272,6 +272,9 @@ struct ctl_path;struct ctl_table ;struct ctl_table_header ; +extern struct ctl_table_header *register_net_sysctl_table_with_parent ( +struct net *net,const struct ctl_path *path, +struct ctl_table *table,struct ctl_table_header *parent);extern struct ctl_table_header *register_net_sysctl_table (struct net *net,const struct ctl_path *path,struct ctl_table *table); extern struct ctl_table_header *register_net_sysctl_rotable(
net/sysctl_net.c +17 -3
@@ -103,14 +103,28 @@ out: }subsys_initcall (sysctl_init); -struct ctl_table_header *register_net_sysctl_table (struct net *net, -const struct ctl_path *path,struct ctl_table *table) +/* The newly created ctl_table_header will be a member of the parent's +* private_children list. The following restrictions apply: +* - the children must be freed before the parent +* - the children are assumed to be unique (no duplicate checks) +* - the children are not listed under attached_to/attached_by +* - you cannot attach another node under a private child. */ +struct ctl_table_header *register_net_sysctl_table_with_parent (struct net *net, +const struct ctl_path *path,struct ctl_table *table, +struct ctl_table_header *parent) {struct nsproxy namespaces; namespaces = *current->nsproxy; namespaces.net_ns = net;return __register_sysctl_paths (&net_sysctl_root, &namespaces, path, - table, net,NULL ); + table, net, parent); +} +EXPORT_SYMBOL_GPL (register_net_sysctl_table_with_parent); + +struct ctl_table_header *register_net_sysctl_table (struct net *net, +const struct ctl_path *path,struct ctl_table *table) +{ +return register_net_sysctl_table_with_parent (net, path, table,NULL ); }EXPORT_SYMBOL_GPL (register_net_sysctl_table);
Signature · 1 line
1.7.5.rc0
PATCH 17/24 sysctl: add register_net_sysctl_table_with_parent
In reply to Lucian Adrian Grijincu--- include/net/net_namespace.h | 3 +++ net/sysctl_net.c | 20 +++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-)
include/net/net_namespace.h +3 -0
@@ -272,6 +272,9 @@ struct ctl_path;struct ctl_table ;struct ctl_table_header ; +extern struct ctl_table_header *register_net_sysctl_table_with_parent ( +struct net *net,const struct ctl_path *path, +struct ctl_table *table,struct ctl_table_header *parent);extern struct ctl_table_header *register_net_sysctl_table (struct net *net,const struct ctl_path *path,struct ctl_table *table); extern struct ctl_table_header *register_net_sysctl_rotable(
net/sysctl_net.c +17 -3
@@ -103,14 +103,28 @@ out: }subsys_initcall (sysctl_init); -struct ctl_table_header *register_net_sysctl_table (struct net *net, -const struct ctl_path *path,struct ctl_table *table) +/* The newly created ctl_table_header will be a member of the parent's +* private_children list. The following restrictions apply: +* - the children must be freed before the parent +* - the children are assumed to be unique (no duplicate checks) +* - the children are not listed under attached_to/attached_by +* - you cannot attach another node under a private child. */ +struct ctl_table_header *register_net_sysctl_table_with_parent (struct net *net, +const struct ctl_path *path,struct ctl_table *table, +struct ctl_table_header *parent) {struct nsproxy namespaces; namespaces = *current->nsproxy; namespaces.net_ns = net;return __register_sysctl_paths (&net_sysctl_root, &namespaces, path, - table, net,NULL ); + table, net, parent); +} +EXPORT_SYMBOL_GPL (register_net_sysctl_table_with_parent); + +struct ctl_table_header *register_net_sysctl_table (struct net *net, +const struct ctl_path *path,struct ctl_table *table) +{ +return register_net_sysctl_table_with_parent (net, path, table,NULL ); }EXPORT_SYMBOL_GPL (register_net_sysctl_table);
Signature · 1 line
1.7.5.rc0
PATCH 18/24 sysctl: ipv4: register /proc/sys/net/ipv4/conf empty directory
In reply to Lucian Adrian GrijincuThis does not change any semantics: it just adds a new header that will be used in the next patch as a parent for all headers for all /proc/sys/net/ipv4/conf/DEVNAME entries.
For now, all interface headers for /proc/sys/net/ipv4/conf/DEVNAME will be bound to this header as opposed to another one from above, but this shouldn't affect performance or behaviour.
--- include/net/netns/ipv4.h | 9 +++++---- net/ipv4/devinet.c | 25 +++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 6 deletions(-)
include/net/netns/ipv4.h +5 -4
@@ -15,10 +15,11 @@ struct sock;struct netns_ipv4 {#ifdef CONFIG_SYSCTL -struct ctl_table_header *forw_hdr; -struct ctl_table_header *frags_hdr; -struct ctl_table_header *ipv4_hdr; -struct ctl_table_header *route_hdr; +struct ctl_table_header *forw_hdr;/* /proc/sys/net/ipv4/ip_forward */ +struct ctl_table_header *conf_hdr;/* /proc/sys/net/ipv4/conf/ */ +struct ctl_table_header *frags_hdr;/* /proc/sys/net/ipv4/ipfrag_* */ +struct ctl_table_header *ipv4_hdr;/* see @ipv4_net_table */ +struct ctl_table_header *route_hdr;/* /proc/sys/net/ipv4/route/flush */ #endif struct ipv4_devconf *devconf_all;struct ipv4_devconf *devconf_dflt;
net/ipv4/devinet.c +23 -2
@@ -1698,6 +1698,18 @@ static void devinet_sysctl_unregister(struct in_device *idev)neigh_sysctl_unregister (idev->arp_parms); } + +/* empty entry for '/proc/sys/net/ipv4/conf/' */ +static __net_initdata struct ctl_table empty[1 ]; +static __net_initdata struct ctl_table ipv4_conf_skel[] = { + { + .procname ="conf" , + .mode =0555 , + .child = empty, + }, + { }, +}; +static struct ctl_table ctl_forward_entry[] = { { .procname ="ip_forward" ,
@@ -1712,7 +1724,7 @@ static struct ctl_table ctl_forward_entry[] = { { }, }; -static __net_initdata struct ctl_path net_ipv4_path[] = { +static __net_initdata const struct ctl_path net_ipv4_path[] = { { .procname ="net" , }, { .procname ="ipv4" , }, { },
@@ -1725,7 +1737,7 @@ static __net_init int devinet_init_net(struct net *net)struct ipv4_devconf *all, *dflt;#ifdef CONFIG_SYSCTL struct ctl_table *tbl = ctl_forward_entry; -struct ctl_table_header *forw_hdr; +struct ctl_table_header *forw_hdr, *conf_hdr;#endif err = -ENOMEM ;
@@ -1753,6 +1765,12 @@ static __net_init int devinet_init_net(struct net *net) }#ifdef CONFIG_SYSCTL + err = -ENOMEM ; + conf_hdr =register_net_sysctl_table (net, net_ipv4_path, ipv4_conf_skel); +if (conf_hdr ==NULL ) + goto err_reg_conf; + net->ipv4.conf_hdr = conf_hdr; + err =__devinet_sysctl_register (net,"all" , all);if (err <0 ) goto err_reg_all;
@@ -1778,6 +1796,8 @@ err_reg_ctl: err_reg_dflt:__devinet_sysctl_unregister (all); err_reg_all: +unregister_net_sysctl_table (conf_hdr); +err_reg_conf:if (tbl != ctl_forward_entry)kfree (tbl); err_alloc_ctl:
@@ -1800,6 +1820,7 @@ static __net_exit void devinet_exit_net(struct net *net)unregister_net_sysctl_table (net->ipv4.forw_hdr);__devinet_sysctl_unregister (net->ipv4.devconf_dflt);__devinet_sysctl_unregister (net->ipv4.devconf_all); +unregister_net_sysctl_table (net->ipv4.conf_hdr);kfree (tbl);#endif kfree (net->ipv4.devconf_dflt);
Signature · 1 line
1.7.5.rc0
PATCH 16/24 sysctl: add support for private_children headers
In reply to Lucian Adrian GrijincuProblem:
- some subsystems register a lot of sysctl tables in a well known place. e.g. all the '/proc/sys/net/ipv4/conf/$DEVNAME' headers under '/proc/sys/net/ipv4/conf/'.
- each time we look for a header we search the list of all headers in it's set (each network namespace specific headers gets it's own set)
When to use private_children:
- when you have registered the parent node of the table you're registering, and you know no other node with a path closer to the one you're registering will be registered.
- when you don't want to register another table underneath the header you're registering
- when you don't need to check for duplicate table names (you have external logic that prevents duplicates).
Advantages of private_children usage:
- the private children are not checked for duplicates
- the private children will be attached to the specified parent. We don't compute the parent by checking with all headers in the set.
- the private children list will only be accessed if the specified parent was accessed. All non-private headers in the set are iterated over when looking for headers attached to another header.
Private headers bring these benefits:
- fast insertion time: O(1) [no duplicate check, fixed parent]
- fast lookup time: only search the parent and it's private_children Not looking over the list of all headers.
- fewer headers in the per-set list of headers => overall reduced insertion/lookup times
Notes for reviewers: there is also room for improvement:
- The cost of checking the list of private children can be very low by limiting the cases where private children may be used:
For example:
p = find_in_table(table, name);
if (!p)
for (h = sysctl_private_child_next(NULL, head); h;
h = sysctl_private_child_next(h, head)) { ... }can be converted into:
if (table->procname)
p = find_in_table(table, name);
else
for (h = sysctl_private_child_next(NULL, head); h;
h = sysctl_private_child_next(h, head)) { ... }If only headers that point to empty directories are allowed to hold private children, and all private children are located in the deepest element of the path, we can use the second variant.
I didn't limit the usability of private children in this patch, because someone else may find use for them in contexts that I have not foreseen, but all of the patches that follow in this series respect this restriction: e.g.:
- the parent header is an empty dir /proc/sys/net/ipv4/conf/
- all children are of the for /proc/sys/net/ipv4/conf/DEVNAME. No private child is registered at a level higher that 'conf'.
Another optimisation would be to replace the linked list of private children with a hashtable: this would lower the lookup times, but would cost more memory and complicate the disposal logic.
--- fs/proc/proc_sysctl.c | 21 ++++++++++++++ include/linux/sysctl.h | 12 +++++++- kernel/sysctl.c | 72 +++++++++++++++++++++++++++++++++++++++++------ net/sysctl_net.c | 4 +- 4 files changed, 96 insertions(+), 13 deletions(-)
fs/proc/proc_sysctl.c +21 -0
@@ -99,6 +99,16 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry, p =find_in_table (table, name);if (!p) { +for (h =sysctl_private_child_next (NULL , head); h; + h =sysctl_private_child_next (h, head)) { +if (h->attached_to != table) +continue ; + p =find_in_table (h->attached_by, name); +if (p) +break ; + } + } +if (!p) {for (h =sysctl_head_next (NULL ); h; h =sysctl_head_next (h)) {if (h->attached_to != table)continue ;
@@ -280,6 +290,17 @@ static int proc_sys_readdir(struct file *filp, void *dirent, filldir_t filldir)if (ret) goto out; +for (h =sysctl_private_child_next (NULL , head); h; + h =sysctl_private_child_next (h, head)) { +if (h->attached_to != table) +continue ; + ret =scan (h, h->attached_by, &pos, filp, dirent, filldir); +if (ret) { +sysctl_head_finish (h); +break ; + } + } +for (h =sysctl_head_next (NULL ); h; h =sysctl_head_next (h)) {if (h->attached_to != table)continue ;
include/linux/sysctl.h +11 -1
@@ -956,6 +956,8 @@ extern struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *);extern struct ctl_table_header *sysctl_head_next (struct ctl_table_header *prev);extern struct ctl_table_header *__sysctl_head_next (struct nsproxy *namespaces,struct ctl_table_header *prev); +extern struct ctl_table_header *sysctl_private_child_next ( +struct ctl_table_header *prev,struct ctl_table_header *parent);extern void sysctl_head_finish (struct ctl_table_header *prev);extern int sysctl_perm (struct ctl_table_root *root,struct ctl_table *table,int op);
@@ -1067,6 +1069,13 @@ struct ctl_table_header/* Pointer to data that outlives this ctl_table_header. * Caller responsible to free the cookie. */ void *ctl_header_cookie; + +/* List of other headers that are 'children' of this header: +* - the children must be freed before this header +* - the children are assumed to be unique (no duplicate checks) +* - the children are not listed under attached_to/attached_by +* - you cannot attach another node under a private child. */ +struct list_head private_children; };/* struct ctl_path describes where in the hierarchy a table is added */
@@ -1077,7 +1086,8 @@ struct ctl_path {void register_sysctl_root (struct ctl_table_root *root);struct ctl_table_header *__register_sysctl_paths (struct ctl_table_root *root,struct nsproxy *namespaces, -const struct ctl_path *path,struct ctl_table *table,void *cookie); +const struct ctl_path *path,struct ctl_table *table, +void *cookie,struct ctl_table_header *private_parent);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 *table);
kernel/sysctl.c +62 -10
126 lines not on this page · raw message
net/sysctl_net.c +2 -2
@@ -110,7 +110,7 @@ struct ctl_table_header *register_net_sysctl_table(struct net *net, namespaces = *current->nsproxy; namespaces.net_ns = net;return __register_sysctl_paths (&net_sysctl_root, &namespaces, path, - table, net); + table, net,NULL ); }EXPORT_SYMBOL_GPL (register_net_sysctl_table);
@@ -118,7 +118,7 @@ struct ctl_table_header *register_net_sysctl_rotable(const struct ctl_path *path, struct ctl_table *table) { return __register_sysctl_paths(&net_sysctl_ro_root, - &init_nsproxy, path, table, NULL); + &init_nsproxy, path, table, NULL, NULL); }EXPORT_SYMBOL_GPL (register_net_sysctl_rotable);
Signature · 1 line
1.7.5.rc0
PATCH 19/24 sysctl: ipv4: register devinet tables as private children
In reply to Lucian Adrian GrijincuThis halves the time it takes to add an interface:
$ time modprobe dummy numdummies=$n
Without this patch:
- n=5000 => real: 17:31m, sys 15:29m
- n=2000 => real: 2:23m, sys 2:19m - n=1000 => real: 0:25m, sys 0:24m
With this patch:
- n=5000 => real: 9:14m, sys: 8:46m - n=2000 => real: 1:19m, sys: 1:17m - n=1000 => real: 0:14m, sys: 0:14m
--- net/ipv4/devinet.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
net/ipv4/devinet.c +2 -2
@@ -1656,8 +1656,8 @@ static int __devinet_sysctl_register(struct net *net, char *dev_name, devinet_ctl_path[DEVINET_CTL_PATH_DEV ].procname = t->dev_name; - t->sysctl_header =register_net_sysctl_table (net, devinet_ctl_path, - t->devinet_vars); + t->sysctl_header =register_net_sysctl_table_with_parent (net, + devinet_ctl_path, t->devinet_vars, net->ipv4.conf_hdr);if (!t->sysctl_header) goto free_procname;
Signature · 1 line
1.7.5.rc0
PATCH 20/24 sysctl: ipv6: register /proc/sys/net/ipv6/conf empty directory
In reply to Lucian Adrian GrijincuThis does not change any semantics: it just adds a new header that will be used in the next patch as a parent for all headers for all /proc/sys/net/ipv6/conf/DEVNAME entries.
For now, all interface headers for /proc/sys/net/ipv6/conf/DEVNAME will be bound to this header as opposed to another one from above, but this shouldn't affect performance or behaviour.
--- include/net/netns/ipv6.h | 3 ++- net/ipv6/addrconf.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-)
include/net/netns/ipv6.h +2 -1
@@ -13,7 +13,8 @@ struct ctl_table_header;struct netns_sysctl_ipv6 {#ifdef CONFIG_SYSCTL struct ctl_table_header *table; -struct ctl_table_header *frags_hdr; +struct ctl_table_header *frags_hdr;/* /proc/sys/net/ipv6/ip6frag_* */ +struct ctl_table_header *conf_hdr;/* /proc/sys/net/ipv6/conf/ */ #endif int bindv6only;int flush_delay;
net/ipv6/addrconf.c +28 -1
@@ -4556,8 +4556,25 @@ static void addrconf_sysctl_unregister(struct inet6_dev *idev) neigh_sysctl_unregister(idev->nd_parms); } +/* empty entry for '/proc/sys/net/ipv6/conf/' */ +static __net_initdata struct ctl_table empty[1 ]; +static __net_initdata struct ctl_table ipv6_conf_skel[] = { + { + .procname ="conf" , + .mode =0555 , + .child = empty, + }, + { }, +}; + +static __net_initdata const struct ctl_path net_ipv6_path[] = { + { .procname ="net" , }, + { .procname ="ipv6" , }, + { }, +}; + +#endif /* CONFIG_SYSCTL */ -#endif static int __net_init addrconf_init_net (struct net *net) {
@@ -4586,6 +4603,12 @@ static int __net_init addrconf_init_net(struct net *net) net->ipv6.devconf_dflt = dflt;#ifdef CONFIG_SYSCTL + err = -ENOMEM ; + net->ipv6.sysctl.conf_hdr =register_net_sysctl_table (net, + net_ipv6_path, ipv6_conf_skel); +if (net->ipv6.sysctl.conf_hdr ==NULL ) + goto err_reg_conf; + err =__addrconf_sysctl_register (net,"all" ,NULL , all);if (err <0 ) goto err_reg_all;
@@ -4593,6 +4616,7 @@ static int __net_init addrconf_init_net(struct net *net) err =__addrconf_sysctl_register (net,"default" ,NULL , dflt);if (err <0 ) goto err_reg_dflt; +#endif return 0 ;
@@ -4600,6 +4624,8 @@ static int __net_init addrconf_init_net(struct net *net) err_reg_dflt:__addrconf_sysctl_unregister (all); err_reg_all: +unregister_net_sysctl_table (net->ipv6.sysctl.conf_hdr); +err_reg_conf:kfree (dflt);#endif err_alloc_dflt:
@@ -4613,6 +4639,7 @@ static void __net_exit addrconf_exit_net(struct net *net)#ifdef CONFIG_SYSCTL __addrconf_sysctl_unregister (net->ipv6.devconf_dflt);__addrconf_sysctl_unregister (net->ipv6.devconf_all); +unregister_net_sysctl_table (net->ipv6.sysctl.conf_hdr);#endif if (!net_eq (net, &init_net)) {kfree (net->ipv6.devconf_dflt);
Signature · 1 line
1.7.5.rc0
PATCH 19/24 sysctl: ipv4: register devinet tables as private children
In reply to Lucian Adrian GrijincuThis halves the time it takes to add an interface:
$ time modprobe dummy numdummies=$n
Without this patch:
- n=5000 => real: 17:31m, sys 15:29m
- n=2000 => real: 2:23m, sys 2:19m - n=1000 => real: 0:25m, sys 0:24m
With this patch:
- n=5000 => real: 9:14m, sys: 8:46m - n=2000 => real: 1:19m, sys: 1:17m - n=1000 => real: 0:14m, sys: 0:14m
--- net/ipv4/devinet.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
net/ipv4/devinet.c +2 -2
@@ -1656,8 +1656,8 @@ static int __devinet_sysctl_register(struct net *net, char *dev_name, devinet_ctl_path[DEVINET_CTL_PATH_DEV ].procname = t->dev_name; - t->sysctl_header =register_net_sysctl_table (net, devinet_ctl_path, - t->devinet_vars); + t->sysctl_header =register_net_sysctl_table_with_parent (net, + devinet_ctl_path, t->devinet_vars, net->ipv4.conf_hdr);if (!t->sysctl_header) goto free_procname;
Signature · 1 line
1.7.5.rc0
PATCH 21/24 sysctl: ipv6: register addrconf tables as private children
In reply to Lucian Adrian GrijincuThis halves the time it takes to add an interface:
$ time modprobe dummy numdummies=$n
Without this patch:
- n=5000 => real: 9:14m, sys: 8:46m - n=2000 => real: 1:19m, sys: 1:17m - n=1000 => real: 0:14m, sys: 0:14m
With this patch:
- n=5000 => real: 4:43m, sys: 4:32m - n=2000 => real: 0:39m, sys: 0:39m - n=1000 => real: 0:07m, sys: 0:07m
--- net/ipv6/addrconf.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
net/ipv6/addrconf.c +2 -2
@@ -4512,8 +4512,8 @@ static int __addrconf_sysctl_register(struct net *net, char *dev_name, addrconf_ctl_path[ADDRCONF_CTL_PATH_DEV ].procname = t->dev_name; - t->sysctl_header =register_net_sysctl_table (net, addrconf_ctl_path, - t->addrconf_vars); + t->sysctl_header =register_net_sysctl_table_with_parent (net, + addrconf_ctl_path, t->addrconf_vars, net->ipv6.sysctl.conf_hdr);if (t->sysctl_header ==NULL ) goto free_procname;
Signature · 1 line
1.7.5.rc0
PATCH 22/24 sysctl: ipv4: register /proc/sys/net/ipv4/neigh empty directory
In reply to Lucian Adrian GrijincuAs opposed to the patches that added the /proc/sys/net/ipv4/conf and /proc/sys/net/ipv6/conf empty directories, this patch does include a change in semantics.
Before this patch /proc/sys/net/ipv4/neigh/default/ was registered from arp_init() directly.
This patch adds new pernet_operations in which it first registers /proc/sys/net/ipv4/neigh/ and afterwards /proc/sys/net/ipv4/neigh/default/.
These operations are ran for each network namespace in part, even for init_net (which is the only net that sees the 'default' entry), thus /proc/sys/net/ipv4/neigh/default/ gets registered, just that the registration now happens later that before this patch.
In testing this did not seem to create problems, but I haven't checked the code thoroughly.
--- include/net/netns/ipv4.h | 1 + net/ipv4/arp.c | 70 ++++++++++++++++++++++++++++++++++++++++++++-- net/ipv4/route.c | 13 ++++---- 3 files changed, 74 insertions(+), 10 deletions(-)
include/net/netns/ipv4.h +1 -0
@@ -17,6 +17,7 @@ struct netns_ipv4 {#ifdef CONFIG_SYSCTL struct ctl_table_header *forw_hdr;/* /proc/sys/net/ipv4/ip_forward */ struct ctl_table_header *conf_hdr;/* /proc/sys/net/ipv4/conf/ */ +struct ctl_table_header *neigh_hdr;/* /proc/sys/net/ipv4/neigh/ */ struct ctl_table_header *frags_hdr;/* /proc/sys/net/ipv4/ipfrag_* */ struct ctl_table_header *ipv4_hdr;/* see @ipv4_net_table */ struct ctl_table_header *route_hdr;/* /proc/sys/net/ipv4/route/flush */
net/ipv4/arp.c +67 -3
85 lines not on this page · raw message
net/ipv4/route.c +6 -7
@@ -3139,15 +3139,14 @@ static ctl_table ipv4_route_table[] = { { } }; -static struct ctl_table empty[1 ]; -static struct ctl_table ipv4_skeleton[] = { - { .procname ="route" , - .mode =0555 , .child = ipv4_route_table}, - { .procname ="neigh" , - .mode =0555 , .child = empty}, - { } + { + .procname ="route" , + .mode =0555 , + .child = ipv4_route_table, + }, + { }, };static __net_initdata struct ctl_path ipv4_path[] = {
Signature · 1 line
1.7.5.rc0
PATCH 23/24 sysctl: ipv6: register /proc/sys/net/ipv6/neigh empty directory
In reply to Lucian Adrian GrijincuSimilar to the previous patch. This patch also changes the moment /proc/sys/net/ipv6/neigh/default is registered:
- before this patch: the 'default' was registered directly in ndisc_init()
- with this patch: 'default' is registered after the empty /proc/sys/net/ipv6/neigh/ directly which is created for each network namespace as a pernet operation. Because of this the neigh_tables have to be initialised (neigh_table_init) before registering pernet ops and cleaned up after unregistering them.
--- include/net/ipv6.h | 2 - include/net/netns/ipv6.h | 1 + net/ipv6/af_inet6.c | 12 ------- net/ipv6/ndisc.c | 76 ++++++++++++++++++++++++++++++++++---------- net/ipv6/sysctl_net_ipv6.c | 27 --------------- 5 files changed, 60 insertions(+), 58 deletions(-)
include/net/ipv6.h +0 -2
@@ -661,8 +661,6 @@ extern ctl_table ipv6_icmp_table[];extern int ipv6_sysctl_register (void );extern void ipv6_sysctl_unregister (void ); -extern int ipv6_static_sysctl_register (void ); -extern void ipv6_static_sysctl_unregister (void );#endif #endif /* __KERNEL__ */
include/net/netns/ipv6.h +1 -0
@@ -15,6 +15,7 @@ struct netns_sysctl_ipv6 {struct ctl_table_header *table;struct ctl_table_header *frags_hdr;/* /proc/sys/net/ipv6/ip6frag_* */ struct ctl_table_header *conf_hdr;/* /proc/sys/net/ipv6/conf/ */ +struct ctl_table_header *neigh_hdr;/* /proc/sys/net/ipv6/neigh/ */ #endif int bindv6only;int flush_delay;
net/ipv6/af_inet6.c +0 -12
@@ -1105,11 +1105,6 @@ static int __init inet6_init(void)if (err) goto out_sock_register_fail; -#ifdef CONFIG_SYSCTL - err =ipv6_static_sysctl_register (); -if (err) - goto static_sysctl_fail; -#endif /* * ipngwg API draft makes clear that the correct semantics * for TCP and UDP is to consider one TCP and UDP instance
@@ -1234,10 +1229,6 @@ ipmr_fail: icmp_fail:unregister_pernet_subsys (&inet6_net_ops); register_pernet_fail: -#ifdef CONFIG_SYSCTL -ipv6_static_sysctl_unregister (); -static_sysctl_fail: -#endifsock_unregister (PF_INET6 );rtnl_unregister_all (PF_INET6 ); out_sock_register_fail:
@@ -1294,9 +1285,6 @@ static void __exit inet6_exit(void)rawv6_exit ();unregister_pernet_subsys (&inet6_net_ops); -#ifdef CONFIG_SYSCTL -ipv6_static_sysctl_unregister (); -#endif proto_unregister (&rawv6_prot);proto_unregister (&udplitev6_prot);proto_unregister (&udpv6_prot);
net/ipv6/ndisc.c +59 -17
128 lines not on this page · raw message
net/ipv6/sysctl_net_ipv6.c +0 -27
@@ -15,18 +15,6 @@#include <net/addrconf.h> #include <net/inet_frag.h> -static struct ctl_table empty[1 ]; - -static ctl_table ipv6_static_skeleton[] = { - { - .procname ="neigh" , - .maxlen =0 , - .mode =0555 , - .child = empty, - }, - { } -}; -static ctl_table ipv6_table[] = { { .procname ="route" ,
@@ -114,18 +102,3 @@ void ipv6_sysctl_unregister(void)unregister_net_sysctl_table (ip6_header);unregister_pernet_subsys (&ipv6_sysctl_net_ops); } - -static struct ctl_table_header *ip6_base; - -int ipv6_static_sysctl_register (void ) -{ - ip6_base =register_sysctl_paths (net_ipv6_ctl_path, ipv6_static_skeleton); -if (ip6_base ==NULL ) -return -ENOMEM ; -return 0 ; -} - -void ipv6_static_sysctl_unregister (void ) -{ -unregister_net_sysctl_table (ip6_base); -}
Signature · 1 line
1.7.5.rc0
PATCH 21/24 sysctl: ipv6: register addrconf tables as private children
In reply to Lucian Adrian GrijincuThis halves the time it takes to add an interface:
$ time modprobe dummy numdummies=$n
Without this patch:
- n=5000 => real: 9:14m, sys: 8:46m - n=2000 => real: 1:19m, sys: 1:17m - n=1000 => real: 0:14m, sys: 0:14m
With this patch:
- n=5000 => real: 4:43m, sys: 4:32m - n=2000 => real: 0:39m, sys: 0:39m - n=1000 => real: 0:07m, sys: 0:07m
--- net/ipv6/addrconf.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
net/ipv6/addrconf.c +2 -2
@@ -4512,8 +4512,8 @@ static int __addrconf_sysctl_register(struct net *net, char *dev_name, addrconf_ctl_path[ADDRCONF_CTL_PATH_DEV ].procname = t->dev_name; - t->sysctl_header =register_net_sysctl_table (net, addrconf_ctl_path, - t->addrconf_vars); + t->sysctl_header =register_net_sysctl_table_with_parent (net, + addrconf_ctl_path, t->addrconf_vars, net->ipv6.sysctl.conf_hdr);if (t->sysctl_header ==NULL ) goto free_procname;
Signature · 1 line
1.7.5.rc0
PATCH 24/24 sysctl: neigh: ipv4 and ipv6 neigh tables as private children
In reply to Lucian Adrian Grijincu$ time modprobe dummy numdummies=$n
Without this patch:
- n=5000 => real: 9:14m, sys: 8:46m - n=2000 => real: 1:19m, sys: 1:17m - n=1000 => real: 0:14m, sys: 0:14m
With this patch:
- n=5000 => real: 12.50s
- n=2000 => real: 1.59s
- n=1000 => real: 0.44s
$ time find /proc/sys/net/ > /dev/null
Without this patch:
- n=5000 => real: 15s
- n=2000 => real: 12s
- n=1000 => real: 4s
With this patch:
- n=5000 => real: 3.77s
- n=2000 => real: 1.55s
- n=1000 => real: 1.43s
--- include/net/neighbour.h | 9 ++++----- net/core/neighbour.c | 6 ++++-- net/ipv4/arp.c | 3 ++- net/ipv4/devinet.c | 3 ++- net/ipv6/addrconf.c | 3 ++- net/ipv6/ndisc.c | 3 ++- 6 files changed, 16 insertions(+), 11 deletions(-)
include/net/neighbour.h +4 -5
@@ -259,11 +259,10 @@ extern void *neigh_seq_start(struct seq_file *, loff_t *, struct neigh_table *,extern void *neigh_seq_next (struct seq_file *,void *,loff_t *);extern void neigh_seq_stop (struct seq_file *,void *); -extern int neigh_sysctl_register (struct net_device *dev, -struct neigh_parms *p, -char *p_name, -proc_handler *proc_handler); -extern void neigh_sysctl_unregister (struct neigh_parms *p); +extern int neigh_sysctl_register (struct net_device *dev,struct neigh_parms *p, +char *p_name,proc_handler *proc_handler, +struct ctl_table_header *parent_header); +extern void neigh_sysctl_unregister (struct neigh_parms *p);static inline void __neigh_parms_put (struct neigh_parms *parms) {
net/core/neighbour.c +4 -2
@@ -2804,7 +2804,8 @@ static struct neigh_sysctl_table { };int neigh_sysctl_register (struct net_device *dev,struct neigh_parms *p, -char *p_name,proc_handler *handler) +char *p_name,proc_handler *handler, +struct ctl_table_header *parent_header) {struct neigh_sysctl_table *t;const char *dev_name_source =NULL ;
@@ -2877,7 +2878,8 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p, neigh_path[NEIGH_CTL_PATH_PROTO ].procname = p_name; t->sysctl_header = -register_net_sysctl_table (neigh_parms_net (p), neigh_path, t->neigh_vars); +register_net_sysctl_table_with_parent (neigh_parms_net (p), + neigh_path, t->neigh_vars, parent_header);if (!t->sysctl_header) goto free_procname;
net/ipv4/arp.c +2 -1
@@ -1509,7 +1509,8 @@ static int __net_init arp_sysctl_net_init(struct net *net)/* register /proc/sys/net/ipv4/neigh/default */ if (net_eq (net, &init_net)) {int err; - err =neigh_sysctl_register (NULL , &arp_tbl.parms,"ipv4" ,NULL ); + err =neigh_sysctl_register (NULL , &arp_tbl.parms,"ipv4" , +NULL , net->ipv4.neigh_hdr);if (err) {unregister_net_sysctl_table (net->ipv4.neigh_hdr);return err;
net/ipv4/devinet.c +2 -1
@@ -1687,7 +1687,8 @@ static void __devinet_sysctl_unregister(struct ipv4_devconf *cnf)static void devinet_sysctl_register (struct in_device *idev) { -neigh_sysctl_register (idev->dev, idev->arp_parms,"ipv4" ,NULL ); +neigh_sysctl_register (idev->dev, idev->arp_parms,"ipv4" , +NULL ,dev_net (idev->dev)->ipv4.neigh_hdr);__devinet_sysctl_register (dev_net (idev->dev), idev->dev->name, &idev->cnf); }
net/ipv6/addrconf.c +2 -1
@@ -4545,7 +4545,8 @@ static void __addrconf_sysctl_unregister(struct ipv6_devconf *p)static void addrconf_sysctl_register (struct inet6_dev *idev) {neigh_sysctl_register (idev->dev, idev->nd_parms,"ipv6" , - &ndisc_ifinfo_sysctl_change); + &ndisc_ifinfo_sysctl_change, +dev_net (idev->dev)->ipv6.sysctl.neigh_hdr);__addrconf_sysctl_register (dev_net (idev->dev), idev->dev->name, idev, &idev->cnf); }
net/ipv6/ndisc.c +2 -1
@@ -1828,7 +1828,8 @@ static int __net_init ndisc_net_init(struct net *net)/* register /proc/sys/net/ipv6/neigh/default */ if (net_eq (net, &init_net)) { err =neigh_sysctl_register (NULL , &nd_tbl.parms,"ipv6" , - &ndisc_ifinfo_sysctl_change); + &ndisc_ifinfo_sysctl_change, + net->ipv6.sysctl.neigh_hdr);if (err) goto neigh_sysctl_register_fail; }
Signature · 1 line
1.7.5.rc0
PATCH 23/24 sysctl: ipv6: register /proc/sys/net/ipv6/neigh empty directory
In reply to Lucian Adrian GrijincuSimilar to the previous patch. This patch also changes the moment /proc/sys/net/ipv6/neigh/default is registered:
- before this patch: the 'default' was registered directly in ndisc_init()
- with this patch: 'default' is registered after the empty /proc/sys/net/ipv6/neigh/ directly which is created for each network namespace as a pernet operation. Because of this the neigh_tables have to be initialised (neigh_table_init) before registering pernet ops and cleaned up after unregistering them.
--- include/net/ipv6.h | 2 - include/net/netns/ipv6.h | 1 + net/ipv6/af_inet6.c | 12 ------- net/ipv6/ndisc.c | 76 ++++++++++++++++++++++++++++++++++---------- net/ipv6/sysctl_net_ipv6.c | 27 --------------- 5 files changed, 60 insertions(+), 58 deletions(-)
include/net/ipv6.h +0 -2
@@ -661,8 +661,6 @@ extern ctl_table ipv6_icmp_table[];extern int ipv6_sysctl_register (void );extern void ipv6_sysctl_unregister (void ); -extern int ipv6_static_sysctl_register (void ); -extern void ipv6_static_sysctl_unregister (void );#endif #endif /* __KERNEL__ */
include/net/netns/ipv6.h +1 -0
@@ -15,6 +15,7 @@ struct netns_sysctl_ipv6 {struct ctl_table_header *table;struct ctl_table_header *frags_hdr;/* /proc/sys/net/ipv6/ip6frag_* */ struct ctl_table_header *conf_hdr;/* /proc/sys/net/ipv6/conf/ */ +struct ctl_table_header *neigh_hdr;/* /proc/sys/net/ipv6/neigh/ */ #endif int bindv6only;int flush_delay;
net/ipv6/af_inet6.c +0 -12
@@ -1105,11 +1105,6 @@ static int __init inet6_init(void)if (err) goto out_sock_register_fail; -#ifdef CONFIG_SYSCTL - err =ipv6_static_sysctl_register (); -if (err) - goto static_sysctl_fail; -#endif /* * ipngwg API draft makes clear that the correct semantics * for TCP and UDP is to consider one TCP and UDP instance
@@ -1234,10 +1229,6 @@ ipmr_fail: icmp_fail:unregister_pernet_subsys (&inet6_net_ops); register_pernet_fail: -#ifdef CONFIG_SYSCTL -ipv6_static_sysctl_unregister (); -static_sysctl_fail: -#endifsock_unregister (PF_INET6 );rtnl_unregister_all (PF_INET6 ); out_sock_register_fail:
@@ -1294,9 +1285,6 @@ static void __exit inet6_exit(void)rawv6_exit ();unregister_pernet_subsys (&inet6_net_ops); -#ifdef CONFIG_SYSCTL -ipv6_static_sysctl_unregister (); -#endif proto_unregister (&rawv6_prot);proto_unregister (&udplitev6_prot);proto_unregister (&udpv6_prot);
net/ipv6/ndisc.c +59 -17
128 lines not on this page · raw message
net/ipv6/sysctl_net_ipv6.c +0 -27
@@ -15,18 +15,6 @@#include <net/addrconf.h> #include <net/inet_frag.h> -static struct ctl_table empty[1 ]; - -static ctl_table ipv6_static_skeleton[] = { - { - .procname ="neigh" , - .maxlen =0 , - .mode =0555 , - .child = empty, - }, - { } -}; -static ctl_table ipv6_table[] = { { .procname ="route" ,
@@ -114,18 +102,3 @@ void ipv6_sysctl_unregister(void)unregister_net_sysctl_table (ip6_header);unregister_pernet_subsys (&ipv6_sysctl_net_ops); } - -static struct ctl_table_header *ip6_base; - -int ipv6_static_sysctl_register (void ) -{ - ip6_base =register_sysctl_paths (net_ipv6_ctl_path, ipv6_static_skeleton); -if (ip6_base ==NULL ) -return -ENOMEM ; -return 0 ; -} - -void ipv6_static_sysctl_unregister (void ) -{ -unregister_net_sysctl_table (ip6_base); -}
Signature · 1 line
1.7.5.rc0
PATCH 20/24 sysctl: ipv6: register /proc/sys/net/ipv6/conf empty directory
In reply to Lucian Adrian GrijincuThis does not change any semantics: it just adds a new header that will be used in the next patch as a parent for all headers for all /proc/sys/net/ipv6/conf/DEVNAME entries.
For now, all interface headers for /proc/sys/net/ipv6/conf/DEVNAME will be bound to this header as opposed to another one from above, but this shouldn't affect performance or behaviour.
--- include/net/netns/ipv6.h | 3 ++- net/ipv6/addrconf.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-)
include/net/netns/ipv6.h +2 -1
@@ -13,7 +13,8 @@ struct ctl_table_header;struct netns_sysctl_ipv6 {#ifdef CONFIG_SYSCTL struct ctl_table_header *table; -struct ctl_table_header *frags_hdr; +struct ctl_table_header *frags_hdr;/* /proc/sys/net/ipv6/ip6frag_* */ +struct ctl_table_header *conf_hdr;/* /proc/sys/net/ipv6/conf/ */ #endif int bindv6only;int flush_delay;
net/ipv6/addrconf.c +28 -1
@@ -4556,8 +4556,25 @@ static void addrconf_sysctl_unregister(struct inet6_dev *idev) neigh_sysctl_unregister(idev->nd_parms); } +/* empty entry for '/proc/sys/net/ipv6/conf/' */ +static __net_initdata struct ctl_table empty[1 ]; +static __net_initdata struct ctl_table ipv6_conf_skel[] = { + { + .procname ="conf" , + .mode =0555 , + .child = empty, + }, + { }, +}; + +static __net_initdata const struct ctl_path net_ipv6_path[] = { + { .procname ="net" , }, + { .procname ="ipv6" , }, + { }, +}; + +#endif /* CONFIG_SYSCTL */ -#endif static int __net_init addrconf_init_net (struct net *net) {
@@ -4586,6 +4603,12 @@ static int __net_init addrconf_init_net(struct net *net) net->ipv6.devconf_dflt = dflt;#ifdef CONFIG_SYSCTL + err = -ENOMEM ; + net->ipv6.sysctl.conf_hdr =register_net_sysctl_table (net, + net_ipv6_path, ipv6_conf_skel); +if (net->ipv6.sysctl.conf_hdr ==NULL ) + goto err_reg_conf; + err =__addrconf_sysctl_register (net,"all" ,NULL , all);if (err <0 ) goto err_reg_all;
@@ -4593,6 +4616,7 @@ static int __net_init addrconf_init_net(struct net *net) err =__addrconf_sysctl_register (net,"default" ,NULL , dflt);if (err <0 ) goto err_reg_dflt; +#endif return 0 ;
@@ -4600,6 +4624,8 @@ static int __net_init addrconf_init_net(struct net *net) err_reg_dflt:__addrconf_sysctl_unregister (all); err_reg_all: +unregister_net_sysctl_table (net->ipv6.sysctl.conf_hdr); +err_reg_conf:kfree (dflt);#endif err_alloc_dflt:
@@ -4613,6 +4639,7 @@ static void __net_exit addrconf_exit_net(struct net *net)#ifdef CONFIG_SYSCTL __addrconf_sysctl_unregister (net->ipv6.devconf_dflt);__addrconf_sysctl_unregister (net->ipv6.devconf_all); +unregister_net_sysctl_table (net->ipv6.sysctl.conf_hdr);#endif if (!net_eq (net, &init_net)) {kfree (net->ipv6.devconf_dflt);
Signature · 1 line
1.7.5.rc0
PATCH 18/24 sysctl: ipv4: register /proc/sys/net/ipv4/conf empty directory
In reply to Lucian Adrian GrijincuThis does not change any semantics: it just adds a new header that will be used in the next patch as a parent for all headers for all /proc/sys/net/ipv4/conf/DEVNAME entries.
For now, all interface headers for /proc/sys/net/ipv4/conf/DEVNAME will be bound to this header as opposed to another one from above, but this shouldn't affect performance or behaviour.
--- include/net/netns/ipv4.h | 9 +++++---- net/ipv4/devinet.c | 25 +++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 6 deletions(-)
include/net/netns/ipv4.h +5 -4
@@ -15,10 +15,11 @@ struct sock;struct netns_ipv4 {#ifdef CONFIG_SYSCTL -struct ctl_table_header *forw_hdr; -struct ctl_table_header *frags_hdr; -struct ctl_table_header *ipv4_hdr; -struct ctl_table_header *route_hdr; +struct ctl_table_header *forw_hdr;/* /proc/sys/net/ipv4/ip_forward */ +struct ctl_table_header *conf_hdr;/* /proc/sys/net/ipv4/conf/ */ +struct ctl_table_header *frags_hdr;/* /proc/sys/net/ipv4/ipfrag_* */ +struct ctl_table_header *ipv4_hdr;/* see @ipv4_net_table */ +struct ctl_table_header *route_hdr;/* /proc/sys/net/ipv4/route/flush */ #endif struct ipv4_devconf *devconf_all;struct ipv4_devconf *devconf_dflt;
net/ipv4/devinet.c +23 -2
@@ -1698,6 +1698,18 @@ static void devinet_sysctl_unregister(struct in_device *idev)neigh_sysctl_unregister (idev->arp_parms); } + +/* empty entry for '/proc/sys/net/ipv4/conf/' */ +static __net_initdata struct ctl_table empty[1 ]; +static __net_initdata struct ctl_table ipv4_conf_skel[] = { + { + .procname ="conf" , + .mode =0555 , + .child = empty, + }, + { }, +}; +static struct ctl_table ctl_forward_entry[] = { { .procname ="ip_forward" ,
@@ -1712,7 +1724,7 @@ static struct ctl_table ctl_forward_entry[] = { { }, }; -static __net_initdata struct ctl_path net_ipv4_path[] = { +static __net_initdata const struct ctl_path net_ipv4_path[] = { { .procname ="net" , }, { .procname ="ipv4" , }, { },
@@ -1725,7 +1737,7 @@ static __net_init int devinet_init_net(struct net *net)struct ipv4_devconf *all, *dflt;#ifdef CONFIG_SYSCTL struct ctl_table *tbl = ctl_forward_entry; -struct ctl_table_header *forw_hdr; +struct ctl_table_header *forw_hdr, *conf_hdr;#endif err = -ENOMEM ;
@@ -1753,6 +1765,12 @@ static __net_init int devinet_init_net(struct net *net) }#ifdef CONFIG_SYSCTL + err = -ENOMEM ; + conf_hdr =register_net_sysctl_table (net, net_ipv4_path, ipv4_conf_skel); +if (conf_hdr ==NULL ) + goto err_reg_conf; + net->ipv4.conf_hdr = conf_hdr; + err =__devinet_sysctl_register (net,"all" , all);if (err <0 ) goto err_reg_all;
@@ -1778,6 +1796,8 @@ err_reg_ctl: err_reg_dflt:__devinet_sysctl_unregister (all); err_reg_all: +unregister_net_sysctl_table (conf_hdr); +err_reg_conf:if (tbl != ctl_forward_entry)kfree (tbl); err_alloc_ctl:
@@ -1800,6 +1820,7 @@ static __net_exit void devinet_exit_net(struct net *net)unregister_net_sysctl_table (net->ipv4.forw_hdr);__devinet_sysctl_unregister (net->ipv4.devconf_dflt);__devinet_sysctl_unregister (net->ipv4.devconf_all); +unregister_net_sysctl_table (net->ipv4.conf_hdr);kfree (tbl);#endif kfree (net->ipv4.devconf_dflt);
Signature · 1 line
1.7.5.rc0
PATCH 14/24 sysctl: cookie: share unix_table between nets
In reply to Lucian Adrian Grijincu--- net/unix/sysctl_net_unix.c | 22 +++------------------- 1 files changed, 3 insertions(+), 19 deletions(-)
net/unix/sysctl_net_unix.c +3 -19
@@ -21,7 +21,7 @@ static ctl_table unix_table[] = { .data = &init_net.unx.sysctl_max_dgram_qlen, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec, }, { } };
@@ -34,30 +34,14 @@ static struct ctl_path unix_path[] = {int __net_init unix_sysctl_register (struct net *net) { -struct ctl_table *table; - - table =kmemdup (unix_table,sizeof (unix_table),GFP_KERNEL ); -if (table ==NULL ) - goto err_alloc; - - table[0 ].data = &net->unx.sysctl_max_dgram_qlen; - net->unx.ctl =register_net_sysctl_table (net, unix_path, table); + net->unx.ctl =register_net_sysctl_table (net, unix_path, unix_table);if (net->unx.ctl ==NULL ) - goto err_reg; +return -ENOMEM ;return 0 ; - -err_reg: -kfree (table); -err_alloc: -return -ENOMEM ; }void unix_sysctl_unregister (struct net *net) { -struct ctl_table *table; - - table = net->unx.ctl->ctl_table_arg;unregister_sysctl_table (net->unx.ctl); -kfree (table); }
Signature · 1 line
1.7.5.rc0
PATCH 12/24 sysctl: cookie: share event_sysctl_table between nets
In reply to Lucian Adrian Grijincu--- net/netfilter/nf_conntrack_ecache.c | 30 +++++------------------------- 1 files changed, 5 insertions(+), 25 deletions(-)
net/netfilter/nf_conntrack_ecache.c +5 -25
@@ -163,14 +163,14 @@ static struct ctl_table event_sysctl_table[] = { .data = &init_net.ct.sysctl_events, .maxlen = sizeof(unsigned int), .mode = 0644, - .proc_handler = proc_dointvec, + .proc_handler = netns_proc_dointvec, }, { .procname = "nf_conntrack_events_retry_timeout", .data = &init_net.ct.sysctl_events_retry_timeout, .maxlen = sizeof(unsigned int), .mode = 0644, - .proc_handler = proc_dointvec_jiffies, + .proc_handler = netns_proc_dointvec_jiffies, }, {} };
@@ -185,38 +185,18 @@ static struct nf_ct_ext_type event_extend __read_mostly = {#ifdef CONFIG_SYSCTL static int nf_conntrack_event_init_sysctl (struct net *net) { -struct ctl_table *table; - - table =kmemdup (event_sysctl_table,sizeof (event_sysctl_table), -GFP_KERNEL ); -if (!table) - goto out; - - table[0 ].data = &net->ct.sysctl_events; - table[1 ].data = &net->ct.sysctl_events_retry_timeout; - - net->ct.event_sysctl_header = -register_net_sysctl_table (net, - nf_net_netfilter_sysctl_path, table); + net->ct.event_sysctl_header =register_net_sysctl_table (net, + nf_net_netfilter_sysctl_path, event_sysctl_table);if (!net->ct.event_sysctl_header) {printk (KERN_ERR "nf_ct_event: can't register to sysctl.\n" ); - goto out_register; +return -ENOMEM ; }return 0 ; - -out_register: -kfree (table); -out: -return -ENOMEM ; }static void nf_conntrack_event_fini_sysctl (struct net *net) { -struct ctl_table *table; - - table = net->ct.event_sysctl_header->ctl_table_arg;unregister_net_sysctl_table (net->ct.event_sysctl_header); -kfree (table); }#else static int nf_conntrack_event_init_sysctl (struct net *net)
Signature · 1 line
1.7.5.rc0
PATCH 9/24 sysctl: cookie: share ip6_frags_ns_ctl_table between nets
In reply to Lucian Adrian Grijincu--- net/ipv6/reassembly.c | 34 ++++++---------------------------- 1 files changed, 6 insertions(+), 28 deletions(-)
net/ipv6/reassembly.c +6 -28
@@ -600,21 +600,21 @@ static struct ctl_table ip6_frags_ns_ctl_table[] = { .data = &init_net.ipv6.frags.high_thresh, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec, }, { .procname = "ip6frag_low_thresh", .data = &init_net.ipv6.frags.low_thresh, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec + .proc_handler = netns_proc_dointvec, }, { .procname = "ip6frag_time", .data = &init_net.ipv6.frags.timeout, .maxlen = sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec_jiffies, + .proc_handler = netns_proc_dointvec_jiffies, }, { } };
@@ -632,42 +632,20 @@ static struct ctl_table ip6_frags_ctl_table[] = {static int __net_init ip6_frags_ns_sysctl_register (struct net *net) { -struct ctl_table *table;struct ctl_table_header *hdr; - table = ip6_frags_ns_ctl_table; -if (!net_eq (net, &init_net)) { - table =kmemdup (table,sizeof (ip6_frags_ns_ctl_table),GFP_KERNEL ); -if (table ==NULL ) - goto err_alloc; - - table[0 ].data = &net->ipv6.frags.high_thresh; - table[1 ].data = &net->ipv6.frags.low_thresh; - table[2 ].data = &net->ipv6.frags.timeout; - } - - hdr =register_net_sysctl_table (net, net_ipv6_ctl_path, table); + hdr =register_net_sysctl_table (net, net_ipv6_ctl_path, + ip6_frags_ns_ctl_table);if (hdr ==NULL ) - goto err_reg; +return -ENOMEM ; net->ipv6.sysctl.frags_hdr = hdr;return 0 ; - -err_reg: -if (!net_eq (net, &init_net)) -kfree (table); -err_alloc: -return -ENOMEM ; } static void __net_exit ip6_frags_ns_sysctl_unregister(struct net *net) { -struct ctl_table *table; - - table = net->ipv6.sysctl.frags_hdr->ctl_table_arg;unregister_net_sysctl_table (net->ipv6.sysctl.frags_hdr); -if (!net_eq (net, &init_net)) -kfree (table); }static struct ctl_table_header *ip6_ctl_header;
Signature · 1 line
1.7.5.rc0
PATCH 7/24 sysctl: cookie: share ipv4_route_flush_table between nets
In reply to Lucian Adrian Grijincu--- net/ipv4/route.c | 30 ++++-------------------------- 1 files changed, 4 insertions(+), 26 deletions(-)
net/ipv4/route.c +4 -26
@@ -3015,13 +3015,12 @@ static int ipv4_sysctl_rtcache_flush(ctl_table *__ctl, int write,if (write) {int flush_delay;ctl_table ctl; -struct net *net; +struct net *net = (struct net *) cookie;memcpy (&ctl, __ctl,sizeof (ctl)); ctl.data = &flush_delay;proc_dointvec (&ctl, write, buffer, lenp, ppos,NULL ); - net = (struct net *)__ctl->extra1;rt_cache_flush (net, flush_delay);return 0 ; }
@@ -3176,37 +3175,16 @@ static __net_initdata struct ctl_path ipv4_route_path[] = {static __net_init int sysctl_route_net_init (struct net *net) { -struct ctl_table *tbl; - - tbl = ipv4_route_flush_table; -if (!net_eq (net, &init_net)) { - tbl =kmemdup (tbl,sizeof (ipv4_route_flush_table),GFP_KERNEL ); -if (tbl ==NULL ) - goto err_dup; - } - tbl[0 ].extra1 = net; - - net->ipv4.route_hdr = -register_net_sysctl_table (net, ipv4_route_path, tbl); + net->ipv4.route_hdr =register_net_sysctl_table (net, + ipv4_route_path, ipv4_route_flush_table);if (net->ipv4.route_hdr ==NULL ) - goto err_reg; +return -ENOMEM ;return 0 ; - -err_reg: -if (tbl != ipv4_route_flush_table) -kfree (tbl); -err_dup: -return -ENOMEM ; } static __net_exit void sysctl_route_net_exit(struct net *net) { -struct ctl_table *tbl; - - tbl = net->ipv4.route_hdr->ctl_table_arg;unregister_net_sysctl_table (net->ipv4.route_hdr); -BUG_ON (tbl == ipv4_route_flush_table); -kfree (tbl); }static __net_initdata struct pernet_operations sysctl_route_ops = {
Signature · 1 line
1.7.5.rc0
David Miller
maintainerRe: [PATCH 01/24] sysctl: net: call unregister_net_sysctl_table where needed
In reply to Lucian Adrian GrijincuFrom: Lucian Adrian Grijincu <[email protected]>
Date: Sat, 2 Apr 2011 04:53:15 +0200
Quoted 4 lines
ctl_table_headersregistered withregister_net_sysctl_tableshould have been unregistered with the equivalentunregister_net_sysctl_tableSigned-off-by Lucian Adrian Grijincu <[email protected]>
Oops, hmmm... Can this actually cause any real problems currently?
If so I'd like to toss this specific patch into net-2.6
Thanks.
David Miller
maintainerRe: [PATCH 02/24] sysctl: cookie: add ctl_header_cookie
In reply to Lucian Adrian GrijincuFrom: Lucian Adrian Grijincu <[email protected]>
Date: Sat, 2 Apr 2011 04:53:16 +0200
kernel/sysctl.c static struct ctl_table_header root_table_header = { · line 209
Quoted 6 lines
kernel/sysctl.c +1
-0@@ -205,6 +205,7 @@ static struct ctl_table_header root_table_header = { .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),}}, .root = &sysctl_table_root, .set = &sysctl_table_root.default_set, + .ctl_header_cookie = NULL, };
Such explicit setting of structure members to NULL in an assignment is never necessary. Please remove these, there were a few cases in this patch.
Thanks.
David Miller
maintainerRe: [PATCH 03/24] sysctl: cookie: pass ctl_header_cookie to proc_handler
In reply to Lucian Adrian GrijincuFrom: Lucian Adrian Grijincu <[email protected]>
Date: Sat, 2 Apr 2011 04:53:17 +0200
Quoted 4 lines
The bulk of this patch changes all
proc_handlersin the kernel to receive the cookie.Signed-off-by Lucian Adrian Grijincu <[email protected]>
Since this stuff is pretty invasive outside of the networking I really need to see two things:
1) Feedback from sysctl folks.
2) Some coordination with whoever maintains sysctl stuff so we can decide how to stage these changes in various maintainer trees, including mine.
Re: [PATCH 01/24] sysctl: net: call unregister_net_sysctl_table where needed
In reply to David MillerQuoted 3 lines · David Miller
Oops, hmmm... Can this actually cause any real problems currently?
If so I'd like to toss this specific patch into net-2.6
Nope:
void unregister_net_sysctl_table(struct ctl_table_header *header)
{
unregister_sysctl_table(header);
}EXPORT_SYMBOL_GPL(unregister_net_sysctl_table);
But I thought that in the future, if something special needs to be done for unregister_net_sysctl_table, it would be better to have these consistent. I'll do a check on all the tree to see if there are other cases.
Another approach would be to remove unregister_net_sysctl_table, as it does nothing different of unregister_sysctl_table and let our future selves deal with the problem.
Can you tell me what you'd like?
Signature · 2 lines
. ..: Lucian
David Miller
maintainerRe: [PATCH 01/24] sysctl: net: call unregister_net_sysctl_table where needed
From: Lucian Adrian Grijincu <[email protected]>
Date: Wed, 6 Apr 2011 22:04:53 +0200
Quoted 6 lines · David Miller
Quoted 3 lines
Oops, hmmm... Can this actually cause any real problems currently?
If so I'd like to toss this specific patch into net-2.6
Quoted 7 lines
Nope:
void
unregister_net_sysctl_table(struct ctl_table_header *header){ unregister_sysctl_table(header); }
EXPORT_SYMBOL_GPL(unregister_net_sysctl_table);
Ok, that's good.
Quoted 10 lines
But I thought that in the future, if something special needs to be done for
unregister_net_sysctl_table, it would be better to have these consistent. I'll do a check on all the tree to see if there are other cases.Another approach would be to remove
unregister_net_sysctl_table, as it does nothing different ofunregister_sysctl_tableand let our future selves deal with the problem.Can you tell me what you'd like?
I think the thing to do is to keep this patch as it is, and only apply it along with this cookie patch series, for -next.