Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: nfnetlink_queue: fix compilation with CONFIG_NF_NAT=m and CONFIG_NF_CT_NETLINK=y

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>

+18 -8
+5 -1
include/linux/netfilter.h
··· 401 401 size_t (*build_size)(const struct nf_conn *ct); 402 402 int (*build)(struct sk_buff *skb, struct nf_conn *ct); 403 403 int (*parse)(const struct nlattr *attr, struct nf_conn *ct); 404 + }; 405 + extern struct nfq_ct_hook __rcu *nfq_ct_hook; 406 + 407 + struct nfq_ct_nat_hook { 404 408 void (*seq_adjust)(struct sk_buff *skb, struct nf_conn *ct, 405 409 u32 ctinfo, int off); 406 410 }; 407 - extern struct nfq_ct_hook __rcu *nfq_ct_hook; 411 + extern struct nfq_ct_nat_hook __rcu *nfq_ct_nat_hook; 408 412 #else 409 413 static inline void nf_ct_attach(struct sk_buff *new, struct sk_buff *skb) {} 410 414 #endif
+6
net/ipv4/netfilter/nf_nat_core.c
··· 691 691 .expectfn = nf_nat_follow_master, 692 692 }; 693 693 694 + static struct nfq_ct_nat_hook nfq_ct_nat = { 695 + .seq_adjust = nf_nat_tcp_seq_adjust, 696 + }; 697 + 694 698 static int __init nf_nat_init(void) 695 699 { 696 700 size_t i; ··· 735 731 nfnetlink_parse_nat_setup); 736 732 BUG_ON(nf_ct_nat_offset != NULL); 737 733 RCU_INIT_POINTER(nf_ct_nat_offset, nf_nat_get_offset); 734 + RCU_INIT_POINTER(nfq_ct_nat_hook, &nfq_ct_nat); 738 735 return 0; 739 736 740 737 cleanup_extend: ··· 752 747 RCU_INIT_POINTER(nf_nat_seq_adjust_hook, NULL); 753 748 RCU_INIT_POINTER(nfnetlink_parse_nat_setup_hook, NULL); 754 749 RCU_INIT_POINTER(nf_ct_nat_offset, NULL); 750 + RCU_INIT_POINTER(nfq_ct_nat_hook, NULL); 755 751 synchronize_net(); 756 752 } 757 753
+3
net/netfilter/core.c
··· 268 268 struct nfq_ct_hook __rcu *nfq_ct_hook __read_mostly; 269 269 EXPORT_SYMBOL_GPL(nfq_ct_hook); 270 270 271 + struct nfq_ct_nat_hook __rcu *nfq_ct_nat_hook __read_mostly; 272 + EXPORT_SYMBOL_GPL(nfq_ct_nat_hook); 273 + 271 274 #endif /* CONFIG_NF_CONNTRACK */ 272 275 273 276 #ifdef CONFIG_PROC_FS
-3
net/netfilter/nf_conntrack_netlink.c
··· 1757 1757 .build_size = ctnetlink_nfqueue_build_size, 1758 1758 .build = ctnetlink_nfqueue_build, 1759 1759 .parse = ctnetlink_nfqueue_parse, 1760 - #ifdef CONFIG_NF_NAT_NEEDED 1761 - .seq_adjust = nf_nat_tcp_seq_adjust, 1762 - #endif 1763 1760 }; 1764 1761 #endif /* CONFIG_NETFILTER_NETLINK_QUEUE_CT */ 1765 1762