Blame view

include/linux/netfilter.h 11.7 KB
b24413180   Greg Kroah-Hartman   License cleanup: ...
1
  /* SPDX-License-Identifier: GPL-2.0 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
3
  #ifndef __LINUX_NETFILTER_H
  #define __LINUX_NETFILTER_H
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
4
  #include <linux/init.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
5
6
7
  #include <linux/skbuff.h>
  #include <linux/net.h>
  #include <linux/if.h>
2e3075a2c   Jan Engelhardt   [NETFILTER]: Exte...
8
9
  #include <linux/in.h>
  #include <linux/in6.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
10
11
  #include <linux/wait.h>
  #include <linux/list.h>
d1c85c2eb   Zhouyi Zhou   netfilter: HAVE_J...
12
  #include <linux/static_key.h>
a263653ed   Pablo Neira Ayuso   netfilter: don't ...
13
  #include <linux/netfilter_defs.h>
085db2c04   Eric W. Biederman   netfilter: Per ne...
14
15
  #include <linux/netdevice.h>
  #include <net/net_namespace.h>
a263653ed   Pablo Neira Ayuso   netfilter: don't ...
16

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
17
  #ifdef CONFIG_NETFILTER
f615df76e   Florian Westphal   netfilter: reduce...
18
19
20
21
  static inline int NF_DROP_GETERR(int verdict)
  {
  	return -(verdict >> NF_VERDICT_QBITS);
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
22

b8beedd25   Patrick McHardy   [NETFILTER]: Add ...
23
24
25
26
27
28
29
30
  static inline int nf_inet_addr_cmp(const union nf_inet_addr *a1,
  				   const union nf_inet_addr *a2)
  {
  	return a1->all[0] == a2->all[0] &&
  	       a1->all[1] == a2->all[1] &&
  	       a1->all[2] == a2->all[2] &&
  	       a1->all[3] == a2->all[3];
  }
efdedd542   Denys Fedoryshchenko   netfilter: xt_rec...
31
32
33
34
35
36
37
38
39
  static inline void nf_inet_addr_mask(const union nf_inet_addr *a1,
  				     union nf_inet_addr *result,
  				     const union nf_inet_addr *mask)
  {
  	result->all[0] = a1->all[0] & mask->all[0];
  	result->all[1] = a1->all[1] & mask->all[1];
  	result->all[2] = a1->all[2] & mask->all[2];
  	result->all[3] = a1->all[3] & mask->all[3];
  }
a0f4ecf34   Joe Perches   netfilter: Remove...
40
  int netfilter_init(void);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
41

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
42
  struct sk_buff;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
43

795aa6ef6   Patrick McHardy   netfilter: pass h...
44
  struct nf_hook_ops;
cfdfab314   David S. Miller   netfilter: Create...
45

1c984f8a5   David Miller   netfilter: Add so...
46
  struct sock;
cfdfab314   David S. Miller   netfilter: Create...
47
48
  struct nf_hook_state {
  	unsigned int hook;
cfdfab314   David S. Miller   netfilter: Create...
49
50
51
  	u_int8_t pf;
  	struct net_device *in;
  	struct net_device *out;
1c984f8a5   David Miller   netfilter: Add so...
52
  	struct sock *sk;
b11b1f652   Eric W. Biederman   netfilter: Store ...
53
  	struct net *net;
0c4b51f00   Eric W. Biederman   netfilter: Pass n...
54
  	int (*okfn)(struct net *, struct sock *, struct sk_buff *);
cfdfab314   David S. Miller   netfilter: Create...
55
  };
e3b37f11e   Aaron Conole   netfilter: replac...
56
57
58
59
  typedef unsigned int nf_hookfn(void *priv,
  			       struct sk_buff *skb,
  			       const struct nf_hook_state *state);
  struct nf_hook_ops {
e3b37f11e   Aaron Conole   netfilter: replac...
60
61
62
63
64
65
66
67
68
69
70
  	/* User fills in from here down. */
  	nf_hookfn		*hook;
  	struct net_device	*dev;
  	void			*priv;
  	u_int8_t		pf;
  	unsigned int		hooknum;
  	/* Hooks are ordered in ascending priority. */
  	int			priority;
  };
  
  struct nf_hook_entry {
d415b9eb7   Aaron Conole   netfilter: decoup...
71
72
  	nf_hookfn			*hook;
  	void				*priv;
e3b37f11e   Aaron Conole   netfilter: replac...
73
  };
