Skip to content

Commit

Permalink
net: Convert all sysctl registrations to register_net_sysctl
Browse files Browse the repository at this point in the history
This results in code with less boiler plate that is a bit easier
to read.

Additionally stops us from using compatibility code in the sysctl
core, hastening the day when the compatibility code can be removed.

Signed-off-by: Eric W. Biederman <[email protected]>
Acked-by: Pavel Emelyanov <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
ebiederm authored and davem330 committed Apr 21, 2012
1 parent f99e8f7 commit ec8f23c
Show file tree
Hide file tree
Showing 36 changed files with 44 additions and 171 deletions.
8 changes: 1 addition & 7 deletions drivers/infiniband/core/ucma.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ static ctl_table ucma_ctl_table[] = {
{ }
};

static struct ctl_path ucma_ctl_path[] = {
{ .procname = "net" },
{ .procname = "rdma_ucm" },
{ }
};

struct ucma_file {
struct mutex mut;
struct file *filp;
Expand Down Expand Up @@ -1392,7 +1386,7 @@ static int __init ucma_init(void)
goto err1;
}

ucma_ctl_table_hdr = register_net_sysctl_table(&init_net, ucma_ctl_path, ucma_ctl_table);
ucma_ctl_table_hdr = register_net_sysctl(&init_net, "net/rdma_ucm", ucma_ctl_table);
if (!ucma_ctl_table_hdr) {
printk(KERN_ERR "rdma_ucm: couldn't register sysctl paths\n");
ret = -ENOMEM;
Expand Down
8 changes: 1 addition & 7 deletions net/802/tr.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,12 +643,6 @@ static struct ctl_table tr_table[] = {
},
{ },
};

static __initdata struct ctl_path tr_path[] = {
{ .procname = "net", },
{ .procname = "token-ring", },
{ }
};
#endif

