Use ctl paths in the networking code.
Subsystems (9)
cover Use ctl paths in the networking code.
This set almost completes the ctl paths usage in the networking code. The first patches doing this were accepted in the last year :), but they tuned only core, ipv4 and ipv6.
I thought, that splitting this into many subsystem would produce too many patches, so I splitted it so, that most subsystems that are patched in a very similar way are merged into one patch to make the review easier. Hope this is OK.
After this set the vmlinux size becomes almost 4Kb less (when all patched files are built-in):
add/remove: 16/40 grow/shrink: 18/6 up/down: 486/-4394 (-3908)
function old new delta
net_vs_ctl_path - 32 +32 dccp_path - 32 +32 x25_path - 24 +24 sctp_path - 24 +24 rose_path - 24 +24 nr_path - 24 +24 net_ipv6_ctl_path - 24 +24 net_ipv4_ctl_path - 24 +24 llc_path - 24 +24 irda_path - 24 +24 ipx_path - 24 +24 dn_path - 24 +24 brnf_path - 24 +24 ax25_path - 24 +24 atalk_path - 24 +24 nf_ct_path - 16 +16 dn_dev_sysctl_register 164 173 +9 x25_register_sysctl 16 21 +5 sctp_sysctl_register 16 21 +5 rose_register_sysctl 16 21 +5 nr_register_sysctl 16 21 +5 nf_conntrack_standalone_init 166 171 +5 llc_sysctl_init 24 29 +5 irda_sysctl_register 24 29 +5 ipx_register_sysctl 16 21 +5 ip_vs_lblcr_init 66 71 +5 ip_vs_control_init 209 214 +5 ip_queue_init 288 293 +5 ip6_queue_init 288 293 +5 dn_register_sysctl 16 21 +5 dccp_sysctl_init 24 29 +5 br_netfilter_init 91 96 +5 atalk_register_sysctl 16 21 +5 ax25_register_sysctl 294 290 -4 ax25_unregister_sysctl 56 46 -10 nf_unregister_sysctl_table 19 - -19 net_ipv4_path 48 24 -24 ipv6_ctl_path 24 - -24 path_free 27 - -27 nf_net_ipv4_netfilter_sysctl_path 88 32 -56 nf_net_netfilter_sysctl_path 88 24 -64 x25_root_table 88 - -88 x25_dir_table 88 - -88 vs_root_table 88 - -88 sctp_root_table 88 - -88 sctp_net_table 88 - -88 rose_root_table 88 - -88 rose_dir_table 88 - -88 nr_root_table 88 - -88 nr_dir_table 88 - -88 nf_net_netfilter_table 88 - -88 nf_net_ipv4_table 88 - -88 nf_net_ipv4_netfilter_table 88 - -88 nf_ct_net_table 88 - -88 llc_root_table 88 - -88 llc_dir_table 88 - -88 lblcr_root_table 88 - -88 lblc_root_table 88 - -88 irda_root_table 88 - -88 irda_net_table 88 - -88 ipx_root_table 88 - -88 ipx_dir_table 88 - -88 dn_root_table 88 - -88 dn_dir_table 88 - -88 dccp_table 88 - -88 dccp_root_table 88 - -88 dccp_dir_table 88 - -88 brnf_net_table 88 - -88 brnf_bridge_table 88 - -88 ax25_root_table 88 - -88 ax25_dir_table 88 - -88 atalk_root_table 88 - -88 atalk_dir_table 88 - -88 nf_register_sysctl_table 118 - -118 ipq_root_table 176 - -176 ipq_dir_table 176 - -176 vs_table 264 - -264 ipvs_ipv4_table 264 - -264 dn_dev_sysctl 576 224 -352
PATCH 1/6 Simple ctl_table to ctl_path conversions.
This patch includes many places, that only required replacing the ctl_table-s with appropriate ctl_paths and call register_sysctl_paths().
Nothing special was done with them.
---
net/appletalk/sysctl_net_atalk.c | 24 +++++------------------- net/bridge/br_netfilter.c | 24 +++++------------------- net/dccp/sysctl.c | 36 +++++++----------------------------- net/ipx/sysctl_net_ipx.c | 24 +++++------------------- net/irda/irsysctl.c | 28 +++++----------------------- net/llc/sysctl_net_llc.c | 24 +++++------------------- net/netrom/sysctl_net_netrom.c | 24 +++++------------------- net/rose/sysctl_net_rose.c | 24 +++++------------------- net/sctp/sysctl.c | 24 +++++------------------- net/x25/sysctl_net_x25.c | 24 +++++------------------- 10 files changed, 52 insertions(+), 204 deletions(-)
net/appletalk/sysctl_net_atalk.c +5 -19
@@ -49,31 +49,17 @@ static struct ctl_table atalk_table[] = { { 0 }, }; -static struct ctl_table atalk_dir_table[] = { - { - .ctl_name =NET_ATALK , - .procname ="appletalk" , - .mode =0555 , - .child = atalk_table, - }, - {0 }, -}; - -static struct ctl_table atalk_root_table[] = { - { - .ctl_name =CTL_NET , - .procname ="net" , - .mode =0555 , - .child = atalk_dir_table, - }, - {0 }, +static struct ctl_path atalk_path[] = { + { .procname ="net" , .ctl_name =CTL_NET , }, + { .procname ="appletalk" , .ctl_name =NET_ATALK , }, + { } };static struct ctl_table_header *atalk_table_header;void atalk_register_sysctl (void ) { - atalk_table_header =register_sysctl_table (atalk_root_table); + atalk_table_header =register_sysctl_paths (atalk_path, atalk_table); }void atalk_unregister_sysctl (void )
net/bridge/br_netfilter.c +5 -19
@@ -934,24 +934,10 @@ static ctl_table brnf_table[] = { { .ctl_name = 0 } }; -static ctl_table brnf_bridge_table[] = { - { - .ctl_name =NET_BRIDGE , - .procname ="bridge" , - .mode =0555 , - .child = brnf_table, - }, - { .ctl_name =0 } -}; - -static ctl_table brnf_net_table[] = { - { - .ctl_name =CTL_NET , - .procname ="net" , - .mode =0555 , - .child = brnf_bridge_table, - }, - { .ctl_name =0 } +static struct ctl_path brnf_path[] = { + { .procname ="net" , .ctl_name =CTL_NET , }, + { .procname ="bridge" , .ctl_name =NET_BRIDGE , }, + { } };#endif
@@ -963,7 +949,7 @@ int __init br_netfilter_init(void)if (ret <0 )return ret;#ifdef CONFIG_SYSCTL - brnf_sysctl_header =register_sysctl_table (brnf_net_table); + brnf_sysctl_header =register_sysctl_paths (brnf_path, brnf_table);if (brnf_sysctl_header ==NULL ) {printk (KERN_WARNING "br_netfilter: can't register to sysctl.\n" );
net/dccp/sysctl.c +7 -29
@@ -100,41 +100,19 @@ static struct ctl_table dccp_default_table[] = { { .ctl_name = 0, } }; -static struct ctl_table dccp_table[] = { - { - .ctl_name =NET_DCCP_DEFAULT , - .procname ="default" , - .mode =0555 , - .child = dccp_default_table, - }, - { .ctl_name =0 , }, -}; - -static struct ctl_table dccp_dir_table[] = { - { - .ctl_name =NET_DCCP , - .procname ="dccp" , - .mode =0555 , - .child = dccp_table, - }, - { .ctl_name =0 , }, -}; - -static struct ctl_table dccp_root_table[] = { - { - .ctl_name =CTL_NET , - .procname ="net" , - .mode =0555 , - .child = dccp_dir_table, - }, - { .ctl_name =0 , }, +static struct ctl_path dccp_path[] = { + { .procname ="net" , .ctl_name =CTL_NET , }, + { .procname ="dccp" , .ctl_name =NET_DCCP , }, + { .procname ="default" , .ctl_name =NET_DCCP_DEFAULT , }, + { } };static struct ctl_table_header *dccp_table_header;int __init dccp_sysctl_init (void ) { - dccp_table_header =register_sysctl_table (dccp_root_table); + dccp_table_header =register_sysctl_paths (dccp_path, + dccp_default_table);return dccp_table_header !=NULL ?0 : -ENOMEM ; }
net/ipx/sysctl_net_ipx.c +5 -19
@@ -28,31 +28,17 @@ static struct ctl_table ipx_table[] = { { 0 }, }; -static struct ctl_table ipx_dir_table[] = { - { - .ctl_name =NET_IPX , - .procname ="ipx" , - .mode =0555 , - .child = ipx_table, - }, - {0 }, -}; - -static struct ctl_table ipx_root_table[] = { - { - .ctl_name =CTL_NET , - .procname ="net" , - .mode =0555 , - .child = ipx_dir_table, - }, - {0 }, +static struct ctl_path ipx_path[] = { + { .procname ="net" , .ctl_name =CTL_NET , }, + { .procname ="ipx" , .ctl_name =NET_IPX , }, + { } };static struct ctl_table_header *ipx_table_header;void ipx_register_sysctl (void ) { - ipx_table_header =register_sysctl_table (ipx_root_table); + ipx_table_header =register_sysctl_paths (ipx_path, ipx_table); }void ipx_unregister_sysctl (void )
net/irda/irsysctl.c +5 -23
@@ -234,28 +234,10 @@ static ctl_table irda_table[] = { { .ctl_name = 0 } }; -/* One directory */ -static ctl_table irda_net_table[] = { - { - .ctl_name =NET_IRDA , - .procname ="irda" , - .maxlen =0 , - .mode =0555 , - .child = irda_table - }, - { .ctl_name =0 } -}; - -/* The parent directory */ -static ctl_table irda_root_table[] = { - { - .ctl_name =CTL_NET , - .procname ="net" , - .maxlen =0 , - .mode =0555 , - .child = irda_net_table - }, - { .ctl_name =0 } +static struct ctl_path irda_path[] = { + { .procname ="net" , .ctl_name =CTL_NET , }, + { .procname ="irda" , .ctl_name =NET_IRDA , }, + { } };static struct ctl_table_header *irda_table_header;
@@ -268,7 +250,7 @@ static struct ctl_table_header *irda_table_header;*/ int __init irda_sysctl_register (void ) { - irda_table_header =register_sysctl_table (irda_root_table); + irda_table_header =register_sysctl_paths (irda_path, irda_table);if (!irda_table_header)return -ENOMEM ;
net/llc/sysctl_net_llc.c +5 -19
@@ -92,31 +92,17 @@ static struct ctl_table llc_table[] = { { 0 }, }; -static struct ctl_table llc_dir_table[] = { - { - .ctl_name =NET_LLC , - .procname ="llc" , - .mode =0555 , - .child = llc_table, - }, - {0 }, -}; - -static struct ctl_table llc_root_table[] = { - { - .ctl_name =CTL_NET , - .procname ="net" , - .mode =0555 , - .child = llc_dir_table, - }, - {0 }, +static struct ctl_path llc_path[] = { + { .procname ="net" , .ctl_name =CTL_NET , }, + { .procname ="llc" , .ctl_name =NET_LLC , }, + { } };static struct ctl_table_header *llc_table_header;int __init llc_sysctl_init (void ) { - llc_table_header =register_sysctl_table (llc_root_table); + llc_table_header =register_sysctl_paths (llc_path, llc_table);return llc_table_header ?0 : -ENOMEM ; }
net/netrom/sysctl_net_netrom.c +5 -19
@@ -170,29 +170,15 @@ static ctl_table nr_table[] = { { .ctl_name = 0 } }; -static ctl_table nr_dir_table[] = { - { - .ctl_name =NET_NETROM , - .procname ="netrom" , - .mode =0555 , - .child = nr_table - }, - { .ctl_name =0 } -}; - -static ctl_table nr_root_table[] = { - { - .ctl_name =CTL_NET , - .procname ="net" , - .mode =0555 , - .child = nr_dir_table - }, - { .ctl_name =0 } +static struct ctl_path nr_path[] = { + { .procname ="net" , .ctl_name =CTL_NET , }, + { .procname ="netrom" , .ctl_name =NET_NETROM , }, + { } };void __init nr_register_sysctl (void ) { - nr_table_header =register_sysctl_table (nr_root_table); + nr_table_header =register_sysctl_paths (nr_path, nr_table); }void nr_unregister_sysctl (void )
net/rose/sysctl_net_rose.c +5 -19
@@ -138,29 +138,15 @@ static ctl_table rose_table[] = { { .ctl_name = 0 } }; -static ctl_table rose_dir_table[] = { - { - .ctl_name =NET_ROSE , - .procname ="rose" , - .mode =0555 , - .child = rose_table - }, - { .ctl_name =0 } -}; - -static ctl_table rose_root_table[] = { - { - .ctl_name =CTL_NET , - .procname ="net" , - .mode =0555 , - .child = rose_dir_table - }, - { .ctl_name =0 } +static struct ctl_path rose_path[] = { + { .procname ="net" , .ctl_name =CTL_NET , }, + { .procname ="rose" , .ctl_name =NET_ROSE , }, + { } };void __init rose_register_sysctl (void ) { - rose_table_header =register_sysctl_table (rose_root_table); + rose_table_header =register_sysctl_paths (rose_path, rose_table); }void rose_unregister_sysctl (void )
net/sctp/sysctl.c +5 -19
@@ -275,24 +275,10 @@ static ctl_table sctp_table[] = { { .ctl_name = 0 } }; -static ctl_table sctp_net_table[] = { - { - .ctl_name =NET_SCTP , - .procname ="sctp" , - .mode =0555 , - .child = sctp_table - }, - { .ctl_name =0 } -}; - -static ctl_table sctp_root_table[] = { - { - .ctl_name =CTL_NET , - .procname ="net" , - .mode =0555 , - .child = sctp_net_table - }, - { .ctl_name =0 } +static struct ctl_path sctp_path[] = { + { .procname ="net" , .ctl_name =CTL_NET , }, + { .procname ="sctp" , .ctl_name =NET_SCTP , }, + { } };static struct ctl_table_header * sctp_sysctl_header;
@@ -300,7 +286,7 @@ static struct ctl_table_header * sctp_sysctl_header;/* Sysctl registration. */ void sctp_sysctl_register (void ) { - sctp_sysctl_header =register_sysctl_table (sctp_root_table); + sctp_sysctl_header =register_sysctl_paths (sctp_path, sctp_table); }/* Sysctl deregistration. */
net/x25/sysctl_net_x25.c +5 -19
@@ -84,29 +84,15 @@ static struct ctl_table x25_table[] = { { 0, }, }; -static struct ctl_table x25_dir_table[] = { - { - .ctl_name =NET_X25 , - .procname ="x25" , - .mode =0555 , - .child = x25_table, - }, - {0 , }, -}; - -static struct ctl_table x25_root_table[] = { - { - .ctl_name =CTL_NET , - .procname ="net" , - .mode =0555 , - .child = x25_dir_table, - }, - {0 , }, +static struct ctl_path x25_path[] = { + { .procname ="net" , .ctl_name =CTL_NET , }, + { .procname ="x25" , .ctl_name =NET_X25 , }, + { } };void __init x25_register_sysctl (void ) { - x25_table_header =register_sysctl_table (x25_root_table); + x25_table_header =register_sysctl_paths (x25_path, x25_table); }void x25_unregister_sysctl (void )
Re: [PATCH net-2.6.25 1/6][NET] Simple ctl_table to ctl_path conversions.
From: Pavel Emelyanov <[email protected]>
Date: Tue, 08 Jan 2008 18:54:57 +0300
Quoted 7 lines
This patch includes many places, that only required replacing the ctl_table-s with appropriate
ctl_pathsand callregister_sysctl_paths().Nothing special was done with them.
Signed-off-by Pavel Emelyanov <[email protected]>
Applied.
PATCH 2/6 Switch to using ctl_paths.
In reply to Pavel EmelyanovThe feature of ipvs ctls is that the net/ipv4/vs path is common for core ipvs ctls and for two schedulers, so I make it exported and re-use it in modules.
Two other .c files required linux/sysctl.h to make the extern declaration of this path compile well.
---
include/net/ip_vs.h | 1 + net/ipv4/ipvs/ip_vs_ctl.c | 35 +++++++---------------------------- net/ipv4/ipvs/ip_vs_est.c | 1 + net/ipv4/ipvs/ip_vs_lblc.c | 31 +------------------------------ net/ipv4/ipvs/ip_vs_lblcr.c | 31 +------------------------------ net/ipv4/ipvs/ip_vs_sched.c | 1 + 6 files changed, 12 insertions(+), 88 deletions(-)
include/net/ip_vs.h +1 -0
@@ -854,6 +854,7 @@ extern int sysctl_ip_vs_expire_quiescent_template;extern int sysctl_ip_vs_sync_threshold[2 ];extern int sysctl_ip_vs_nat_icmp_send;extern struct ip_vs_stats ip_vs_stats; +extern struct ctl_path net_vs_ctl_path[];extern struct ip_vs_service *ip_vs_service_get (__u32 fwmark,__u16 protocol,__be32 vaddr,__be16 vport);
net/ipv4/ipvs/ip_vs_ctl.c +7 -28
@@ -1591,34 +1591,13 @@ static struct ctl_table vs_vars[] = { { .ctl_name = 0 } }; -static ctl_table vs_table[] = { - { - .procname ="vs" , - .mode =0555 , - .child = vs_vars - }, - { .ctl_name =0 } -}; - -static ctl_table ipvs_ipv4_table[] = { - { - .ctl_name =NET_IPV4 , - .procname ="ipv4" , - .mode =0555 , - .child = vs_table, - }, - { .ctl_name =0 } -}; - -static ctl_table vs_root_table[] = { - { - .ctl_name =CTL_NET , - .procname ="net" , - .mode =0555 , - .child = ipvs_ipv4_table, - }, - { .ctl_name =0 } +struct ctl_path net_vs_ctl_path[] = { + { .procname ="net" , .ctl_name =CTL_NET , }, + { .procname ="ipv4" , .ctl_name =NET_IPV4 , }, + { .procname ="vs" , }, + { } }; +EXPORT_SYMBOL_GPL (net_vs_ctl_path);static struct ctl_table_header * sysctl_header;
@@ -2345,7 +2324,7 @@ int ip_vs_control_init(void)proc_net_fops_create (&init_net,"ip_vs" ,0 , &ip_vs_info_fops);proc_net_fops_create (&init_net,"ip_vs_stats" ,0 , &ip_vs_stats_fops); - sysctl_header =register_sysctl_table (vs_root_table); + sysctl_header =register_sysctl_paths (net_vs_ctl_path, vs_vars);/* Initialize ip_vs_svc_table, ip_vs_svc_fwm_table, ip_vs_rtable */ for (idx =0 ; idx <IP_VS_SVC_TAB_SIZE ; idx++) {
net/ipv4/ipvs/ip_vs_est.c +1 -0
@@ -18,6 +18,7 @@#include <linux/slab.h> #include <linux/types.h> #include <linux/interrupt.h> +#include <linux/sysctl.h> #include <net/ip_vs.h>
net/ipv4/ipvs/ip_vs_lblc.c +1 -30
@@ -123,35 +123,6 @@ static ctl_table vs_vars_table[] = { { .ctl_name = 0 } }; -static ctl_table vs_table[] = { - { - .procname ="vs" , - .mode =0555 , - .child = vs_vars_table - }, - { .ctl_name =0 } -}; - -static ctl_table ipvs_ipv4_table[] = { - { - .ctl_name =NET_IPV4 , - .procname ="ipv4" , - .mode =0555 , - .child = vs_table - }, - { .ctl_name =0 } -}; - -static ctl_table lblc_root_table[] = { - { - .ctl_name =CTL_NET , - .procname ="net" , - .mode =0555 , - .child = ipvs_ipv4_table - }, - { .ctl_name =0 } -}; -static struct ctl_table_header * sysctl_header;/*
@@ -582,7 +553,7 @@ static int __init ip_vs_lblc_init(void)int ret;INIT_LIST_HEAD (&ip_vs_lblc_scheduler.n_list); - sysctl_header =register_sysctl_table (lblc_root_table); + sysctl_header =register_sysctl_paths (net_vs_ctl_path, vs_vars_table); ret =register_ip_vs_scheduler (&ip_vs_lblc_scheduler);if (ret)unregister_sysctl_table (sysctl_header);
net/ipv4/ipvs/ip_vs_lblcr.c +1 -30
@@ -311,35 +311,6 @@ static ctl_table vs_vars_table[] = { { .ctl_name = 0 } }; -static ctl_table vs_table[] = { - { - .procname ="vs" , - .mode =0555 , - .child = vs_vars_table - }, - { .ctl_name =0 } -}; - -static ctl_table ipvs_ipv4_table[] = { - { - .ctl_name =NET_IPV4 , - .procname ="ipv4" , - .mode =0555 , - .child = vs_table - }, - { .ctl_name =0 } -}; - -static ctl_table lblcr_root_table[] = { - { - .ctl_name =CTL_NET , - .procname ="net" , - .mode =0555 , - .child = ipvs_ipv4_table - }, - { .ctl_name =0 } -}; -static struct ctl_table_header * sysctl_header;/*
@@ -771,7 +742,7 @@ static int __init ip_vs_lblcr_init(void)int ret;INIT_LIST_HEAD (&ip_vs_lblcr_scheduler.n_list); - sysctl_header =register_sysctl_table (lblcr_root_table); + sysctl_header =register_sysctl_paths (net_vs_ctl_path, vs_vars_table); ret =register_ip_vs_scheduler (&ip_vs_lblcr_scheduler);if (ret)unregister_sysctl_table (sysctl_header);
net/ipv4/ipvs/ip_vs_sched.c +1 -0
@@ -24,6 +24,7 @@#include <linux/interrupt.h> #include <asm/string.h> #include <linux/kmod.h> +#include <linux/sysctl.h> #include <net/ip_vs.h>
Re: [PATCH net-2.6.25 2/6][IPVS] Switch to using ctl_paths.
Quoted 8 lines · Pavel Emelyanov
The feature of ipvs ctls is that the
net/ipv4/vspath is common for core ipvs ctls and for two schedulers, so I make it exported and re-use it in modules.Two other .c files required
linux/sysctl.hto make the extern declaration of this path compile well.Signed-off-by Pavel Emelyanov <[email protected]>
Thanks, this looks good to me and I've confirmed that the same entires with the same permissions exist under /proc/sys/net/ipv4/vs before and after the change.
Signature · 1 line
Horms
Re: [PATCH net-2.6.25 2/6][IPVS] Switch to using ctl_paths.
From: Simon Horman <[email protected]>
Date: Wed, 9 Jan 2008 11:49:16 +0900
Quoted 8 lines · Pavel Emelyanov
Quoted 7 lines
The feature of ipvs ctls is that the
net/ipv4/vspath is common for core ipvs ctls and for two schedulers, so I make it exported and re-use it in modules.Two other .c files required
linux/sysctl.hto make the extern declaration of this path compile well.
Quoted 7 lines
Quoted 1 line
Signed-off-by Pavel Emelyanov <[email protected]>Thanks, this looks good to me and I've confirmed that the same entires with the same permissions exist under
/proc/sys/net/ipv4/vsbefore and after the change.Acked-by Simon Horman <[email protected]>
Applied, thanks everyone.
PATCH 3/6 Switch to using ctl_paths.
In reply to Pavel EmelyanovThe decnet includes two places to patch. The first one is the net/decnet table itself, and it is patched just like other subsystems in the first patch in this series.
The second place is a bit more complex - it is the net/decnet/conf/xxx entries,. similar to those in ipv4/devinet.c and ipv6/addrconf.c. This code is made similar to those in ipv[46].
---
net/decnet/dn_dev.c | 52 +++++++++++------------------------------ net/decnet/sysctl_net_decnet.c | 23 +++--------------- 2 files changed, 20 insertions(+), 55 deletions(-)
net/decnet/dn_dev.c +15 -37
@@ -173,10 +173,6 @@ static int dn_forwarding_sysctl(ctl_table *table, int __user *name, int nlen,static struct dn_dev_sysctl_table {struct ctl_table_header *sysctl_header;ctl_table dn_dev_vars[5 ]; -ctl_table dn_dev_dev[2 ]; -ctl_table dn_dev_conf_dir[2 ]; -ctl_table dn_dev_proto_dir[2 ]; -ctl_table dn_dev_root_dir[2 ]; } dn_dev_sysctl = {NULL , {
@@ -224,30 +220,6 @@ static struct dn_dev_sysctl_table { }, {0} }, - {{ - .ctl_name = 0, - .procname = "", - .mode = 0555, - .child = dn_dev_sysctl.dn_dev_vars - }, {0}}, - {{ - .ctl_name = NET_DECNET_CONF, - .procname = "conf", - .mode = 0555, - .child = dn_dev_sysctl.dn_dev_dev - }, {0}}, - {{ - .ctl_name = NET_DECNET, - .procname = "decnet", - .mode = 0555, - .child = dn_dev_sysctl.dn_dev_conf_dir - }, {0}}, - {{ - .ctl_name = CTL_NET, - .procname = "net", - .mode = 0555, - .child = dn_dev_sysctl.dn_dev_proto_dir - }, {0}} };static void dn_dev_sysctl_register (struct net_device *dev,struct dn_dev_parms *parms)
@@ -255,6 +227,16 @@ static void dn_dev_sysctl_register(struct net_device *dev, struct dn_dev_parms *struct dn_dev_sysctl_table *t;int i; +#define DN_CTL_PATH_DEV 3 + +struct ctl_path dn_ctl_path[] = { + { .procname ="net" , .ctl_name =CTL_NET , }, + { .procname ="decnet" , .ctl_name =NET_DECNET , }, + { .procname ="conf" , .ctl_name =NET_DECNET_CONF , }, + {/* to be set */ }, + { }, + }; + t =kmemdup (&dn_dev_sysctl,sizeof (*t),GFP_KERNEL );if (t ==NULL )return ;
@@ -265,20 +247,16 @@ static void dn_dev_sysctl_register(struct net_device *dev, struct dn_dev_parms * }if (dev) { - t->dn_dev_dev[0 ].procname = dev->name; - t->dn_dev_dev[0 ].ctl_name = dev->ifindex; + dn_ctl_path[DN_CTL_PATH_DEV ].procname = dev->name; + dn_ctl_path[DN_CTL_PATH_DEV ].ctl_name = dev->ifindex; }else { - t->dn_dev_dev[0 ].procname = parms->name; - t->dn_dev_dev[0 ].ctl_name = parms->ctl_name; + dn_ctl_path[DN_CTL_PATH_DEV ].procname = parms->name; + dn_ctl_path[DN_CTL_PATH_DEV ].ctl_name = parms->ctl_name; } - t->dn_dev_dev[0 ].child = t->dn_dev_vars; - t->dn_dev_conf_dir[0 ].child = t->dn_dev_dev; - t->dn_dev_proto_dir[0 ].child = t->dn_dev_conf_dir; - t->dn_dev_root_dir[0 ].child = t->dn_dev_proto_dir; t->dn_dev_vars[0 ].extra1 = (void *)dev; - t->sysctl_header =register_sysctl_table (t->dn_dev_root_dir); + t->sysctl_header =register_sysctl_paths (dn_ctl_path, t->dn_dev_vars);if (t->sysctl_header ==NULL )kfree (t);else
net/decnet/sysctl_net_decnet.c +5 -18
@@ -470,28 +470,15 @@ static ctl_table dn_table[] = { {0} }; -static ctl_table dn_dir_table[] = { - { - .ctl_name =NET_DECNET , - .procname ="decnet" , - .mode =0555 , - .child = dn_table}, - {0 } -}; - -static ctl_table dn_root_table[] = { - { - .ctl_name =CTL_NET , - .procname ="net" , - .mode =0555 , - .child = dn_dir_table - }, - {0 } +static struct ctl_path dn_path[] = { + { .procname ="net" , .ctl_name =CTL_NET , }, + { .procname ="decnet" , .ctl_name =NET_DECNET , }, + { } };void dn_register_sysctl (void ) { - dn_table_header =register_sysctl_table (dn_root_table); + dn_table_header =register_sysctl_paths (dn_path, dn_table); }void dn_unregister_sysctl (void )
Re: [PATCH net-2.6.25 3/6][DECNET] Switch to using ctl_paths.
From: Pavel Emelyanov <[email protected]>
Date: Tue, 08 Jan 2008 19:02:16 +0300
Quoted 10 lines
The decnet includes two places to patch. The first one is the net/decnet table itself, and it is patched just like other subsystems in the first patch in this series.
The second place is a bit more complex - it is the
net/decnet/conf/xxxentries,. similar to those inipv4/devinet.candipv6/addrconf.c. This code is made similar to those in ipv[46].Signed-off-by Pavel Emelyanov <[email protected]>
Applied.
PATCH 4/6 Switch to using ctl_paths.
In reply to Pavel EmelyanovThis one is almost the same as the hunks in the first patch, but ax25 tables are created dynamically.
So this patch differs a bit to handle this case.
---
net/ax25/sysctl_net_ax25.c | 27 +++++---------------------- 1 files changed, 5 insertions(+), 22 deletions(-)
net/ax25/sysctl_net_ax25.c +5 -22
@@ -31,25 +31,11 @@ static struct ctl_table_header *ax25_table_header;static ctl_table *ax25_table;static int ax25_table_size; -static ctl_table ax25_dir_table[] = { - { - .ctl_name =NET_AX25 , - .procname ="ax25" , - .mode =0555 , - }, - { .ctl_name =0 } -}; - -static ctl_table ax25_root_table[] = { - { - .ctl_name =CTL_NET , - .procname ="net" , - .mode =0555 , - .child = ax25_dir_table - }, - { .ctl_name =0 } +static struct ctl_path ax25_path[] = { + { .procname ="net" , .ctl_name =CTL_NET , }, + { .procname ="ax25" , .ctl_name =NET_AX25 , }, + { } }; -static const ctl_table ax25_param_table[] = { { .ctl_name =NET_AX25_IP_DEFAULT_MODE ,
@@ -243,9 +229,7 @@ void ax25_register_sysctl(void) }spin_unlock_bh (&ax25_dev_lock); - ax25_dir_table[0 ].child = ax25_table; - - ax25_table_header =register_sysctl_table (ax25_root_table); + ax25_table_header =register_sysctl_paths (ax25_path, ax25_table); }void ax25_unregister_sysctl (void )
@@ -253,7 +237,6 @@ void ax25_unregister_sysctl(void)ctl_table *p;unregister_sysctl_table (ax25_table_header); - ax25_dir_table[0 ].child =NULL ;for (p = ax25_table; p->ctl_name; p++)kfree (p->child);kfree (ax25_table);
Re: [PATCH net-2.6.25 4/6][AX25] Switch to using ctl_paths.
From: Pavel Emelyanov <[email protected]>
Date: Tue, 08 Jan 2008 19:05:18 +0300
Quoted 6 lines
This one is almost the same as the hunks in the first patch, but ax25 tables are created dynamically.
So this patch differs a bit to handle this case.
Signed-off-by Pavel Emelyanov <[email protected]>
Applied.
PATCH 5/6 Switch to using ctl_paths in nf_queue and conntrack modules
In reply to Pavel EmelyanovThis includes the most simple cases for netfilter.
The first part is tne queue modules for ipv4 and ipv6, on which the net/ipv4/ and net/ipv6/ paths are reused from the appropriate ipv4 and ipv6 code.
The conntrack module is also patched, but this hunk is very small and simple.
---
include/net/ip.h +2 -0
@@ -177,6 +177,8 @@ extern void inet_get_local_port_range(int *low, int *high);extern int sysctl_ip_default_ttl;extern int sysctl_ip_nonlocal_bind; +extern struct ctl_path net_ipv4_ctl_path[]; +/* From ip_fragment.c */ struct inet_frags_ctl ;extern struct inet_frags_ctl ip4_frags_ctl;
include/net/ipv6.h +2 -0
@@ -112,6 +112,8 @@ struct frag_hdr {extern int sysctl_ipv6_bindv6only;extern int sysctl_mld_max_msf; +extern struct ctl_path net_ipv6_ctl_path[]; +#define _DEVINC (statname, modifier, idev, field) \ ({ \ struct inet6_dev *_idev = (idev); \
net/ipv4/netfilter/ip_queue.c +2 -21
@@ -29,6 +29,7 @@#include <net/sock.h> #include <net/route.h> #include <net/netfilter/nf_queue.h> +#include <net/ip.h> #define IPQ_QMAX_DEFAULT 1024#define IPQ_PROC_FS_NAME "ip_queue"
@@ -525,26 +526,6 @@ static ctl_table ipq_table[] = { { .ctl_name = 0 } }; -static ctl_table ipq_dir_table[] = { - { - .ctl_name =NET_IPV4 , - .procname ="ipv4" , - .mode =0555 , - .child = ipq_table - }, - { .ctl_name =0 } -}; - -static ctl_table ipq_root_table[] = { - { - .ctl_name =CTL_NET , - .procname ="net" , - .mode =0555 , - .child = ipq_dir_table - }, - { .ctl_name =0 } -}; -static int ip_queue_show (struct seq_file *m,void *v) {read_lock_bh (&queue_lock);
@@ -610,7 +591,7 @@ static int __init ip_queue_init(void) }register_netdevice_notifier (&ipq_dev_notifier); - ipq_sysctl_header =register_sysctl_table (ipq_root_table); + ipq_sysctl_header =register_sysctl_paths (net_ipv4_ctl_path, ipq_table); status =nf_register_queue_handler (PF_INET , &nfqh);if (status <0 ) {
net/ipv4/sysctl_net_ipv4.c +3 -2
@@ -846,17 +846,18 @@ static struct ctl_table ipv4_table[] = { { .ctl_name = 0 } }; -static __initdata struct ctl_path net_ipv4_path[] = { +struct ctl_path net_ipv4_ctl_path[] = { { .procname ="net" , .ctl_name =CTL_NET , }, { .procname ="ipv4" , .ctl_name =NET_IPV4 , }, { }, }; +EXPORT_SYMBOL_GPL (net_ipv4_ctl_path);static __init int sysctl_ipv4_init (void ) {struct ctl_table_header *hdr; - hdr =register_sysctl_paths (net_ipv4_path, ipv4_table); + hdr =register_sysctl_paths (net_ipv4_ctl_path, ipv4_table);return hdr ==NULL ? -ENOMEM :0 ; }
net/ipv6/netfilter/ip6_queue.c +1 -21
@@ -529,26 +529,6 @@ static ctl_table ipq_table[] = { { .ctl_name = 0 } }; -static ctl_table ipq_dir_table[] = { - { - .ctl_name =NET_IPV6 , - .procname ="ipv6" , - .mode =0555 , - .child = ipq_table - }, - { .ctl_name =0 } -}; - -static ctl_table ipq_root_table[] = { - { - .ctl_name =CTL_NET , - .procname ="net" , - .mode =0555 , - .child = ipq_dir_table - }, - { .ctl_name =0 } -}; -static int ip6_queue_show (struct seq_file *m,void *v) {read_lock_bh (&queue_lock);
@@ -614,7 +594,7 @@ static int __init ip6_queue_init(void) }register_netdevice_notifier (&ipq_dev_notifier); - ipq_sysctl_header =register_sysctl_table (ipq_root_table); + ipq_sysctl_header =register_sysctl_paths (net_ipv6_ctl_path, ipq_table); status =nf_register_queue_handler (PF_INET6 , &nfqh);if (status <0 ) {
net/ipv6/sysctl_net_ipv6.c +4 -2
@@ -82,17 +82,19 @@ static ctl_table ipv6_table[] = { { .ctl_name = 0 } }; -static struct ctl_path ipv6_ctl_path[] = { +struct ctl_path net_ipv6_ctl_path[] = { { .procname ="net" , .ctl_name =CTL_NET , }, { .procname ="ipv6" , .ctl_name =NET_IPV6 , }, { }, }; +EXPORT_SYMBOL_GPL (net_ipv6_ctl_path);static struct ctl_table_header *ipv6_sysctl_header;void ipv6_sysctl_register (void ) { - ipv6_sysctl_header =register_sysctl_paths (ipv6_ctl_path, ipv6_table); + ipv6_sysctl_header =register_sysctl_paths (net_ipv6_ctl_path, + ipv6_table); }void ipv6_sysctl_unregister (void )
net/netfilter/nf_conntrack_standalone.c +6 -9
@@ -383,15 +383,11 @@ static ctl_table nf_ct_netfilter_table[] = { { .ctl_name = 0 } }; -static ctl_table nf_ct_net_table[] = { - { - .ctl_name =CTL_NET , - .procname ="net" , - .mode =0555 , - .child = nf_ct_netfilter_table, - }, - { .ctl_name =0 } +struct ctl_path nf_ct_path[] = { + { .procname ="net" , .ctl_name =CTL_NET , }, + { } }; +EXPORT_SYMBOL_GPL (nf_ct_log_invalid);#endif /* CONFIG_SYSCTL */
@@ -418,7 +414,8 @@ static int __init nf_conntrack_standalone_init(void) proc_stat->owner =THIS_MODULE ;#endif #ifdef CONFIG_SYSCTL - nf_ct_sysctl_header =register_sysctl_table (nf_ct_net_table); + nf_ct_sysctl_header =register_sysctl_paths (nf_ct_path, + nf_ct_netfilter_table);if (nf_ct_sysctl_header ==NULL ) {printk ("nf_conntrack: can't register to sysctl.\n" ); ret = -ENOMEM ;
Re: [PATCH net-2.6.25 5/6][NETFILTER] Switch to using ctl_paths in nf_queue and conntrack modules
Quoted 8 lines · Pavel Emelyanov
This includes the most simple cases for netfilter.
The first part is tne queue modules for ipv4 and ipv6,
on which thenet/ipv4/andnet/ipv6/paths are reused from the appropriate ipv4 and ipv6 code.The conntrack module is also patched, but this hunk is very small and simple.
Signed-off-by Pavel Emelyanov <[email protected]>
Looks good to me.
Re: [PATCH net-2.6.25 5/6][NETFILTER] Switch to using ctl_paths in nf_queue and conntrack modules
From: Patrick McHardy <[email protected]>
Date: Tue, 08 Jan 2008 17:10:58 +0100
Quoted 7 lines
Quoted 6 lines · Pavel Emelyanov
This includes the most simple cases for netfilter.
The first part is tne queue modules for ipv4 and ipv6, on which the
net/ipv4/andnet/ipv6/paths are reused from the appropriate ipv4 and ipv6 code.
Quoted 6 lines
Quoted 4 lines
The conntrack module is also patched, but this hunk is very small and simple.
Signed-off-by Pavel Emelyanov <[email protected]>Looks good to me.
Applied.
PATCH 6/6 Use the ctl paths instead of hand-made analogue
In reply to Pavel EmelyanovThe conntracks subsystem has a similar infrastructure to maintain ctl_paths, but since we already have it on the generic level, I think it's OK to switch to using it.
So, basically, this patch just replaces the ctl_table-s with ctl_path-s, nf_register_sysctl_table with register_sysctl_paths() and removes no longer needed code.
After this the net/netfilter/nf_sysctl.c file contains the paths only.
---
include/linux/netfilter.h | 8 - include/net/netfilter/nf_conntrack_l3proto.h | 2 net/netfilter/nf_conntrack_proto.c | 7 - net/netfilter/nf_sysctl.c | 127 +-------------------------- 4 files changed, 16 insertions(+), 128 deletions(-)
include/linux/netfilter.h +2 -6
@@ -120,12 +120,8 @@ void nf_unregister_sockopt(struct nf_sockopt_ops *reg);#ifdef CONFIG_SYSCTL /* Sysctl registration */ -struct ctl_table_header *nf_register_sysctl_table (struct ctl_table *path, -struct ctl_table *table); -void nf_unregister_sysctl_table (struct ctl_table_header *header, -struct ctl_table *table); -extern struct ctl_table nf_net_netfilter_sysctl_path[]; -extern struct ctl_table nf_net_ipv4_netfilter_sysctl_path[]; +extern struct ctl_path nf_net_netfilter_sysctl_path[]; +extern struct ctl_path nf_net_ipv4_netfilter_sysctl_path[];#endif /* CONFIG_SYSCTL */ extern struct list_head nf_hooks[NPROTO ][NF_MAX_HOOKS ];
include/net/netfilter/nf_conntrack_l3proto.h +1 -1
@@ -73,7 +73,7 @@ struct nf_conntrack_l3proto#ifdef CONFIG_SYSCTL struct ctl_table_header *ctl_table_header; -struct ctl_table *ctl_table_path; +struct ctl_path *ctl_table_path;struct ctl_table *ctl_table;#endif /* CONFIG_SYSCTL */
net/netfilter/nf_conntrack_proto.c +4 -3
@@ -36,11 +36,11 @@ static DEFINE_MUTEX(nf_ct_proto_mutex);#ifdef CONFIG_SYSCTL static int -nf_ct_register_sysctl (struct ctl_table_header **header,struct ctl_table *path, +nf_ct_register_sysctl (struct ctl_table_header **header,struct ctl_path *path,struct ctl_table *table,unsigned int *users) {if (*header ==NULL ) { - *header =nf_register_sysctl_table (path, table); + *header =register_sysctl_paths (path, table);if (*header ==NULL )return -ENOMEM ; }
@@ -55,7 +55,8 @@ nf_ct_unregister_sysctl(struct ctl_table_header **header, {if (users !=NULL && --*users >0 )return ; -nf_unregister_sysctl_table (*header, table); + +unregister_sysctl_table (*header); *header =NULL ; }#endif
net/netfilter/nf_sysctl.c +9 -118
137 lines not on this page · raw message
Re: [PATCH net-2.6.25 6/6][NETFILTER] Use the ctl paths instead of hand-made analogue
Quoted 7 lines · Pavel Emelyanov
The conntracks subsystem has a similar infrastructure to maintain
ctl_paths, but since we already have it on the generic level, I think it's OK to switch to using it.So, basically, this patch just replaces the ctl_table-s
with ctl_path-s,nf_register_sysctl_tablewithregister_sysctl_paths()and removes no longer needed code.
Also looks good, thanks. But please remeber to CC netfilter-devel on patches affecting netfilter.
Quoted 1 line
After this the
net/netfilter/nf_sysctl.cfile contains the paths only.
That sounds like they should be moved to net/netfilter/core.c instead and the file removed. I can take care of that once your patches are in Dave's tree.
David Miller
maintainerRe: [PATCH net-2.6.25 6/6][NETFILTER] Use the ctl paths instead of hand-made analogue
From: Patrick McHardy <[email protected]>
Date: Tue, 08 Jan 2008 17:13:30 +0100
Quoted 11 lines
Quoted 8 lines · Pavel Emelyanov
The conntracks subsystem has a similar infrastructure to maintain
ctl_paths, but since we already have it on the generic level, I think it's OK to switch to using it.So, basically, this patch just replaces the ctl_table-s with ctl_path-s,
nf_register_sysctl_tablewithregister_sysctl_paths()and removes no longer needed code.Also looks good, thanks.
Also applied, thanks.