Skip to content

Commit ae90bde

Browse files
KOVACS Krisztiankaber
authored andcommitted
netfilter: fix compilation when conntrack is disabled but tproxy is enabled
The IPv6 tproxy patches split IPv6 defragmentation off of conntrack, but failed to update the #ifdef stanzas guarding the defragmentation related fields and code in skbuff and conntrack related code in nf_defrag_ipv6.c. This patch adds the required #ifdefs so that IPv6 tproxy can truly be used without connection tracking. Original report: http://marc.info/?l=linux-netdev&m=129010118516341&w=2 Reported-by: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: KOVACS Krisztian <hidden@balabit.hu> Acked-by: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: Patrick McHardy <kaber@trash.net>
1 parent f1c7222 commit ae90bde

File tree

5 files changed

+34
-11
lines changed

5 files changed

+34
-11
lines changed

include/linux/skbuff.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,11 @@ typedef unsigned int sk_buff_data_t;
255255
typedef unsigned char *sk_buff_data_t;
256256
#endif
257257

258+
#if defined(CONFIG_NF_DEFRAG_IPV4) || defined(CONFIG_NF_DEFRAG_IPV4_MODULE) || \
259+
defined(CONFIG_NF_DEFRAG_IPV6) || defined(CONFIG_NF_DEFRAG_IPV6_MODULE)
260+
#define NET_SKBUFF_NF_DEFRAG_NEEDED 1
261+
#endif
262+
258263
/**
259264
* struct sk_buff - socket buffer
260265
* @next: Next buffer in list
@@ -362,6 +367,8 @@ struct sk_buff {
362367
void (*destructor)(struct sk_buff *skb);
363368
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
364369
struct nf_conntrack *nfct;
370+
#endif
371+
#ifdef NET_SKBUFF_NF_DEFRAG_NEEDED
365372
struct sk_buff *nfct_reasm;
366373
#endif
367374
#ifdef CONFIG_BRIDGE_NETFILTER
@@ -2051,6 +2058,8 @@ static inline void nf_conntrack_get(struct nf_conntrack *nfct)
20512058
if (nfct)
20522059
atomic_inc(&nfct->use);
20532060
}
2061+
#endif
2062+
#ifdef NET_SKBUFF_NF_DEFRAG_NEEDED
20542063
static inline void nf_conntrack_get_reasm(struct sk_buff *skb)
20552064
{
20562065
if (skb)
@@ -2079,6 +2088,8 @@ static inline void nf_reset(struct sk_buff *skb)
20792088
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
20802089
nf_conntrack_put(skb->nfct);
20812090
skb->nfct = NULL;
2091+
#endif
2092+
#ifdef NET_SKBUFF_NF_DEFRAG_NEEDED
20822093
nf_conntrack_put_reasm(skb->nfct_reasm);
20832094
skb->nfct_reasm = NULL;
20842095
#endif
@@ -2095,6 +2106,8 @@ static inline void __nf_copy(struct sk_buff *dst, const struct sk_buff *src)
20952106
dst->nfct = src->nfct;
20962107
nf_conntrack_get(src->nfct);
20972108
dst->nfctinfo = src->nfctinfo;
2109+
#endif
2110+
#ifdef NET_SKBUFF_NF_DEFRAG_NEEDED
20982111
dst->nfct_reasm = src->nfct_reasm;
20992112
nf_conntrack_get_reasm(src->nfct_reasm);
21002113
#endif
@@ -2108,6 +2121,8 @@ static inline void nf_copy(struct sk_buff *dst, const struct sk_buff *src)
21082121
{
21092122
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
21102123
nf_conntrack_put(dst->nfct);
2124+
#endif
2125+
#ifdef NET_SKBUFF_NF_DEFRAG_NEEDED
21112126
nf_conntrack_put_reasm(dst->nfct_reasm);
21122127
#endif
21132128
#ifdef CONFIG_BRIDGE_NETFILTER

include/net/netfilter/ipv6/nf_conntrack_ipv6.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,6 @@ extern struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp6;
77
extern struct nf_conntrack_l4proto nf_conntrack_l4proto_udp6;
88
extern struct nf_conntrack_l4proto nf_conntrack_l4proto_icmpv6;
99

10-
extern int nf_ct_frag6_init(void);
11-
extern void nf_ct_frag6_cleanup(void);
12-
extern struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb, u32 user);
13-
extern void nf_ct_frag6_output(unsigned int hooknum, struct sk_buff *skb,
14-
struct net_device *in,
15-
struct net_device *out,
16-
int (*okfn)(struct sk_buff *));
17-
18-
struct inet_frags_ctl;
19-
2010
#include <linux/sysctl.h>
2111
extern struct ctl_table nf_ct_ipv6_sysctl_table[];
2212

include/net/netfilter/ipv6/nf_defrag_ipv6.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,14 @@
33

44
extern void nf_defrag_ipv6_enable(void);
55

6+
extern int nf_ct_frag6_init(void);
7+
extern void nf_ct_frag6_cleanup(void);
8+
extern struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb, u32 user);
9+
extern void nf_ct_frag6_output(unsigned int hooknum, struct sk_buff *skb,
10+
struct net_device *in,
11+
struct net_device *out,
12+
int (*okfn)(struct sk_buff *));
13+
14+
struct inet_frags_ctl;
15+
616
#endif /* _NF_DEFRAG_IPV6_H */

