提交 0443929f 编写于 作者: S Simon Horman 提交者: Patrick McHardy

IPVS: Allow compilation with CONFIG_SYSCTL disabled

This is a rather naieve approach to allowing PVS to compile with
CONFIG_SYSCTL disabled.  I am working on a more comprehensive patch which
will remove compilation of all sysctl-related IPVS code when CONFIG_SYSCTL
is disabled.
Reported-by: NRandy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: NSimon Horman <horms@verge.net.au>
Acked-by: NRandy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: NHans Schillstrom <hans@schillstrom.com>
Tested-by: NHans Schillstrom <hans@schillstrom.com>
Signed-off-by: NPatrick McHardy <kaber@trash.net>
上级 a1367647
...@@ -3552,10 +3552,15 @@ int __net_init __ip_vs_control_init(struct net *net) ...@@ -3552,10 +3552,15 @@ int __net_init __ip_vs_control_init(struct net *net)
tbl[idx++].data = &ipvs->sysctl_nat_icmp_send; tbl[idx++].data = &ipvs->sysctl_nat_icmp_send;
#ifdef CONFIG_SYSCTL
ipvs->sysctl_hdr = register_net_sysctl_table(net, net_vs_ctl_path, ipvs->sysctl_hdr = register_net_sysctl_table(net, net_vs_ctl_path,
tbl); tbl);
if (ipvs->sysctl_hdr == NULL) if (ipvs->sysctl_hdr == NULL) {
goto err_reg; if (!net_eq(net, &init_net))
kfree(tbl);
goto err_dup;
}
#endif
ip_vs_new_estimator(net, ipvs->tot_stats); ip_vs_new_estimator(net, ipvs->tot_stats);
ipvs->sysctl_tbl = tbl; ipvs->sysctl_tbl = tbl;
/* Schedule defense work */ /* Schedule defense work */
...@@ -3563,9 +3568,6 @@ int __net_init __ip_vs_control_init(struct net *net) ...@@ -3563,9 +3568,6 @@ int __net_init __ip_vs_control_init(struct net *net)
schedule_delayed_work(&ipvs->defense_work, DEFENSE_TIMER_PERIOD); schedule_delayed_work(&ipvs->defense_work, DEFENSE_TIMER_PERIOD);
return 0; return 0;
err_reg:
if (!net_eq(net, &init_net))
kfree(tbl);
err_dup: err_dup:
free_percpu(ipvs->cpustats); free_percpu(ipvs->cpustats);
err_alloc: err_alloc:
...@@ -3581,7 +3583,9 @@ static void __net_exit __ip_vs_control_cleanup(struct net *net) ...@@ -3581,7 +3583,9 @@ static void __net_exit __ip_vs_control_cleanup(struct net *net)
ip_vs_kill_estimator(net, ipvs->tot_stats); ip_vs_kill_estimator(net, ipvs->tot_stats);
cancel_delayed_work_sync(&ipvs->defense_work); cancel_delayed_work_sync(&ipvs->defense_work);
cancel_work_sync(&ipvs->defense_work.work); cancel_work_sync(&ipvs->defense_work.work);
#ifdef CONFIG_SYSCTL
unregister_net_sysctl_table(ipvs->sysctl_hdr); unregister_net_sysctl_table(ipvs->sysctl_hdr);
#endif
proc_net_remove(net, "ip_vs_stats_percpu"); proc_net_remove(net, "ip_vs_stats_percpu");
proc_net_remove(net, "ip_vs_stats"); proc_net_remove(net, "ip_vs_stats");
proc_net_remove(net, "ip_vs"); proc_net_remove(net, "ip_vs");
......
...@@ -554,33 +554,33 @@ static int __net_init __ip_vs_lblc_init(struct net *net) ...@@ -554,33 +554,33 @@ static int __net_init __ip_vs_lblc_init(struct net *net)
sizeof(vs_vars_table), sizeof(vs_vars_table),
GFP_KERNEL); GFP_KERNEL);
if (ipvs->lblc_ctl_table == NULL) if (ipvs->lblc_ctl_table == NULL)
goto err_dup; return -ENOMEM;
} else } else
ipvs->lblc_ctl_table = vs_vars_table; ipvs->lblc_ctl_table = vs_vars_table;
ipvs->sysctl_lblc_expiration = 24*60*60*HZ; ipvs->sysctl_lblc_expiration = 24*60*60*HZ;
ipvs->lblc_ctl_table[0].data = &ipvs->sysctl_lblc_expiration; ipvs->lblc_ctl_table[0].data = &ipvs->sysctl_lblc_expiration;
#ifdef CONFIG_SYSCTL
ipvs->lblc_ctl_header = ipvs->lblc_ctl_header =
register_net_sysctl_table(net, net_vs_ctl_path, register_net_sysctl_table(net, net_vs_ctl_path,
ipvs->lblc_ctl_table); ipvs->lblc_ctl_table);
if (!ipvs->lblc_ctl_header) if (!ipvs->lblc_ctl_header) {
goto err_reg; if (!net_eq(net, &init_net))
kfree(ipvs->lblc_ctl_table);
return -ENOMEM;
}
#endif
return 0; return 0;
err_reg:
if (!net_eq(net, &init_net))
kfree(ipvs->lblc_ctl_table);
err_dup:
return -ENOMEM;
} }
static void __net_exit __ip_vs_lblc_exit(struct net *net) static void __net_exit __ip_vs_lblc_exit(struct net *net)
{ {
struct netns_ipvs *ipvs = net_ipvs(net); struct netns_ipvs *ipvs = net_ipvs(net);
#ifdef CONFIG_SYSCTL
unregister_net_sysctl_table(ipvs->lblc_ctl_header); unregister_net_sysctl_table(ipvs->lblc_ctl_header);
#endif
if (!net_eq(net, &init_net)) if (!net_eq(net, &init_net))
kfree(ipvs->lblc_ctl_table); kfree(ipvs->lblc_ctl_table);
......
...@@ -754,33 +754,33 @@ static int __net_init __ip_vs_lblcr_init(struct net *net) ...@@ -754,33 +754,33 @@ static int __net_init __ip_vs_lblcr_init(struct net *net)
sizeof(vs_vars_table), sizeof(vs_vars_table),
GFP_KERNEL); GFP_KERNEL);
if (ipvs->lblcr_ctl_table == NULL) if (ipvs->lblcr_ctl_table == NULL)
goto err_dup; return -ENOMEM;
} else } else
ipvs->lblcr_ctl_table = vs_vars_table; ipvs->lblcr_ctl_table = vs_vars_table;
ipvs->sysctl_lblcr_expiration = 24*60*60*HZ; ipvs->sysctl_lblcr_expiration = 24*60*60*HZ;
ipvs->lblcr_ctl_table[0].data = &ipvs->sysctl_lblcr_expiration; ipvs->lblcr_ctl_table[0].data = &ipvs->sysctl_lblcr_expiration;
#ifdef CONFIG_SYSCTL
ipvs->lblcr_ctl_header = ipvs->lblcr_ctl_header =
register_net_sysctl_table(net, net_vs_ctl_path, register_net_sysctl_table(net, net_vs_ctl_path,
ipvs->lblcr_ctl_table); ipvs->lblcr_ctl_table);
if (!ipvs->lblcr_ctl_header) if (!ipvs->lblcr_ctl_header) {
goto err_reg; if (!net_eq(net, &init_net))
kfree(ipvs->lblcr_ctl_table);
return -ENOMEM;
}
#endif
return 0; return 0;
err_reg:
if (!net_eq(net, &init_net))
kfree(ipvs->lblcr_ctl_table);
err_dup:
return -ENOMEM;
} }
static void __net_exit __ip_vs_lblcr_exit(struct net *net) static void __net_exit __ip_vs_lblcr_exit(struct net *net)
{ {
struct netns_ipvs *ipvs = net_ipvs(net); struct netns_ipvs *ipvs = net_ipvs(net);
#ifdef CONFIG_SYSCTL
unregister_net_sysctl_table(ipvs->lblcr_ctl_header); unregister_net_sysctl_table(ipvs->lblcr_ctl_header);
#endif
if (!net_eq(net, &init_net)) if (!net_eq(net, &init_net))
kfree(ipvs->lblcr_ctl_table); kfree(ipvs->lblcr_ctl_table);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册