960632ece   Aaron Conole   netfilter: conver...
74
75
76
77
78
79
80
81
82
83
84
85
86
  struct nf_hook_entries {
  	u16				num_hook_entries;
  	/* padding */
  	struct nf_hook_entry		hooks[];
  
  	/* trailer: pointers to original orig_ops of each hook.
  	 *
  	 * This is not part of struct nf_hook_entry since its only
  	 * needed in slow path (hook register/unregister).
  	 *
  	 * const struct nf_hook_ops     *orig_ops[]
  	 */
  };
0aa8c57a0   Aaron Conole   netfilter: introd...
87

960632ece   Aaron Conole   netfilter: conver...
88
  static inline struct nf_hook_ops **nf_hook_entries_get_hook_ops(const struct nf_hook_entries *e)
0aa8c57a0   Aaron Conole   netfilter: introd...
89
  {
960632ece   Aaron Conole   netfilter: conver...
90
91
92
93
94
95
  	unsigned int n = e->num_hook_entries;
  	const void *hook_end;
  
  	hook_end = &e->hooks[n]; /* this is *past* ->hooks[]! */
  
  	return (struct nf_hook_ops **)hook_end;
0aa8c57a0   Aaron Conole   netfilter: introd...
96
97
98
99
100
101
  }
  
  static inline int
  nf_hook_entry_hookfn(const struct nf_hook_entry *entry, struct sk_buff *skb,
  		     struct nf_hook_state *state)
  {
d415b9eb7   Aaron Conole   netfilter: decoup...
102
  	return entry->hook(entry->priv, skb, state);
0aa8c57a0   Aaron Conole   netfilter: introd...
103
  }
107a9f4dc   David Miller   netfilter: Add nf...
104
105
  static inline void nf_hook_state_init(struct nf_hook_state *p,
  				      unsigned int hook,
1610a73c4   Pablo Neira Ayuso   netfilter: kill N...
106
  				      u_int8_t pf,
107a9f4dc   David Miller   netfilter: Add nf...
107
108
  				      struct net_device *indev,
  				      struct net_device *outdev,
1c984f8a5   David Miller   netfilter: Add so...
109
  				      struct sock *sk,
b11b1f652   Eric W. Biederman   netfilter: Store ...
110
  				      struct net *net,
0c4b51f00   Eric W. Biederman   netfilter: Pass n...
111
  				      int (*okfn)(struct net *, struct sock *, struct sk_buff *))
