提交 c392a740 编写于 作者: P Patrick McHardy 提交者: David S. Miller

[NETFILTER]: {ip,ip6}_queue: fix build error

Reported by Ingo Molnar:

 net/built-in.o: In function `ip_queue_init':
 ip_queue.c:(.init.text+0x322c): undefined reference to `net_ipv4_ctl_path'

Fix the build error and also handle CONFIG_PROC_FS=n properly.
Signed-off-by: NPatrick McHardy <kaber@trash.net>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 32948588
...@@ -512,6 +512,7 @@ static struct notifier_block ipq_nl_notifier = { ...@@ -512,6 +512,7 @@ static struct notifier_block ipq_nl_notifier = {
.notifier_call = ipq_rcv_nl_event, .notifier_call = ipq_rcv_nl_event,
}; };
#ifdef CONFIG_SYSCTL
static struct ctl_table_header *ipq_sysctl_header; static struct ctl_table_header *ipq_sysctl_header;
static ctl_table ipq_table[] = { static ctl_table ipq_table[] = {
...@@ -525,7 +526,9 @@ static ctl_table ipq_table[] = { ...@@ -525,7 +526,9 @@ static ctl_table ipq_table[] = {
}, },
{ .ctl_name = 0 } { .ctl_name = 0 }
}; };
#endif
#ifdef CONFIG_PROC_FS
static int ip_queue_show(struct seq_file *m, void *v) static int ip_queue_show(struct seq_file *m, void *v)
{ {
read_lock_bh(&queue_lock); read_lock_bh(&queue_lock);
...@@ -562,6 +565,7 @@ static const struct file_operations ip_queue_proc_fops = { ...@@ -562,6 +565,7 @@ static const struct file_operations ip_queue_proc_fops = {
.release = single_release, .release = single_release,
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
#endif
static const struct nf_queue_handler nfqh = { static const struct nf_queue_handler nfqh = {
.name = "ip_queue", .name = "ip_queue",
...@@ -571,7 +575,7 @@ static const struct nf_queue_handler nfqh = { ...@@ -571,7 +575,7 @@ static const struct nf_queue_handler nfqh = {
static int __init ip_queue_init(void) static int __init ip_queue_init(void)
{ {
int status = -ENOMEM; int status = -ENOMEM;
struct proc_dir_entry *proc; struct proc_dir_entry *proc __maybe_unused;
netlink_register_notifier(&ipq_nl_notifier); netlink_register_notifier(&ipq_nl_notifier);
ipqnl = netlink_kernel_create(&init_net, NETLINK_FIREWALL, 0, ipqnl = netlink_kernel_create(&init_net, NETLINK_FIREWALL, 0,
...@@ -581,6 +585,7 @@ static int __init ip_queue_init(void) ...@@ -581,6 +585,7 @@ static int __init ip_queue_init(void)
goto cleanup_netlink_notifier; goto cleanup_netlink_notifier;
} }
#ifdef CONFIG_PROC_FS
proc = create_proc_entry(IPQ_PROC_FS_NAME, 0, init_net.proc_net); proc = create_proc_entry(IPQ_PROC_FS_NAME, 0, init_net.proc_net);
if (proc) { if (proc) {
proc->owner = THIS_MODULE; proc->owner = THIS_MODULE;
...@@ -589,10 +594,11 @@ static int __init ip_queue_init(void) ...@@ -589,10 +594,11 @@ static int __init ip_queue_init(void)
printk(KERN_ERR "ip_queue: failed to create proc entry\n"); printk(KERN_ERR "ip_queue: failed to create proc entry\n");
goto cleanup_ipqnl; goto cleanup_ipqnl;
} }
#endif
register_netdevice_notifier(&ipq_dev_notifier); register_netdevice_notifier(&ipq_dev_notifier);
#ifdef CONFIG_SYSCTL
ipq_sysctl_header = register_sysctl_paths(net_ipv4_ctl_path, ipq_table); ipq_sysctl_header = register_sysctl_paths(net_ipv4_ctl_path, ipq_table);
#endif
status = nf_register_queue_handler(PF_INET, &nfqh); status = nf_register_queue_handler(PF_INET, &nfqh);
if (status < 0) { if (status < 0) {
printk(KERN_ERR "ip_queue: failed to register queue handler\n"); printk(KERN_ERR "ip_queue: failed to register queue handler\n");
...@@ -601,10 +607,12 @@ static int __init ip_queue_init(void) ...@@ -601,10 +607,12 @@ static int __init ip_queue_init(void)
return status; return status;
cleanup_sysctl: cleanup_sysctl:
#ifdef CONFIG_SYSCTL
unregister_sysctl_table(ipq_sysctl_header); unregister_sysctl_table(ipq_sysctl_header);
#endif
unregister_netdevice_notifier(&ipq_dev_notifier); unregister_netdevice_notifier(&ipq_dev_notifier);
proc_net_remove(&init_net, IPQ_PROC_FS_NAME); proc_net_remove(&init_net, IPQ_PROC_FS_NAME);
cleanup_ipqnl: cleanup_ipqnl: __maybe_unused
netlink_kernel_release(ipqnl); netlink_kernel_release(ipqnl);
mutex_lock(&ipqnl_mutex); mutex_lock(&ipqnl_mutex);
mutex_unlock(&ipqnl_mutex); mutex_unlock(&ipqnl_mutex);
...@@ -620,7 +628,9 @@ static void __exit ip_queue_fini(void) ...@@ -620,7 +628,9 @@ static void __exit ip_queue_fini(void)
synchronize_net(); synchronize_net();
ipq_flush(NULL, 0); ipq_flush(NULL, 0);
#ifdef CONFIG_SYSCTL
unregister_sysctl_table(ipq_sysctl_header); unregister_sysctl_table(ipq_sysctl_header);
#endif
unregister_netdevice_notifier(&ipq_dev_notifier); unregister_netdevice_notifier(&ipq_dev_notifier);
proc_net_remove(&init_net, IPQ_PROC_FS_NAME); proc_net_remove(&init_net, IPQ_PROC_FS_NAME);
......
...@@ -515,6 +515,7 @@ static struct notifier_block ipq_nl_notifier = { ...@@ -515,6 +515,7 @@ static struct notifier_block ipq_nl_notifier = {
.notifier_call = ipq_rcv_nl_event, .notifier_call = ipq_rcv_nl_event,
}; };
#ifdef CONFIG_SYSCTL
static struct ctl_table_header *ipq_sysctl_header; static struct ctl_table_header *ipq_sysctl_header;
static ctl_table ipq_table[] = { static ctl_table ipq_table[] = {
...@@ -528,7 +529,9 @@ static ctl_table ipq_table[] = { ...@@ -528,7 +529,9 @@ static ctl_table ipq_table[] = {
}, },
{ .ctl_name = 0 } { .ctl_name = 0 }
}; };
#endif
#ifdef CONFIG_PROC_FS
static int ip6_queue_show(struct seq_file *m, void *v) static int ip6_queue_show(struct seq_file *m, void *v)
{ {
read_lock_bh(&queue_lock); read_lock_bh(&queue_lock);
...@@ -565,6 +568,7 @@ static const struct file_operations ip6_queue_proc_fops = { ...@@ -565,6 +568,7 @@ static const struct file_operations ip6_queue_proc_fops = {
.release = single_release, .release = single_release,
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
#endif
static const struct nf_queue_handler nfqh = { static const struct nf_queue_handler nfqh = {
.name = "ip6_queue", .name = "ip6_queue",
...@@ -574,7 +578,7 @@ static const struct nf_queue_handler nfqh = { ...@@ -574,7 +578,7 @@ static const struct nf_queue_handler nfqh = {
static int __init ip6_queue_init(void) static int __init ip6_queue_init(void)
{ {
int status = -ENOMEM; int status = -ENOMEM;
struct proc_dir_entry *proc; struct proc_dir_entry *proc __maybe_unused;
netlink_register_notifier(&ipq_nl_notifier); netlink_register_notifier(&ipq_nl_notifier);
ipqnl = netlink_kernel_create(&init_net, NETLINK_IP6_FW, 0, ipqnl = netlink_kernel_create(&init_net, NETLINK_IP6_FW, 0,
...@@ -584,6 +588,7 @@ static int __init ip6_queue_init(void) ...@@ -584,6 +588,7 @@ static int __init ip6_queue_init(void)
goto cleanup_netlink_notifier; goto cleanup_netlink_notifier;
} }
#ifdef CONFIG_PROC_FS
proc = create_proc_entry(IPQ_PROC_FS_NAME, 0, init_net.proc_net); proc = create_proc_entry(IPQ_PROC_FS_NAME, 0, init_net.proc_net);
if (proc) { if (proc) {
proc->owner = THIS_MODULE; proc->owner = THIS_MODULE;
...@@ -592,10 +597,11 @@ static int __init ip6_queue_init(void) ...@@ -592,10 +597,11 @@ static int __init ip6_queue_init(void)
printk(KERN_ERR "ip6_queue: failed to create proc entry\n"); printk(KERN_ERR "ip6_queue: failed to create proc entry\n");
goto cleanup_ipqnl; goto cleanup_ipqnl;
} }
#endif
register_netdevice_notifier(&ipq_dev_notifier); register_netdevice_notifier(&ipq_dev_notifier);
#ifdef CONFIG_SYSCTL
ipq_sysctl_header = register_sysctl_paths(net_ipv6_ctl_path, ipq_table); ipq_sysctl_header = register_sysctl_paths(net_ipv6_ctl_path, ipq_table);
#endif
status = nf_register_queue_handler(PF_INET6, &nfqh); status = nf_register_queue_handler(PF_INET6, &nfqh);
if (status < 0) { if (status < 0) {
printk(KERN_ERR "ip6_queue: failed to register queue handler\n"); printk(KERN_ERR "ip6_queue: failed to register queue handler\n");
...@@ -604,11 +610,13 @@ static int __init ip6_queue_init(void) ...@@ -604,11 +610,13 @@ static int __init ip6_queue_init(void)
return status; return status;
cleanup_sysctl: cleanup_sysctl:
#ifdef CONFIG_SYSCTL
unregister_sysctl_table(ipq_sysctl_header); unregister_sysctl_table(ipq_sysctl_header);
#endif
unregister_netdevice_notifier(&ipq_dev_notifier); unregister_netdevice_notifier(&ipq_dev_notifier);
proc_net_remove(&init_net, IPQ_PROC_FS_NAME); proc_net_remove(&init_net, IPQ_PROC_FS_NAME);
cleanup_ipqnl: cleanup_ipqnl: __maybe_unused
netlink_kernel_release(ipqnl); netlink_kernel_release(ipqnl);
mutex_lock(&ipqnl_mutex); mutex_lock(&ipqnl_mutex);
mutex_unlock(&ipqnl_mutex); mutex_unlock(&ipqnl_mutex);
...@@ -624,7 +632,9 @@ static void __exit ip6_queue_fini(void) ...@@ -624,7 +632,9 @@ static void __exit ip6_queue_fini(void)
synchronize_net(); synchronize_net();
ipq_flush(NULL, 0); ipq_flush(NULL, 0);
#ifdef CONFIG_SYSCTL
unregister_sysctl_table(ipq_sysctl_header); unregister_sysctl_table(ipq_sysctl_header);
#endif
unregister_netdevice_notifier(&ipq_dev_notifier); unregister_netdevice_notifier(&ipq_dev_notifier);
proc_net_remove(&init_net, IPQ_PROC_FS_NAME); proc_net_remove(&init_net, IPQ_PROC_FS_NAME);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册