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

netfilter: nf_defrag_ipv4: fix compilation error with NF_CONNTRACK=n

As reported by Randy Dunlap <randy.dunlap@oracle.com>, compilation
of nf_defrag_ipv4 fails with:

include/net/netfilter/nf_conntrack.h:94: error: field 'ct_general' has incomplete type
include/net/netfilter/nf_conntrack.h:178: error: 'const struct sk_buff' has no member named 'nfct'
include/net/netfilter/nf_conntrack.h:185: error: implicit declaration of function 'nf_conntrack_put'
include/net/netfilter/nf_conntrack.h:294: error: 'const struct sk_buff' has no member named 'nfct'
net/ipv4/netfilter/nf_defrag_ipv4.c:45: error: 'struct sk_buff' has no member named 'nfct'
net/ipv4/netfilter/nf_defrag_ipv4.c:46: error: 'struct sk_buff' has no member named 'nfct'

net/nf_conntrack.h must not be included with NF_CONNTRACK=n, add a
few #ifdefs. Long term the header file should be fixed to be usable
even with NF_CONNTRACK=n.

Tested-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>

+9 -3
+4 -2
include/net/netfilter/nf_conntrack_zones.h
··· 1 1 #ifndef _NF_CONNTRACK_ZONES_H 2 2 #define _NF_CONNTRACK_ZONES_H 3 3 4 - #include <net/netfilter/nf_conntrack_extend.h> 5 - 6 4 #define NF_CT_DEFAULT_ZONE 0 5 + 6 + #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) 7 + #include <net/netfilter/nf_conntrack_extend.h> 7 8 8 9 struct nf_conntrack_zone { 9 10 u16 id; ··· 21 20 return NF_CT_DEFAULT_ZONE; 22 21 } 23 22 23 + #endif /* CONFIG_NF_CONNTRACK || CONFIG_NF_CONNTRACK_MODULE */ 24 24 #endif /* _NF_CONNTRACK_ZONES_H */
+5 -1
net/ipv4/netfilter/nf_defrag_ipv4.c
··· 16 16 17 17 #include <linux/netfilter_bridge.h> 18 18 #include <linux/netfilter_ipv4.h> 19 - #include <net/netfilter/nf_conntrack_zones.h> 20 19 #include <net/netfilter/ipv4/nf_defrag_ipv4.h> 20 + #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) 21 21 #include <net/netfilter/nf_conntrack.h> 22 + #endif 23 + #include <net/netfilter/nf_conntrack_zones.h> 22 24 23 25 /* Returns new sk_buff, or NULL */ 24 26 static int nf_ct_ipv4_gather_frags(struct sk_buff *skb, u_int32_t user) ··· 44 42 { 45 43 u16 zone = NF_CT_DEFAULT_ZONE; 46 44 45 + #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) 47 46 if (skb->nfct) 48 47 zone = nf_ct_zone((struct nf_conn *)skb->nfct); 48 + #endif 49 49 50 50 #ifdef CONFIG_BRIDGE_NETFILTER 51 51 if (skb->nf_bridge &&