107a9f4dc   David Miller   netfilter: Add nf...
112
113
  {
  	p->hook = hook;
107a9f4dc   David Miller   netfilter: Add nf...
114
115
116
  	p->pf = pf;
  	p->in = indev;
  	p->out = outdev;
1c984f8a5   David Miller   netfilter: Add so...
117
  	p->sk = sk;
b11b1f652   Eric W. Biederman   netfilter: Store ...
118
  	p->net = net;
107a9f4dc   David Miller   netfilter: Add nf...
119
120
  	p->okfn = okfn;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
121

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
122

d94d9fee9   Eric Dumazet   net: cleanup incl...
123
  struct nf_sockopt_ops {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
124
  	struct list_head list;
76108cea0   Jan Engelhardt   netfilter: Use un...
125
  	u_int8_t pf;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
126
127
128
129
130
  
  	/* Non-inclusive ranges: use 0/0/NULL to never get called. */
  	int set_optmin;
  	int set_optmax;
  	int (*set)(struct sock *sk, int optval, void __user *user, unsigned int len);
c30f540b6   Alexey Dobriyan   netfilter: xtable...
131
  #ifdef CONFIG_COMPAT
3fdadf7d2   Dmitry Mishin   [NET]: {get|set}s...
132
133
  	int (*compat_set)(struct sock *sk, int optval,
  			void __user *user, unsigned int len);
c30f540b6   Alexey Dobriyan   netfilter: xtable...
134
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
135
136
137
  	int get_optmin;
  	int get_optmax;
  	int (*get)(struct sock *sk, int optval, void __user *user, int *len);
c30f540b6   Alexey Dobriyan   netfilter: xtable...
138
  #ifdef CONFIG_COMPAT
3fdadf7d2   Dmitry Mishin   [NET]: {get|set}s...
139
140
  	int (*compat_get)(struct sock *sk, int optval,
  			void __user *user, int *len);
c30f540b6   Alexey Dobriyan   netfilter: xtable...
141
  #endif
16fcec35e   Neil Horman   [NETFILTER]: Fix/...
142
143
  	/* Use the module struct to lock set/get code in place */
  	struct module *owner;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
144
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
145
  /* Function to register/unregister hook points. */
085db2c04   Eric W. Biederman   netfilter: Per ne...
146
147
148
149
150
151
  int nf_register_net_hook(struct net *net, const struct nf_hook_ops *ops);
  void nf_unregister_net_hook(struct net *net, const struct nf_hook_ops *ops);
  int nf_register_net_hooks(struct net *net, const struct nf_hook_ops *reg,
  			  unsigned int n);
  void nf_unregister_net_hooks(struct net *net, const struct nf_hook_ops *reg,
  			     unsigned int n);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
152
153
154
155
  /* Functions to register get/setsockopt ranges (non-inclusive).  You
     need to check permissions yourself! */
  int nf_register_sockopt(struct nf_sockopt_ops *reg);
  void nf_unregister_sockopt(struct nf_sockopt_ops *reg);
d1c85c2eb   Zhouyi Zhou   netfilter: HAVE_J...
156
  #ifdef HAVE_JUMP_LABEL
c5905afb0   Ingo Molnar   static keys: Intr...
157
  extern struct static_key nf_hooks_needed[NFPROTO_NUMPROTO][NF_MAX_HOOKS];
a2d7ec58a   Eric Dumazet   netfilter: use ju...
158
  #endif
01886bd91   Pablo Neira Ayuso   netfilter: remove...
159
  int nf_hook_slow(struct sk_buff *skb, struct nf_hook_state *state,
960632ece   Aaron Conole   netfilter: conver...
160
  		 const struct nf_hook_entries *e, unsigned int i);
16a6677fd   Patrick McHardy   [XFRM]: Netfilter...
161
162
  
  /**
1610a73c4   Pablo Neira Ayuso   netfilter: kill N...
163
   *	nf_hook - call a netfilter hook
b8d0aad0c   Pablo Neira   netfilter: add nf...
164
   *
16a6677fd   Patrick McHardy   [XFRM]: Netfilter...
165
166
167
168
   *	Returns 1 if the hook has allowed the packet to pass.  The function
   *	okfn must be invoked by the caller in this case.  Any other return
   *	value indicates the packet has been consumed by the hook.
   */
1610a73c4   Pablo Neira Ayuso   netfilter: kill N...
169
170
171
172
  static inline int nf_hook(u_int8_t pf, unsigned int hook, struct net *net,
  			  struct sock *sk, struct sk_buff *skb,
  			  struct net_device *indev, struct net_device *outdev,
  			  int (*okfn)(struct net *, struct sock *, struct sk_buff *))
16a6677fd   Patrick McHardy   [XFRM]: Netfilter...
173
  {
960632ece   Aaron Conole   netfilter: conver...
174
  	struct nf_hook_entries *hook_head;
e3b37f11e   Aaron Conole   netfilter: replac...
175
  	int ret = 1;
af4610c39   Florian Westphal   netfilter: don't ...
176
177
178
179
180
181
182
  
  #ifdef HAVE_JUMP_LABEL
  	if (__builtin_constant_p(pf) &&
  	    __builtin_constant_p(hook) &&
  	    !static_key_false(&nf_hooks_needed[pf][hook]))
  		return 1;
  #endif
e3b37f11e   Aaron Conole   netfilter: replac...
183
184
185
  	rcu_read_lock();
  	hook_head = rcu_dereference(net->nf.hooks[pf][hook]);
  	if (hook_head) {
107a9f4dc   David Miller   netfilter: Add nf...
186
  		struct nf_hook_state state;
cfdfab314   David S. Miller   netfilter: Create...
187

01886bd91   Pablo Neira Ayuso   netfilter: remove...
188
  		nf_hook_state_init(&state, hook, pf, indev, outdev,
1610a73c4   Pablo Neira Ayuso   netfilter: kill N...
189
  				   sk, net, okfn);
fe72926b7   Florian Westphal   netfilter: call n...
190

960632ece   Aaron Conole   netfilter: conver...
191
  		ret = nf_hook_slow(skb, &state, hook_head, 0);
cfdfab314   David S. Miller   netfilter: Create...
192
  	}
e3b37f11e   Aaron Conole   netfilter: replac...
193
194
195
  	rcu_read_unlock();
  
  	return ret;
16a6677fd   Patrick McHardy   [XFRM]: Netfilter...
196
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
  /* Activate hook; either okfn or kfree_skb called, unless a hook
     returns NF_STOLEN (in which case, it's up to the hook to deal with
     the consequences).
  
     Returns -ERRNO if packet dropped.  Zero means queued, stolen or
     accepted.
  */
  
  /* RR:
     > I don't want nf_hook to return anything because people might forget
     > about async and trust the return value to mean "packet was ok".
  
     AK:
     Just document it clearly, then you can expect some sense from kernel
     coders :)
  */
2249065f4   Jan Engelhardt   netfilter: get ri...
213
  static inline int
29a26a568   Eric W. Biederman   netfilter: Pass s...
214
  NF_HOOK_COND(uint8_t pf, unsigned int hook, struct net *net, struct sock *sk,
7026b1ddb   David Miller   netfilter: Pass s...
215
  	     struct sk_buff *skb, struct net_device *in, struct net_device *out,
0c4b51f00   Eric W. Biederman   netfilter: Pass n...
216
217
  	     int (*okfn)(struct net *, struct sock *, struct sk_buff *),
  	     bool cond)
2249065f4   Jan Engelhardt   netfilter: get ri...
218
  {
4bac6b180   Patrick McHardy   netfilter: restor...
219
220
221
  	int ret;
  
  	if (!cond ||
1610a73c4   Pablo Neira Ayuso   netfilter: kill N...
222
  	    ((ret = nf_hook(pf, hook, net, sk, skb, in, out, okfn)) == 1))
0c4b51f00   Eric W. Biederman   netfilter: Pass n...
223
  		ret = okfn(net, sk, skb);
2249065f4   Jan Engelhardt   netfilter: get ri...
224
225
  	return ret;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
226

2249065f4   Jan Engelhardt   netfilter: get ri...
227
  static inline int
29a26a568   Eric W. Biederman   netfilter: Pass s...
228
  NF_HOOK(uint8_t pf, unsigned int hook, struct net *net, struct sock *sk, struct sk_buff *skb,
2249065f4   Jan Engelhardt   netfilter: get ri...
229
  	struct net_device *in, struct net_device *out,
0c4b51f00   Eric W. Biederman   netfilter: Pass n...
230
  	int (*okfn)(struct net *, struct sock *, struct sk_buff *))
2249065f4   Jan Engelhardt   netfilter: get ri...
231
  {
1610a73c4   Pablo Neira Ayuso   netfilter: kill N...
232
233
234
235
  	int ret = nf_hook(pf, hook, net, sk, skb, in, out, okfn);
  	if (ret == 1)
  		ret = okfn(net, sk, skb);
  	return ret;
2249065f4   Jan Engelhardt   netfilter: get ri...
236
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
237
238
  
  /* Call setsockopt() */
76108cea0   Jan Engelhardt   netfilter: Use un...
239
  int nf_setsockopt(struct sock *sk, u_int8_t pf, int optval, char __user *opt,
b7058842c   David S. Miller   net: Make setsock...
240
  		  unsigned int len);
76108cea0   Jan Engelhardt   netfilter: Use un...
241
  int nf_getsockopt(struct sock *sk, u_int8_t pf, int optval, char __user *opt,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
242
  		  int *len);
c30f540b6   Alexey Dobriyan   netfilter: xtable...
243
  #ifdef CONFIG_COMPAT
76108cea0   Jan Engelhardt   netfilter: Use un...
244
  int compat_nf_setsockopt(struct sock *sk, u_int8_t pf, int optval,
b7058842c   David S. Miller   net: Make setsock...
245
  		char __user *opt, unsigned int len);
76108cea0   Jan Engelhardt   netfilter: Use un...
246
  int compat_nf_getsockopt(struct sock *sk, u_int8_t pf, int optval,
3fdadf7d2   Dmitry Mishin   [NET]: {get|set}s...
247
  		char __user *opt, int *len);
c30f540b6   Alexey Dobriyan   netfilter: xtable...
248
  #endif
3fdadf7d2   Dmitry Mishin   [NET]: {get|set}s...
249

089af26c7   Harald Welte   [NETFILTER]: Rena...
250
251
252
  /* Call this before modifying an existing packet: ensures it is
     modifiable and linear to the point you care about (writable_len).
     Returns true or false. */
a0f4ecf34   Joe Perches   netfilter: Remove...
253
  int skb_make_writable(struct sk_buff *skb, unsigned int writable_len);
089af26c7   Harald Welte   [NETFILTER]: Rena...
254

1841a4c7a   Patrick McHardy   [NETFILTER]: nf_c...
255
  struct flowi;
02f014d88   Patrick McHardy   [NETFILTER]: nf_q...
256
  struct nf_queue_entry;
c01cd429f   Patrick McHardy   [NETFILTER]: nf_q...
257

bce8032ef   Patrick McHardy   [NETFILTER]: Intr...
258
259
  struct nf_afinfo {
  	unsigned short	family;
b51655b95   Al Viro   [NET]: Annotate _...
260
  	__sum16		(*checksum)(struct sk_buff *skb, unsigned int hook,
422c346fa   Patrick McHardy   [NETFILTER]: Add ...
261
  				    unsigned int dataoff, u_int8_t protocol);
d63a65073   Patrick McHardy   [NETFILTER]: Add ...
262
263
264
265
266
  	__sum16		(*checksum_partial)(struct sk_buff *skb,
  					    unsigned int hook,
  					    unsigned int dataoff,
  					    unsigned int len,
  					    u_int8_t protocol);
31ad3dd64   Florian Westphal   netfilter: af_inf...
267
  	int		(*route)(struct net *net, struct dst_entry **dst,
0fae2e774   Florian Westphal   netfilter: af_inf...
268
  				 struct flowi *fl, bool strict);
bce8032ef   Patrick McHardy   [NETFILTER]: Intr...
269
  	void		(*saveroute)(const struct sk_buff *skb,
02f014d88   Patrick McHardy   [NETFILTER]: nf_q...
270
  				     struct nf_queue_entry *entry);
d815d90bb   Eric W. Biederman   netfilter: Push s...
271
  	int		(*reroute)(struct net *net, struct sk_buff *skb,
02f014d88   Patrick McHardy   [NETFILTER]: nf_q...
272
  				   const struct nf_queue_entry *entry);
bce8032ef   Patrick McHardy   [NETFILTER]: Intr...
273
  	int		route_key_size;
2cc7d5730   Harald Welte   [NETFILTER]: Move...
274
  };
0e60ebe04   Eric Dumazet   netfilter: add __...
275
  extern const struct nf_afinfo __rcu *nf_afinfo[NFPROTO_NUMPROTO];
1e796fda0   Patrick McHardy   [NETFILTER]: cons...
276
  static inline const struct nf_afinfo *nf_get_afinfo(unsigned short family)
bce8032ef   Patrick McHardy   [NETFILTER]: Intr...
277
278
279
  {
  	return rcu_dereference(nf_afinfo[family]);
  }
2cc7d5730   Harald Welte   [NETFILTER]: Move...
280

b51655b95   Al Viro   [NET]: Annotate _...
281
  static inline __sum16
422c346fa   Patrick McHardy   [NETFILTER]: Add ...
282
283
284
  nf_checksum(struct sk_buff *skb, unsigned int hook, unsigned int dataoff,
  	    u_int8_t protocol, unsigned short family)
  {
1e796fda0   Patrick McHardy   [NETFILTER]: cons...
285
  	const struct nf_afinfo *afinfo;
b51655b95   Al Viro   [NET]: Annotate _...
286
  	__sum16 csum = 0;
422c346fa   Patrick McHardy   [NETFILTER]: Add ...
287
288
289
290
291
292
293
294
  
  	rcu_read_lock();
  	afinfo = nf_get_afinfo(family);
  	if (afinfo)
  		csum = afinfo->checksum(skb, hook, dataoff, protocol);
  	rcu_read_unlock();
  	return csum;
  }
d63a65073   Patrick McHardy   [NETFILTER]: Add ...
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
  static inline __sum16
  nf_checksum_partial(struct sk_buff *skb, unsigned int hook,
  		    unsigned int dataoff, unsigned int len,
  		    u_int8_t protocol, unsigned short family)
  {
  	const struct nf_afinfo *afinfo;
  	__sum16 csum = 0;
  
  	rcu_read_lock();
  	afinfo = nf_get_afinfo(family);
  	if (afinfo)
  		csum = afinfo->checksum_partial(skb, hook, dataoff, len,
  						protocol);
  	rcu_read_unlock();
  	return csum;
  }
a0f4ecf34   Joe Perches   netfilter: Remove...
311
312
  int nf_register_afinfo(const struct nf_afinfo *afinfo);
  void nf_unregister_afinfo(const struct nf_afinfo *afinfo);
bce8032ef   Patrick McHardy   [NETFILTER]: Intr...
313

eb9c7ebe6   Patrick McHardy   [NETFILTER]: Hand...
314
  #include <net/flow.h>
c7232c997   Patrick McHardy   netfilter: add pr...
315
  extern void (*nf_nat_decode_session_hook)(struct sk_buff *, struct flowi *);
eb9c7ebe6   Patrick McHardy   [NETFILTER]: Hand...
316
317
  
  static inline void
76108cea0   Jan Engelhardt   netfilter: Use un...
318
  nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, u_int8_t family)
eb9c7ebe6   Patrick McHardy   [NETFILTER]: Hand...
319
  {
051578ccb   Patrick McHardy   [NETFILTER]: nf_n...
320
  #ifdef CONFIG_NF_NAT_NEEDED
eb9c7ebe6   Patrick McHardy   [NETFILTER]: Hand...
321
  	void (*decodefn)(struct sk_buff *, struct flowi *);
c7232c997   Patrick McHardy   netfilter: add pr...
322
323
324
325
326
  	rcu_read_lock();
  	decodefn = rcu_dereference(nf_nat_decode_session_hook);
  	if (decodefn)
  		decodefn(skb, fl);
  	rcu_read_unlock();
eb9c7ebe6   Patrick McHardy   [NETFILTER]: Hand...
327
328
  #endif
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
329
  #else /* !CONFIG_NETFILTER */
008027c31   Arnd Bergmann   netfilter: turn N...
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
  static inline int
  NF_HOOK_COND(uint8_t pf, unsigned int hook, struct net *net, struct sock *sk,
  	     struct sk_buff *skb, struct net_device *in, struct net_device *out,
  	     int (*okfn)(struct net *, struct sock *, struct sk_buff *),
  	     bool cond)
  {
  	return okfn(net, sk, skb);
  }
  
  static inline int
  NF_HOOK(uint8_t pf, unsigned int hook, struct net *net, struct sock *sk,
  	struct sk_buff *skb, struct net_device *in, struct net_device *out,
  	int (*okfn)(struct net *, struct sock *, struct sk_buff *))
  {
  	return okfn(net, sk, skb);
  }
29a26a568   Eric W. Biederman   netfilter: Pass s...
346
347
348
  static inline int nf_hook(u_int8_t pf, unsigned int hook, struct net *net,
  			  struct sock *sk, struct sk_buff *skb,
  			  struct net_device *indev, struct net_device *outdev,
0c4b51f00   Eric W. Biederman   netfilter: Pass n...
349
  			  int (*okfn)(struct net *, struct sock *, struct sk_buff *))
f53b61d8c   David S. Miller   [NETFILTER]: Add ...
350
  {
9c92d3486   Patrick McHardy   [NETFILTER]: Don'...
351
  	return 1;
f53b61d8c   David S. Miller   [NETFILTER]: Add ...
352
  }
f53b61d8c   David S. Miller   [NETFILTER]: Add ...
353
  struct flowi;
eb9c7ebe6   Patrick McHardy   [NETFILTER]: Hand...
354
  static inline void
76108cea0   Jan Engelhardt   netfilter: Use un...
355
356
357
  nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, u_int8_t family)
  {
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
358
  #endif /*CONFIG_NETFILTER*/
5f79e0f91   Yasuyuki Kozakai   [NETFILTER]: nf_c...
359
  #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
62da98656   Daniel Borkmann   netfilter: nf_con...
360
  #include <linux/netfilter/nf_conntrack_zones_common.h>
312a0c16c   Patrick McHardy   netfilter: nf_con...
361
  extern void (*ip_ct_attach)(struct sk_buff *, const struct sk_buff *) __rcu;
a0f4ecf34   Joe Perches   netfilter: Remove...
362
  void nf_ct_attach(struct sk_buff *, const struct sk_buff *);
0e60ebe04   Eric Dumazet   netfilter: add __...
363
  extern void (*nf_ct_destroy)(struct nf_conntrack *) __rcu;
b7bd1809e   Pablo Neira Ayuso   netfilter: nfnetl...
364
365
366
  #else
  static inline void nf_ct_attach(struct sk_buff *new, struct sk_buff *skb) {}
  #endif
9cb017665   Pablo Neira Ayuso   netfilter: add gl...
367
368
  
  struct nf_conn;
41d73ec05   Patrick McHardy   netfilter: nf_con...
369
  enum ip_conntrack_info;
9cb017665   Pablo Neira Ayuso   netfilter: add gl...
370
  struct nlattr;
a4b4766c3   Ken-ichirou MATSUZAWA   netfilter: nfnetl...
371
  struct nfnl_ct_hook {
224a05975   Ken-ichirou MATSUZAWA   netfilter: ctnetl...
372
  	struct nf_conn *(*get_ct)(const struct sk_buff *skb,
b7bd1809e   Pablo Neira Ayuso   netfilter: nfnetl...
373
  				  enum ip_conntrack_info *ctinfo);
9cb017665   Pablo Neira Ayuso   netfilter: add gl...
374
  	size_t (*build_size)(const struct nf_conn *ct);
b7bd1809e   Pablo Neira Ayuso   netfilter: nfnetl...
375
376
377
  	int (*build)(struct sk_buff *skb, struct nf_conn *ct,
  		     enum ip_conntrack_info ctinfo,
  		     u_int16_t ct_attr, u_int16_t ct_info_attr);
9cb017665   Pablo Neira Ayuso   netfilter: add gl...
378
  	int (*parse)(const struct nlattr *attr, struct nf_conn *ct);
bd0779370   Pablo Neira Ayuso   netfilter: nfnetl...
379
380
  	int (*attach_expect)(const struct nlattr *attr, struct nf_conn *ct,
  			     u32 portid, u32 report);
8c88f87cb   Pablo Neira Ayuso   netfilter: nfnetl...
381
  	void (*seq_adjust)(struct sk_buff *skb, struct nf_conn *ct,
41d73ec05   Patrick McHardy   netfilter: nf_con...
382
  			   enum ip_conntrack_info ctinfo, s32 off);
9cb017665   Pablo Neira Ayuso   netfilter: add gl...
383
  };
a4b4766c3   Ken-ichirou MATSUZAWA   netfilter: nfnetl...
384
  extern struct nfnl_ct_hook __rcu *nfnl_ct_hook;
5f79e0f91   Yasuyuki Kozakai   [NETFILTER]: nf_c...
385

e7c8899f3   Florian Westphal   netfilter: move t...
386
387
388
389
390
391
392
393
394
395
  /**
   * nf_skb_duplicated - TEE target has sent a packet
   *
   * When a xtables target sends a packet, the OUTPUT and POSTROUTING
   * hooks are traversed again, i.e. nft and xtables are invoked recursively.
   *
   * This is used by xtables TEE target to prevent the duplicated skb from
   * being duplicated again.
   */
  DECLARE_PER_CPU(bool, nf_skb_duplicated);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
396
  #endif /*__LINUX_NETFILTER_H*/