Skip to content

Commit 78458e3

Browse files
a3a3elummakynes
authored andcommitted
netfilter: add missing IS_ENABLED(CONFIG_NETFILTER) checks to some header-files.
linux/netfilter.h defines a number of struct and inline function definitions which are only available is CONFIG_NETFILTER is enabled. These structs and functions are used in declarations and definitions in other header-files. Added preprocessor checks to make sure these headers will compile if CONFIG_NETFILTER is disabled. Signed-off-by: Jeremy Sowden <jeremy@azazel.net> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 0abc8bf commit 78458e3

15 files changed

Lines changed: 52 additions & 0 deletions

File tree

‎include/linux/netfilter/x_tables.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,15 @@ struct xt_action_param {
3535
union {
3636
const void *matchinfo, *targinfo;
3737
};
38+
#if IS_ENABLED(CONFIG_NETFILTER)
3839
const struct nf_hook_state *state;
40+
#endif
3941
int fragoff;
4042
unsigned int thoff;
4143
bool hotdrop;
4244
};
4345

46+
#if IS_ENABLED(CONFIG_NETFILTER)
4447
static inline struct net *xt_net(const struct xt_action_param *par)
4548
{
4649
return par->state->net;
@@ -75,6 +78,7 @@ static inline u_int8_t xt_family(const struct xt_action_param *par)
7578
{
7679
return par->state->pf;
7780
}
81+
#endif
7882

7983
/**
8084
* struct xt_mtchk_param - parameters for match extensions'
@@ -446,7 +450,9 @@ xt_get_per_cpu_counter(struct xt_counters *cnt, unsigned int cpu)
446450
return cnt;
447451
}
448452

453+
#if IS_ENABLED(CONFIG_NETFILTER)
449454
struct nf_hook_ops *xt_hook_ops_alloc(const struct xt_table *, nf_hookfn *);
455+
#endif
450456

451457
#ifdef CONFIG_COMPAT
452458
#include <net/compat.h>

‎include/linux/netfilter_arp/arp_tables.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ struct arpt_error {
4949
}
5050

5151
extern void *arpt_alloc_initial_table(const struct xt_table *);
52+
#if IS_ENABLED(CONFIG_NETFILTER)
5253
int arpt_register_table(struct net *net, const struct xt_table *table,
5354
const struct arpt_replace *repl,
5455
const struct nf_hook_ops *ops, struct xt_table **res);
@@ -57,6 +58,7 @@ void arpt_unregister_table(struct net *net, struct xt_table *table,
5758
extern unsigned int arpt_do_table(struct sk_buff *skb,
5859
const struct nf_hook_state *state,
5960
struct xt_table *table);
61+
#endif
6062

6163
#ifdef CONFIG_COMPAT
6264
#include <net/compat.h>

‎include/linux/netfilter_bridge/ebtables.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ struct ebt_table {
105105

106106
#define EBT_ALIGN(s) (((s) + (__alignof__(struct _xt_align)-1)) & \
107107
~(__alignof__(struct _xt_align)-1))
108+
#if IS_ENABLED(CONFIG_NETFILTER)
108109
extern int ebt_register_table(struct net *net,
109110
const struct ebt_table *table,
110111
const struct nf_hook_ops *ops,
@@ -114,6 +115,7 @@ extern void ebt_unregister_table(struct net *net, struct ebt_table *table,
114115
extern unsigned int ebt_do_table(struct sk_buff *skb,
115116
const struct nf_hook_state *state,
116117
struct ebt_table *table);
118+
#endif
117119

118120
/* True if the hook mask denotes that the rule is in a base chain,
119121
* used in the check() functions */

‎include/linux/netfilter_ipv4/ip_tables.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@
2525

2626
extern void ipt_init(void) __init;
2727

28+
#if IS_ENABLED(CONFIG_NETFILTER)
2829
int ipt_register_table(struct net *net, const struct xt_table *table,
2930
const struct ipt_replace *repl,
3031
const struct nf_hook_ops *ops, struct xt_table **res);
3132
void ipt_unregister_table(struct net *net, struct xt_table *table,
3233
const struct nf_hook_ops *ops);
34+
#endif
3335

3436
/* Standard entry. */
3537
struct ipt_standard {
@@ -65,9 +67,11 @@ struct ipt_error {
6567
}
6668

6769
extern void *ipt_alloc_initial_table(const struct xt_table *);
70+
#if IS_ENABLED(CONFIG_NETFILTER)
6871
extern unsigned int ipt_do_table(struct sk_buff *skb,
6972
const struct nf_hook_state *state,
7073
struct xt_table *table);
74+
#endif
7175

7276
#ifdef CONFIG_COMPAT
7377
#include <net/compat.h>

‎include/linux/netfilter_ipv6/ip6_tables.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
extern void ip6t_init(void) __init;
2727

2828
extern void *ip6t_alloc_initial_table(const struct xt_table *);
29+
#if IS_ENABLED(CONFIG_NETFILTER)
2930
int ip6t_register_table(struct net *net, const struct xt_table *table,
3031
const struct ip6t_replace *repl,
3132
const struct nf_hook_ops *ops, struct xt_table **res);
@@ -34,6 +35,7 @@ void ip6t_unregister_table(struct net *net, struct xt_table *table,
3435
extern unsigned int ip6t_do_table(struct sk_buff *skb,
3536
const struct nf_hook_state *state,
3637
struct xt_table *table);
38+
#endif
3739

3840
/* Check for an extension */
3941
static inline int

‎include/net/netfilter/br_netfilter.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ static inline struct rtable *bridge_parent_rtable(const struct net_device *dev)
5555
struct net_device *setup_pre_routing(struct sk_buff *skb,
5656
const struct net *net);
5757

58+
#if IS_ENABLED(CONFIG_NETFILTER)
5859
#if IS_ENABLED(CONFIG_IPV6)
5960
int br_validate_ipv6(struct net *net, struct sk_buff *skb);
6061
unsigned int br_nf_pre_routing_ipv6(void *priv,
@@ -73,5 +74,6 @@ br_nf_pre_routing_ipv6(const struct nf_hook_ops *ops, struct sk_buff *skb,
7374
return NF_ACCEPT;
7475
}
7576
#endif
77+
#endif
7678

7779
#endif /* _BR_NETFILTER_H_ */

‎include/net/netfilter/nf_conntrack_bridge.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
#include <uapi/linux/if_ether.h>
77

88
struct nf_ct_bridge_info {
9+
#if IS_ENABLED(CONFIG_NETFILTER)
910
struct nf_hook_ops *ops;
11+
#endif
1012
unsigned int ops_size;
1113
struct module *me;
1214
};

‎include/net/netfilter/nf_conntrack_core.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
/* This header is used to share core functionality between the
2121
standalone connection tracking module, and the compatibility layer's use
2222
of connection tracking. */
23+
24+
#if IS_ENABLED(CONFIG_NETFILTER)
2325
unsigned int nf_conntrack_in(struct sk_buff *skb, const struct nf_hook_state *state);
26+
#endif
2427

2528
int nf_conntrack_init_net(struct net *net);
2629
void nf_conntrack_cleanup_net(struct net *net);

‎include/net/netfilter/nf_conntrack_l4proto.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ bool nf_conntrack_invert_icmp_tuple(struct nf_conntrack_tuple *tuple,
7575
bool nf_conntrack_invert_icmpv6_tuple(struct nf_conntrack_tuple *tuple,
7676
const struct nf_conntrack_tuple *orig);
7777

78+
#if IS_ENABLED(CONFIG_NETFILTER)
7879
int nf_conntrack_inet_error(struct nf_conn *tmpl, struct sk_buff *skb,
7980
unsigned int dataoff,
8081
const struct nf_hook_state *state,
@@ -131,6 +132,7 @@ int nf_conntrack_gre_packet(struct nf_conn *ct,
131132
unsigned int dataoff,
132133
enum ip_conntrack_info ctinfo,
133134
const struct nf_hook_state *state);
135+
#endif
134136

135137
void nf_conntrack_generic_init_net(struct net *net);
136138
void nf_conntrack_tcp_init_net(struct net *net);

‎include/net/netfilter/nf_conntrack_tuple.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ struct nf_conntrack_tuple_hash {
121121
struct nf_conntrack_tuple tuple;
122122
};
123123

124+
#if IS_ENABLED(CONFIG_NETFILTER)
124125
static inline bool __nf_ct_tuple_src_equal(const struct nf_conntrack_tuple *t1,
125126
const struct nf_conntrack_tuple *t2)
126127
{
@@ -183,5 +184,6 @@ nf_ct_tuple_mask_cmp(const struct nf_conntrack_tuple *t,
183184
return nf_ct_tuple_src_mask_cmp(t, tuple, mask) &&
184185
__nf_ct_tuple_dst_equal(t, tuple);
185186
}
187+
#endif
186188

187189
#endif /* _NF_CONNTRACK_TUPLE_H */

0 commit comments

Comments
 (0)