Skip to content

Commit 0abc8bf

Browse files
a3a3elummakynes
authored andcommitted
netfilter: add missing IS_ENABLED(CONFIG_NF_CONNTRACK) checks to some header-files.
struct nf_conn contains a "struct nf_conntrack ct_general" member and struct net contains a "struct netns_ct ct" member which are both only defined in CONFIG_NF_CONNTRACK is enabled. These members are used in a number of inline functions defined in other header-files. Added preprocessor checks to make sure the headers will compile if CONFIG_NF_CONNTRACK is disabled. Signed-off-by: Jeremy Sowden <jeremy@azazel.net> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 47e640a commit 0abc8bf

4 files changed

Lines changed: 31 additions & 0 deletions

File tree

‎include/net/netfilter/nf_conntrack.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ struct nf_conntrack_net {
5959
#include <net/netfilter/ipv6/nf_conntrack_ipv6.h>
6060

6161
struct nf_conn {
62+
#if IS_ENABLED(CONFIG_NF_CONNTRACK)
6263
/* Usage count in here is 1 for hash table, 1 per skb,
6364
* plus 1 for any connection(s) we are `master' for
6465
*
@@ -68,6 +69,7 @@ struct nf_conn {
6869
* beware nf_ct_get() is different and don't inc refcnt.
6970
*/
7071
struct nf_conntrack ct_general;
72+
#endif
7173

7274
spinlock_t lock;
7375
/* jiffies32 when this ct is considered dead */
@@ -148,6 +150,8 @@ void nf_conntrack_alter_reply(struct nf_conn *ct,
148150
int nf_conntrack_tuple_taken(const struct nf_conntrack_tuple *tuple,
149151
const struct nf_conn *ignored_conntrack);
150152

153+
#if IS_ENABLED(CONFIG_NF_CONNTRACK)
154+
151155
#define NFCT_INFOMASK 7UL
152156
#define NFCT_PTRMASK ~(NFCT_INFOMASK)
153157

@@ -167,6 +171,8 @@ static inline void nf_ct_put(struct nf_conn *ct)
167171
nf_conntrack_put(&ct->ct_general);
168172
}
169173

174+
#endif
175+
170176
/* Protocol module loading */
171177
int nf_ct_l3proto_try_module_get(unsigned short l3proto);
172178
void nf_ct_l3proto_module_put(unsigned short l3proto);
@@ -318,12 +324,16 @@ void nf_ct_tmpl_free(struct nf_conn *tmpl);
318324

319325
u32 nf_ct_get_id(const struct nf_conn *ct);
320326

327+
#if IS_ENABLED(CONFIG_NF_CONNTRACK)
328+
321329
static inline void
322330
nf_ct_set(struct sk_buff *skb, struct nf_conn *ct, enum ip_conntrack_info info)
323331
{
324332
skb->_nfct = (unsigned long)ct | info;
325333
}
326334

335+
#endif
336+
327337
#define NF_CT_STAT_INC(net, count) __this_cpu_inc((net)->ct.stat->count)
328338
#define NF_CT_STAT_INC_ATOMIC(net, count) this_cpu_inc((net)->ct.stat->count)
329339
#define NF_CT_STAT_ADD_ATOMIC(net, count, v) this_cpu_add((net)->ct.stat->count, (v))

‎include/net/netfilter/nf_conntrack_acct.h‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ struct nf_conn_acct *nf_conn_acct_find(const struct nf_conn *ct)
2929
static inline
3030
struct nf_conn_acct *nf_ct_acct_ext_add(struct nf_conn *ct, gfp_t gfp)
3131
{
32+
#if IS_ENABLED(CONFIG_NF_CONNTRACK)
3233
struct net *net = nf_ct_net(ct);
3334
struct nf_conn_acct *acct;
3435

@@ -41,22 +42,34 @@ struct nf_conn_acct *nf_ct_acct_ext_add(struct nf_conn *ct, gfp_t gfp)
4142

4243

4344
return acct;
45+
#else
46+
return NULL;
47+
#endif
4448
};
4549

4650
/* Check if connection tracking accounting is enabled */
4751
static inline bool nf_ct_acct_enabled(struct net *net)
4852
{
53+
#if IS_ENABLED(CONFIG_NF_CONNTRACK)
4954
return net->ct.sysctl_acct != 0;
55+
#else
56+
return false;
57+
#endif
5058
}
5159

5260
/* Enable/disable connection tracking accounting */
5361
static inline void nf_ct_set_acct(struct net *net, bool enable)
5462
{
63+
#if IS_ENABLED(CONFIG_NF_CONNTRACK)
5564
net->ct.sysctl_acct = enable;
65+
#endif
5666
}
5767

68+
#if IS_ENABLED(CONFIG_NF_CONNTRACK)
5869
void nf_conntrack_acct_pernet_init(struct net *net);
5970

6071
int nf_conntrack_acct_init(void);
6172
void nf_conntrack_acct_fini(void);
73+
#endif /* IS_ENABLED(CONFIG_NF_CONNTRACK) */
74+
6275
#endif /* _NF_CONNTRACK_ACCT_H */

‎include/net/netfilter/nf_conntrack_l4proto.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ void nf_ct_l4proto_log_invalid(const struct sk_buff *skb,
176176
const char *fmt, ...) { }
177177
#endif /* CONFIG_SYSCTL */
178178

179+
#if IS_ENABLED(CONFIG_NF_CONNTRACK)
179180
static inline struct nf_generic_net *nf_generic_pernet(struct net *net)
180181
{
181182
return &net->ct.nf_ct_proto.generic;
@@ -200,6 +201,7 @@ static inline struct nf_icmp_net *nf_icmpv6_pernet(struct net *net)
200201
{
201202
return &net->ct.nf_ct_proto.icmpv6;
202203
}
204+
#endif
203205

204206
#ifdef CONFIG_NF_CT_PROTO_DCCP
205207
static inline struct nf_dccp_net *nf_dccp_pernet(struct net *net)

‎include/net/netfilter/nf_conntrack_timestamp.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,18 @@ struct nf_conn_tstamp *nf_ct_tstamp_ext_add(struct nf_conn *ct, gfp_t gfp)
4040

4141
static inline bool nf_ct_tstamp_enabled(struct net *net)
4242
{
43+
#if IS_ENABLED(CONFIG_NF_CONNTRACK)
4344
return net->ct.sysctl_tstamp != 0;
45+
#else
46+
return false;
47+
#endif
4448
}
4549

4650
static inline void nf_ct_set_tstamp(struct net *net, bool enable)
4751
{
52+
#if IS_ENABLED(CONFIG_NF_CONNTRACK)
4853
net->ct.sysctl_tstamp = enable;
54+
#endif
4955
}
5056

5157
#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP

0 commit comments

Comments
 (0)