netfilter: nfnetlink_queue: fix compilation with CONFIG_NF_NAT=m and CONFIG_NF_CT_NET...
authorPablo Neira Ayuso <pablo@netfilter.org>
Wed, 20 Jun 2012 18:52:31 +0000 (20:52 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 22 Jun 2012 00:49:52 +0000 (02:49 +0200)
  LD      init/built-in.o
net/built-in.o:(.data+0x4408): undefined reference to `nf_nat_tcp_seq_adjust'
make: *** [vmlinux] Error 1

This patch adds a new pointer hook (nfq_ct_nat_hook) similar to other existing
in Netfilter to solve our complicated configuration dependencies.

Reported-by: Valdis Kletnieks <valdis.kletnieks@vt.edu>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/linux/netfilter.h
net/ipv4/netfilter/nf_nat_core.c
net/netfilter/core.c
net/netfilter/nf_conntrack_netlink.c
net/netfilter/nfnetlink_queue_ct.c

index 38b96a54f9a592d546cd20265ab73d9d8c6a31e5..c613cf0d7884f8d3f4cf85c188a17c04f8f5e054 100644 (file)
@@ -401,10 +401,14 @@ struct nfq_ct_hook {
        size_t (*build_size)(const struct nf_conn *ct);
        int (*build)(struct sk_buff *skb, struct nf_conn *ct);
        int (*parse)(const struct nlattr *attr, struct nf_conn *ct);
+};
+extern struct nfq_ct_hook __rcu *nfq_ct_hook;
+
+struct nfq_ct_nat_hook {
        void (*seq_adjust)(struct sk_buff *skb, struct nf_conn *ct,
                           u32 ctinfo, int off);
 };
-extern struct nfq_ct_hook __rcu *nfq_ct_hook;
+extern struct nfq_ct_nat_hook __rcu *nfq_ct_nat_hook;
 #else
 static inline void nf_ct_attach(struct sk_buff *new, struct sk_buff *skb) {}
 #endif
index abb52adf5acdfdda9f816cb4e336ad9137452396..44b082fd48abd214b4365a964b44076c164c7148 100644 (file)
@@ -691,6 +691,10 @@ static struct nf_ct_helper_expectfn follow_master_nat = {
        .expectfn       = nf_nat_follow_master,
 };
 
+static struct nfq_ct_nat_hook nfq_ct_nat = {
+       .seq_adjust     = nf_nat_tcp_seq_adjust,
+};
+
 static int __init nf_nat_init(void)
 {
        size_t i;
@@ -731,6 +735,7 @@ static int __init nf_nat_init(void)
                           nfnetlink_parse_nat_setup);
        BUG_ON(nf_ct_nat_offset != NULL);
        RCU_INIT_POINTER(nf_ct_nat_offset, nf_nat_get_offset);
+       RCU_INIT_POINTER(nfq_ct_nat_hook, &nfq_ct_nat);
        return 0;
 
  cleanup_extend:
@@ -747,6 +752,7 @@ static void __exit nf_nat_cleanup(void)
        RCU_INIT_POINTER(nf_nat_seq_adjust_hook, NULL);
        RCU_INIT_POINTER(nfnetlink_parse_nat_setup_hook, NULL);
        RCU_INIT_POINTER(nf_ct_nat_offset, NULL);
+       RCU_INIT_POINTER(nfq_ct_nat_hook, NULL);
        synchronize_net();
 }
 
index 4cd10ed2d6e685bc1d2fde55f7f676241240c423..0bc6b60db4df2fda1a7cd2f1b57747f655d046a3 100644 (file)
@@ -268,6 +268,9 @@ EXPORT_SYMBOL(nf_conntrack_destroy);
 struct nfq_ct_hook __rcu *nfq_ct_hook __read_mostly;
 EXPORT_SYMBOL_GPL(nfq_ct_hook);
 
+struct nfq_ct_nat_hook __rcu *nfq_ct_nat_hook __read_mostly;
+EXPORT_SYMBOL_GPL(nfq_ct_nat_hook);
+
 #endif /* CONFIG_NF_CONNTRACK */
 
 #ifdef CONFIG_PROC_FS
index 31d1d8f3a6ce4a7eaf47a6c8b4e093480e308d90..8bb47339b7708fc10e58568228bd6b2458e5da83 100644 (file)
@@ -1757,9 +1757,6 @@ static struct nfq_ct_hook ctnetlink_nfqueue_hook = {
        .build_size     = ctnetlink_nfqueue_build_size,
        .build          = ctnetlink_nfqueue_build,
        .parse          = ctnetlink_nfqueue_parse,
-#ifdef CONFIG_NF_NAT_NEEDED
-       .seq_adjust     = nf_nat_tcp_seq_adjust,
-#endif
 };
 #endif /* CONFIG_NETFILTER_NETLINK_QUEUE_CT */
 
index 68ef550066f5e0a6d9c4c361b2e797e2a51109ad..01247b730e664bf0c0cc9178175f7c78c7514197 100644 (file)
@@ -86,12 +86,12 @@ nla_put_failure:
 void nfqnl_ct_seq_adjust(struct sk_buff *skb, struct nf_conn *ct,
                         enum ip_conntrack_info ctinfo, int diff)
 {
-       struct nfq_ct_hook *nfq_ct;
+       struct nfq_ct_nat_hook *nfq_nat_ct;
 
-       nfq_ct = rcu_dereference(nfq_ct_hook);
-       if (nfq_ct == NULL)
+       nfq_nat_ct = rcu_dereference(nfq_ct_nat_hook);
+       if (nfq_nat_ct == NULL)
                return;
 
        if ((ct->status & IPS_NAT_MASK) && diff)
-               nfq_ct->seq_adjust(skb, ct, ctinfo, diff);
+               nfq_nat_ct->seq_adjust(skb, ct, ctinfo, diff);
 }