From 5c96c965be27556d2345a9534e36ff0e93604cec Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 7 Sep 2004 00:18:46 -0700 Subject: [PATCH] [NETFILTER]: Fix build error with CONFIG_SYSCTL disabled. ip_ct_log_invalid was added without testing that it compiles without CONFIG_SYSCTL. Since sysctl is the only way of turning it on, there should be no references to it if \!CONFIG_SYSCTL. Also, that turns off CONFIG_PROC_FS, which elicits more warnings. Squish them too. Signed-off-by: Rusty Russell Signed-off-by: David S. Miller --- .../netfilter_ipv4/ip_conntrack_protocol.h | 4 ++++ net/ipv4/netfilter/ip_conntrack_proto_sctp.c | 2 +- net/ipv4/netfilter/ip_conntrack_standalone.c | 21 +++++++++++++------ net/ipv4/netfilter/ip_queue.c | 2 ++ 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/include/linux/netfilter_ipv4/ip_conntrack_protocol.h b/include/linux/netfilter_ipv4/ip_conntrack_protocol.h index 55d57404acb82..6edb801fa51f4 100644 --- a/include/linux/netfilter_ipv4/ip_conntrack_protocol.h +++ b/include/linux/netfilter_ipv4/ip_conntrack_protocol.h @@ -75,6 +75,7 @@ extern int ip_conntrack_protocol_tcp_init(void); /* Log invalid packets */ extern unsigned int ip_ct_log_invalid; +#ifdef CONFIG_SYSCTL #ifdef DEBUG_INVALID_PACKETS #define LOG_INVALID(proto) \ (ip_ct_log_invalid == (proto) || ip_ct_log_invalid == IPPROTO_RAW) @@ -83,5 +84,8 @@ extern unsigned int ip_ct_log_invalid; ((ip_ct_log_invalid == (proto) || ip_ct_log_invalid == IPPROTO_RAW) \ && net_ratelimit()) #endif +#else +#define LOG_INVALID(proto) 0 +#endif /* CONFIG_SYSCTL */ #endif /*_IP_CONNTRACK_PROTOCOL_H*/ diff --git a/net/ipv4/netfilter/ip_conntrack_proto_sctp.c b/net/ipv4/netfilter/ip_conntrack_proto_sctp.c index 64755c5aed6e6..3e51036e5065f 100644 --- a/net/ipv4/netfilter/ip_conntrack_proto_sctp.c +++ b/net/ipv4/netfilter/ip_conntrack_proto_sctp.c @@ -623,8 +623,8 @@ int __init init(void) return ret; - cleanup: #ifdef CONFIG_SYSCTL + cleanup: ip_conntrack_protocol_unregister(&ip_conntrack_protocol_sctp); #endif out: diff --git a/net/ipv4/netfilter/ip_conntrack_standalone.c b/net/ipv4/netfilter/ip_conntrack_standalone.c index ceff26dbff471..f4c3899771c40 100644 --- a/net/ipv4/netfilter/ip_conntrack_standalone.c +++ b/net/ipv4/netfilter/ip_conntrack_standalone.c @@ -54,6 +54,7 @@ static int kill_proto(const struct ip_conntrack *i, void *data) *((u_int8_t *) data)); } +#ifdef CONFIG_PROC_FS static unsigned int print_tuple(char *buffer, const struct ip_conntrack_tuple *tuple, struct ip_conntrack_protocol *proto) @@ -367,6 +368,7 @@ static struct file_operations ct_cpu_seq_fops = { .llseek = seq_lseek, .release = seq_release_private, }; +#endif static unsigned int ip_confirm(unsigned int hooknum, struct sk_buff **pskb, @@ -726,10 +728,15 @@ static ctl_table ip_ct_net_table[] = { }, { .ctl_name = 0 } }; -#endif + +EXPORT_SYMBOL(ip_ct_log_invalid); +#endif /* CONFIG_SYSCTL */ + static int init_or_cleanup(int init) { +#ifdef CONFIG_PROC_FS struct proc_dir_entry *proc, *proc_exp, *proc_stat; +#endif int ret = 0; if (!init) goto cleanup; @@ -738,19 +745,20 @@ static int init_or_cleanup(int init) if (ret < 0) goto cleanup_nothing; - proc = proc_net_create("ip_conntrack", 0440, NULL); +#ifdef CONFIG_PROC_FS + proc = proc_net_fops_create("ip_conntrack", 0440, &ct_file_ops); if (!proc) goto cleanup_init; - proc->proc_fops = &ct_file_ops; - proc_exp = proc_net_create("ip_conntrack_expect", 0440, NULL); + proc_exp = proc_net_fops_create("ip_conntrack_expect", 0440, + &exp_file_ops); if (!proc_exp) goto cleanup_proc; - proc_exp->proc_fops = &exp_file_ops; proc_stat = proc_net_fops_create("ip_conntrack_stat", S_IRUGO, &ct_cpu_seq_fops); if (!proc_stat) goto cleanup_proc_exp; proc_stat->owner = THIS_MODULE; +#endif ret = nf_register_hook(&ip_conntrack_defrag_ops); if (ret < 0) { @@ -814,12 +822,14 @@ static int init_or_cleanup(int init) local_bh_enable(); nf_unregister_hook(&ip_conntrack_defrag_ops); cleanup_proc_stat: +#ifdef CONFIG_PROC_FS proc_net_remove("ip_conntrack_stat"); cleanup_proc_exp: proc_net_remove("ip_conntrack_exp"); cleanup_proc: proc_net_remove("ip_conntrack"); cleanup_init: +#endif /* CONFIG_PROC_FS */ ip_conntrack_cleanup(); cleanup_nothing: return ret; @@ -912,4 +922,3 @@ EXPORT_SYMBOL(ip_conntrack_hash); EXPORT_SYMBOL(ip_conntrack_untracked); EXPORT_SYMBOL_GPL(ip_conntrack_find_get); EXPORT_SYMBOL_GPL(ip_conntrack_put); -EXPORT_SYMBOL(ip_ct_log_invalid); diff --git a/net/ipv4/netfilter/ip_queue.c b/net/ipv4/netfilter/ip_queue.c index 906b89df2f197..26dca38f692ac 100644 --- a/net/ipv4/netfilter/ip_queue.c +++ b/net/ipv4/netfilter/ip_queue.c @@ -619,6 +619,7 @@ static ctl_table ipq_root_table[] = { { .ctl_name = 0 } }; +#ifdef CONFIG_PROC_FS static int ipq_get_info(char *buffer, char **start, off_t offset, int length) { @@ -648,6 +649,7 @@ ipq_get_info(char *buffer, char **start, off_t offset, int length) len = 0; return len; } +#endif /* CONFIG_PROC_FS */ static int init_or_cleanup(int init) -- 2.53.0