/*
Expand All @@ -662,7 +656,7 @@ static int __init rif_init(void)
setup_timer(&rif_timer, rif_check_expire, 0);
add_timer(&rif_timer);
#ifdef CONFIG_SYSCTL
register_net_sysctl_table(&init_net, tr_path, tr_table);
register_net_sysctl(&init_net, "net/token-ring", tr_table);
#endif
proc_net_fops_create(&init_net, "tr_rif", S_IRUGO, &rif_seq_fops);
return 0;
Expand Down
8 changes: 1 addition & 7 deletions net/appletalk/sysctl_net_atalk.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,11 @@ static struct ctl_table atalk_table[] = {
{ },
};

static struct ctl_path atalk_path[] = {
{ .procname = "net", },
{ .procname = "appletalk", },
{ }
};

static struct ctl_table_header *atalk_table_header;

void atalk_register_sysctl(void)
{
atalk_table_header = register_net_sysctl_table(&init_net, atalk_path, atalk_table);
atalk_table_header = register_net_sysctl(&init_net, "net/appletalk", atalk_table);
}

void atalk_unregister_sysctl(void)
Expand Down
8 changes: 1 addition & 7 deletions net/bridge/br_netfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1008,12 +1008,6 @@ static ctl_table brnf_table[] = {
},
{ }
};

static struct ctl_path brnf_path[] = {
{ .procname = "net", },
{ .procname = "bridge", },
{ }
};
#endif

int __init br_netfilter_init(void)
Expand All @@ -1030,7 +1024,7 @@ int __init br_netfilter_init(void)
return ret;
}
#ifdef CONFIG_SYSCTL
brnf_sysctl_header = register_net_sysctl_table(&init_net, brnf_path, brnf_table);
brnf_sysctl_header = register_net_sysctl(&init_net, "net/bridge", brnf_table);
if (brnf_sysctl_header == NULL) {
printk(KERN_WARNING
"br_netfilter: can't register to sysctl.\n");
Expand Down
3 changes: 1 addition & 2 deletions net/core/sysctl_net_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,7 @@ static __net_init int sysctl_core_net_init(struct net *net)
tbl[0].data = &net->core.sysctl_somaxconn;
}

net->core.sysctl_hdr = register_net_sysctl_table(net,
net_core_path, tbl);
net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
if (net->core.sysctl_hdr == NULL)
goto err_reg;

Expand Down
9 changes: 1 addition & 8 deletions net/dccp/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,11 @@ static struct ctl_table dccp_default_table[] = {
{ }
};

static struct ctl_path dccp_path[] = {
{ .procname = "net", },
{ .procname = "dccp", },
{ .procname = "default", },
{ }
};

static struct ctl_table_header *dccp_table_header;

int __init dccp_sysctl_init(void)
{
dccp_table_header = register_net_sysctl_table(&init_net, dccp_path,
dccp_table_header = register_net_sysctl(&init_net, "net/dccp/default",
dccp_default_table);

return dccp_table_header != NULL ? 0 : -ENOMEM;
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/ip_fragment.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
table[2].data = &net->ipv4.frags.timeout;
}

hdr = register_net_sysctl_table(net, net_ipv4_ctl_path, table);
hdr = register_net_sysctl(net, "net/ipv4", table);
if (hdr == NULL)
goto err_reg;

Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/netfilter/ip_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ static int __init ip_queue_init(void)
#endif
register_netdevice_notifier(&ipq_dev_notifier);
#ifdef CONFIG_SYSCTL
ipq_sysctl_header = register_net_sysctl_table(&init_net, net_ipv4_ctl_path, ipq_table);
ipq_sysctl_header = register_net_sysctl(&init_net, "net/ipv4", ipq_table);
#endif
status = nf_register_queue_handler(NFPROTO_IPV4, &nfqh);
if (status < 0) {
Expand Down
10 changes: 1 addition & 9 deletions net/ipv4/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -3354,13 +3354,6 @@ static struct ctl_table ipv4_route_flush_table[] = {
{ },
};

static __net_initdata struct ctl_path ipv4_route_path[] = {
{ .procname = "net", },
{ .procname = "ipv4", },
{ .procname = "route", },
{ },
};

static __net_init int sysctl_route_net_init(struct net *net)
{
struct ctl_table *tbl;
Expand All @@ -3373,8 +3366,7 @@ static __net_init int sysctl_route_net_init(struct net *net)
}
tbl[0].extra1 = net;

net->ipv4.route_hdr =
register_net_sysctl_table(net, ipv4_route_path, tbl);
net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
if (net->ipv4.route_hdr == NULL)
goto err_reg;
return 0;
Expand Down
5 changes: 2 additions & 3 deletions net/ipv4/sysctl_net_ipv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -815,8 +815,7 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)

tcp_init_mem(net);

net->ipv4.ipv4_hdr = register_net_sysctl_table(net,
net_ipv4_ctl_path, table);
net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
if (net->ipv4.ipv4_hdr == NULL)
goto err_reg;

Expand Down Expand Up @@ -857,7 +856,7 @@ static __init int sysctl_ipv4_init(void)
if (!i->procname)
return -EINVAL;

hdr = register_net_sysctl_table(&init_net, net_ipv4_ctl_path, ipv4_table);
hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
if (hdr == NULL)
return -ENOMEM;

Expand Down
4 changes: 2 additions & 2 deletions net/ipv4/xfrm4_policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ void __init xfrm4_init(int rt_max_size)
xfrm4_state_init();
xfrm4_policy_init();
#ifdef CONFIG_SYSCTL
sysctl_hdr = register_net_sysctl_table(&init_net, net_ipv4_ctl_path,
xfrm4_policy_table);
sysctl_hdr = register_net_sysctl(&init_net, "net/ipv4",
xfrm4_policy_table);
#endif
}

2 changes: 1 addition & 1 deletion net/ipv6/netfilter/ip6_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ static int __init ip6_queue_init(void)
#endif
register_netdevice_notifier(&ipq_dev_notifier);
#ifdef CONFIG_SYSCTL
ipq_sysctl_header = register_net_sysctl_table(&init_net, net_ipv6_ctl_path, ipq_table);
ipq_sysctl_header = register_net_sysctl(&init_net, "net/ipv6", ipq_table);
#endif
status = nf_register_queue_handler(NFPROTO_IPV6, &nfqh);
if (status < 0) {
Expand Down
4 changes: 2 additions & 2 deletions net/ipv6/netfilter/nf_conntrack_reasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,8 @@ int nf_ct_frag6_init(void)
inet_frags_init(&nf_frags);

#ifdef CONFIG_SYSCTL
nf_ct_frag6_sysctl_header = register_net_sysctl_table(&init_net, nf_net_netfilter_sysctl_path,
nf_ct_frag6_sysctl_table);
nf_ct_frag6_sysctl_header = register_net_sysctl(&init_net, "net/netfilter",
nf_ct_frag6_sysctl_table);
if (!nf_ct_frag6_sysctl_header) {
inet_frags_fini(&nf_frags);
return -ENOMEM;
Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/reassembly.c
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
table[2].data = &net->ipv6.frags.timeout;
}

hdr = register_net_sysctl_table(net, net_ipv6_ctl_path, table);
hdr = register_net_sysctl(net, "net/ipv6", table);
if (hdr == NULL)
goto err_reg;

Expand Down
4 changes: 2 additions & 2 deletions net/ipv6/xfrm6_policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ int __init xfrm6_init(void)
goto out_policy;

#ifdef CONFIG_SYSCTL
sysctl_hdr = register_net_sysctl_table(&init_net, net_ipv6_ctl_path,
xfrm6_policy_table);
sysctl_hdr = register_net_sysctl(&init_net, "net/ipv6",
xfrm6_policy_table);
#endif
out:
return ret;
Expand Down
8 changes: 1 addition & 7 deletions net/ipx/sysctl_net_ipx.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,11 @@ static struct ctl_table ipx_table[] = {
{ },
};

static struct ctl_path ipx_path[] = {
{ .procname = "net", },
{ .procname = "ipx", },
{ }
};

static struct ctl_table_header *ipx_table_header;

void ipx_register_sysctl(void)
{
ipx_table_header = register_net_sysctl_table(&init_net, ipx_path, ipx_table);
ipx_table_header = register_net_sysctl(&init_net, "net/ipx", ipx_table);
}

void ipx_unregister_sysctl(void)
Expand Down
8 changes: 1 addition & 7 deletions net/irda/irsysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,6 @@ static ctl_table irda_table[] = {
{ }
};

static struct ctl_path irda_path[] = {
{ .procname = "net", },
{ .procname = "irda", },
{ }
};

static struct ctl_table_header *irda_table_header;

/*
Expand All @@ -251,7 +245,7 @@ static struct ctl_table_header *irda_table_header;
*/
int __init irda_sysctl_register(void)
{
irda_table_header = register_net_sysctl_table(&init_net, irda_path, irda_table);
irda_table_header = register_net_sysctl(&init_net, "net/irda", irda_table);
if (!irda_table_header)
return -ENOMEM;

Expand Down
3 changes: 1 addition & 2 deletions net/netfilter/ipvs/ip_vs_ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3672,8 +3672,7 @@ int __net_init ip_vs_control_net_init_sysctl(struct net *net)
tbl[idx++].data = &ipvs->sysctl_nat_icmp_send;


ipvs->sysctl_hdr = register_net_sysctl_table(net, net_vs_ctl_path,
tbl);
ipvs->sysctl_hdr = register_net_sysctl(net, "net/ipv4/vs", tbl);
if (ipvs->sysctl_hdr == NULL) {
if (!net_eq(net, &init_net))
kfree(tbl);
Expand Down
3 changes: 1 addition & 2 deletions net/netfilter/ipvs/ip_vs_lblc.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,7 @@ static int __net_init __ip_vs_lblc_init(struct net *net)
ipvs->lblc_ctl_table[0].data = &ipvs->sysctl_lblc_expiration;

ipvs->lblc_ctl_header =
register_net_sysctl_table(net, net_vs_ctl_path,
ipvs->lblc_ctl_table);
register_net_sysctl(net, "net/ipv4/vs", ipvs->lblc_ctl_table);
if (!ipvs->lblc_ctl_header) {
if (!net_eq(net, &init_net))
kfree(ipvs->lblc_ctl_table);
Expand Down
3 changes: 1 addition & 2 deletions net/netfilter/ipvs/ip_vs_lblcr.c
Original file line number Diff line number Diff line change
Expand Up @@ -757,8 +757,7 @@ static int __net_init __ip_vs_lblcr_init(struct net *net)
ipvs->lblcr_ctl_table[0].data = &ipvs->sysctl_lblcr_expiration;

ipvs->lblcr_ctl_header =
register_net_sysctl_table(net, net_vs_ctl_path,
ipvs->lblcr_ctl_table);
register_net_sysctl(net, "net/ipv4/vs", ipvs->lblcr_ctl_table);
if (!ipvs->lblcr_ctl_header) {
if (!net_eq(net, &init_net))
kfree(ipvs->lblcr_ctl_table);
Expand Down
4 changes: 2 additions & 2 deletions net/netfilter/nf_conntrack_acct.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ static int nf_conntrack_acct_init_sysctl(struct net *net)

table[0].data = &net->ct.sysctl_acct;

net->ct.acct_sysctl_header = register_net_sysctl_table(net,
nf_net_netfilter_sysctl_path, table);
net->ct.acct_sysctl_header = register_net_sysctl(net, "net/netfilter",
table);
if (!net->ct.acct_sysctl_header) {
printk(KERN_ERR "nf_conntrack_acct: can't register to sysctl.\n");
goto out_register;
Expand Down
3 changes: 1 addition & 2 deletions net/netfilter/nf_conntrack_ecache.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,7 @@ static int nf_conntrack_event_init_sysctl(struct net *net)
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);
register_net_sysctl(net, "net/netfilter", table);
if (!net->ct.event_sysctl_header) {
printk(KERN_ERR "nf_ct_event: can't register to sysctl.\n");
goto out_register;
Expand Down
4 changes: 2 additions & 2 deletions net/netfilter/nf_conntrack_proto_dccp.c
Original file line number Diff line number Diff line change
Expand Up @@ -910,8 +910,8 @@ static __net_init int dccp_net_init(struct net *net)
dn->sysctl_table[6].data = &dn->dccp_timeout[CT_DCCP_TIMEWAIT];
dn->sysctl_table[7].data = &dn->dccp_loose;

dn->sysctl_header = register_net_sysctl_table(net,
nf_net_netfilter_sysctl_path, dn->sysctl_table);
dn->sysctl_header = register_net_sysctl(net, "net/netfilter",
dn->sysctl_table);
if (!dn->sysctl_header) {
kfree(dn->sysctl_table);
return -ENOMEM;
Expand Down
10 changes: 2 additions & 8 deletions net/netfilter/nf_conntrack_standalone.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,18 +468,13 @@ static ctl_table nf_ct_netfilter_table[] = {
{ }
};

static struct ctl_path nf_ct_path[] = {
{ .procname = "net", },
{ }
};

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_net_sysctl_table(&init_net, nf_ct_path, nf_ct_netfilter_table);
register_net_sysctl(&init_net, "net", nf_ct_netfilter_table);
if (!nf_ct_netfilter_header)
goto out;
}
Expand All @@ -494,8 +489,7 @@ static int nf_conntrack_standalone_init_sysctl(struct net *net)
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);
net->ct.sysctl_header = register_net_sysctl(net, "net/netfilter", table);
if (!net->ct.sysctl_header)
goto out_unregister_netfilter;

Expand Down
4 changes: 2 additions & 2 deletions net/netfilter/nf_conntrack_timestamp.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ static int nf_conntrack_tstamp_init_sysctl(struct net *net)

table[0].data = &net->ct.sysctl_tstamp;

net->ct.tstamp_sysctl_header = register_net_sysctl_table(net,
nf_net_netfilter_sysctl_path, table);
net->ct.tstamp_sysctl_header = register_net_sysctl(net, "net/netfilter",
table);
if (!net->ct.tstamp_sysctl_header) {
printk(KERN_ERR "nf_ct_tstamp: can't register to sysctl.\n");
goto out_register;
Expand Down
9 changes: 1 addition & 8 deletions net/netfilter/nf_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,6 @@ static const struct file_operations nflog_file_ops = {
#endif /* PROC_FS */

#ifdef CONFIG_SYSCTL
static struct ctl_path nf_log_sysctl_path[] = {
{ .procname = "net", },
{ .procname = "netfilter", },
{ .procname = "nf_log", },
{ }
};

static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
static struct ctl_table_header *nf_log_dir_header;
Expand Down Expand Up @@ -283,7 +276,7 @@ static __init int netfilter_log_sysctl_init(void)
nf_log_sysctl_table[i].extra1 = (void *)(unsigned long) i;
}

nf_log_dir_header = register_net_sysctl_table(&init_net, nf_log_sysctl_path,
nf_log_dir_header = register_net_sysctl(&init_net, "net/netfilter/nf_log",
nf_log_sysctl_table);
if (!nf_log_dir_header)
return -ENOMEM;
Expand Down
Loading

0 comments on commit ec8f23c

Please sign in to comment.