net/core/skbuff.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ static void skb_release_head_state(struct sk_buff *skb)
380380
}
381381
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
382382
nf_conntrack_put(skb->nfct);
383+
#endif
384+
#ifdef NET_SKBUFF_NF_DEFRAG_NEEDED
383385
nf_conntrack_put_reasm(skb->nfct_reasm);
384386
#endif
385387
#ifdef CONFIG_BRIDGE_NETFILTER

net/ipv6/netfilter/nf_defrag_ipv6_hooks.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,26 @@
1919

2020
#include <linux/netfilter_ipv6.h>
2121
#include <linux/netfilter_bridge.h>
22+
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
2223
#include <net/netfilter/nf_conntrack.h>
2324
#include <net/netfilter/nf_conntrack_helper.h>
2425
#include <net/netfilter/nf_conntrack_l4proto.h>
2526
#include <net/netfilter/nf_conntrack_l3proto.h>
2627
#include <net/netfilter/nf_conntrack_core.h>
27-
#include <net/netfilter/nf_conntrack_zones.h>
2828
#include <net/netfilter/ipv6/nf_conntrack_ipv6.h>
29+
#endif
30+
#include <net/netfilter/nf_conntrack_zones.h>
2931
#include <net/netfilter/ipv6/nf_defrag_ipv6.h>
3032

3133
static enum ip6_defrag_users nf_ct6_defrag_user(unsigned int hooknum,
3234
struct sk_buff *skb)
3335
{
3436
u16 zone = NF_CT_DEFAULT_ZONE;
3537

38+
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
3639
if (skb->nfct)
3740
zone = nf_ct_zone((struct nf_conn *)skb->nfct);
41+
#endif
3842

3943
#ifdef CONFIG_BRIDGE_NETFILTER
4044
if (skb->nf_bridge &&
@@ -56,9 +60,11 @@ static unsigned int ipv6_defrag(unsigned int hooknum,
5660
{
5761
struct sk_buff *reasm;
5862

63+
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
5964
/* Previously seen (loopback)? */
6065
if (skb->nfct && !nf_ct_is_template((struct nf_conn *)skb->nfct))
6166
return NF_ACCEPT;
67+
#endif
6268

6369
reasm = nf_ct_frag6_gather(skb, nf_ct6_defrag_user(hooknum, skb));
6470
/* queued */

0 commit comments

Comments
 (0)