21
21
#include <net/tcp_states.h> /* for TCP_TIME_WAIT */
22
22
#include <net/netfilter/nf_tables.h>
23
23
#include <net/netfilter/nf_tables_core.h>
24
+ #include <net/netfilter/nft_meta.h>
24
25
25
26
#include <uapi/linux/netfilter_bridge.h> /* NF_BR_PRE_ROUTING */
26
27
27
- struct nft_meta {
28
- enum nft_meta_keys key :8 ;
29
- union {
30
- enum nft_registers dreg :8 ;
31
- enum nft_registers sreg :8 ;
32
- };
33
- };
34
-
35
28
static DEFINE_PER_CPU (struct rnd_state , nft_prandom_state ) ;
36
29
37
- #ifdef CONFIG_NF_TABLES_BRIDGE
38
- #include "../bridge/br_private.h"
39
- #endif
40
-
41
30
void nft_meta_get_eval (const struct nft_expr * expr ,
42
31
struct nft_regs * regs ,
43
32
const struct nft_pktinfo * pkt )
@@ -47,9 +36,6 @@ void nft_meta_get_eval(const struct nft_expr *expr,
47
36
const struct net_device * in = nft_in (pkt ), * out = nft_out (pkt );
48
37
struct sock * sk ;
49
38
u32 * dest = & regs -> data [priv -> dreg ];
50
- #ifdef CONFIG_NF_TABLES_BRIDGE
51
- const struct net_bridge_port * p ;
52
- #endif
53
39
54
40
switch (priv -> key ) {
55
41
case NFT_META_LEN :
@@ -228,18 +214,6 @@ void nft_meta_get_eval(const struct nft_expr *expr,
228
214
case NFT_META_SECPATH :
229
215
nft_reg_store8 (dest , secpath_exists (skb ));
230
216
break ;
231
- #endif
232
- #ifdef CONFIG_NF_TABLES_BRIDGE
233
- case NFT_META_BRI_IIFNAME :
234
- if (in == NULL || (p = br_port_get_rcu (in )) == NULL )
235
- goto err ;
236
- strncpy ((char * )dest , p -> br -> dev -> name , IFNAMSIZ );
237
- return ;
238
- case NFT_META_BRI_OIFNAME :
239
- if (out == NULL || (p = br_port_get_rcu (out )) == NULL )
240
- goto err ;
241
- strncpy ((char * )dest , p -> br -> dev -> name , IFNAMSIZ );
242
- return ;
243
217
#endif
244
218
case NFT_META_IIFKIND :
245
219
if (in == NULL || in -> rtnl_link_ops == NULL )
@@ -260,10 +234,11 @@ void nft_meta_get_eval(const struct nft_expr *expr,
260
234
err :
261
235
regs -> verdict .code = NFT_BREAK ;
262
236
}
237
+ EXPORT_SYMBOL_GPL (nft_meta_get_eval );
263
238
264
- static void nft_meta_set_eval (const struct nft_expr * expr ,
265
- struct nft_regs * regs ,
266
- const struct nft_pktinfo * pkt )
239
+ void nft_meta_set_eval (const struct nft_expr * expr ,
240
+ struct nft_regs * regs ,
241
+ const struct nft_pktinfo * pkt )
267
242
{
268
243
const struct nft_meta * meta = nft_expr_priv (expr );
269
244
struct sk_buff * skb = pkt -> skb ;
@@ -300,16 +275,18 @@ static void nft_meta_set_eval(const struct nft_expr *expr,
300
275
WARN_ON (1 );
301
276
}
302
277
}
278
+ EXPORT_SYMBOL_GPL (nft_meta_set_eval );
303
279
304
- static const struct nla_policy nft_meta_policy [NFTA_META_MAX + 1 ] = {
280
+ const struct nla_policy nft_meta_policy [NFTA_META_MAX + 1 ] = {
305
281
[NFTA_META_DREG ] = { .type = NLA_U32 },
306
282
[NFTA_META_KEY ] = { .type = NLA_U32 },
307
283
[NFTA_META_SREG ] = { .type = NLA_U32 },
308
284
};
285
+ EXPORT_SYMBOL_GPL (nft_meta_policy );
309
286
310
- static int nft_meta_get_init (const struct nft_ctx * ctx ,
311
- const struct nft_expr * expr ,
312
- const struct nlattr * const tb [])
287
+ int nft_meta_get_init (const struct nft_ctx * ctx ,
288
+ const struct nft_expr * expr ,
289
+ const struct nlattr * const tb [])
313
290
{
314
291
struct nft_meta * priv = nft_expr_priv (expr );
315
292
unsigned int len ;
@@ -359,14 +336,6 @@ static int nft_meta_get_init(const struct nft_ctx *ctx,
359
336
case NFT_META_SECPATH :
360
337
len = sizeof (u8 );
361
338
break ;
362
- #endif
363
- #ifdef CONFIG_NF_TABLES_BRIDGE
364
- case NFT_META_BRI_IIFNAME :
365
- case NFT_META_BRI_OIFNAME :
366
- if (ctx -> family != NFPROTO_BRIDGE )
367
- return - EOPNOTSUPP ;
368
- len = IFNAMSIZ ;
369
- break ;
370
339
#endif
371
340
default :
372
341
return - EOPNOTSUPP ;
@@ -376,6 +345,7 @@ static int nft_meta_get_init(const struct nft_ctx *ctx,
376
345
return nft_validate_register_store (ctx , priv -> dreg , NULL ,
377
346
NFT_DATA_VALUE , len );
378
347
}
348
+ EXPORT_SYMBOL_GPL (nft_meta_get_init );
379
349
380
350
static int nft_meta_get_validate (const struct nft_ctx * ctx ,
381
351
const struct nft_expr * expr ,
@@ -409,9 +379,9 @@ static int nft_meta_get_validate(const struct nft_ctx *ctx,
409
379
#endif
410
380
}
411
381
412
- static int nft_meta_set_validate (const struct nft_ctx * ctx ,
413
- const struct nft_expr * expr ,
414
- const struct nft_data * * data )
382
+ int nft_meta_set_validate (const struct nft_ctx * ctx ,
383
+ const struct nft_expr * expr ,
384
+ const struct nft_data * * data )
415
385
{
416
386
struct nft_meta * priv = nft_expr_priv (expr );
417
387
unsigned int hooks ;
@@ -437,10 +407,11 @@ static int nft_meta_set_validate(const struct nft_ctx *ctx,
437
407
438
408
return nft_chain_validate_hooks (ctx -> chain , hooks );
439
409
}
410
+ EXPORT_SYMBOL_GPL (nft_meta_set_validate );
440
411
441
- static int nft_meta_set_init (const struct nft_ctx * ctx ,
442
- const struct nft_expr * expr ,
443
- const struct nlattr * const tb [])
412
+ int nft_meta_set_init (const struct nft_ctx * ctx ,
413
+ const struct nft_expr * expr ,
414
+ const struct nlattr * const tb [])
444
415
{
445
416
struct nft_meta * priv = nft_expr_priv (expr );
446
417
unsigned int len ;
@@ -475,9 +446,10 @@ static int nft_meta_set_init(const struct nft_ctx *ctx,
475
446
476
447
return 0 ;
477
448
}
449
+ EXPORT_SYMBOL_GPL (nft_meta_set_init );
478
450
479
- static int nft_meta_get_dump (struct sk_buff * skb ,
480
- const struct nft_expr * expr )
451
+ int nft_meta_get_dump (struct sk_buff * skb ,
452
+ const struct nft_expr * expr )
481
453
{
482
454
const struct nft_meta * priv = nft_expr_priv (expr );
483
455
@@ -490,8 +462,9 @@ static int nft_meta_get_dump(struct sk_buff *skb,
490
462
nla_put_failure :
491
463
return -1 ;
492
464
}
465
+ EXPORT_SYMBOL_GPL (nft_meta_get_dump );
493
466
494
- static int nft_meta_set_dump (struct sk_buff * skb , const struct nft_expr * expr )
467
+ int nft_meta_set_dump (struct sk_buff * skb , const struct nft_expr * expr )
495
468
{
496
469
const struct nft_meta * priv = nft_expr_priv (expr );
497
470
@@ -505,15 +478,17 @@ static int nft_meta_set_dump(struct sk_buff *skb, const struct nft_expr *expr)
505
478
nla_put_failure :
506
479
return -1 ;
507
480
}
481
+ EXPORT_SYMBOL_GPL (nft_meta_set_dump );
508
482
509
- static void nft_meta_set_destroy (const struct nft_ctx * ctx ,
510
- const struct nft_expr * expr )
483
+ void nft_meta_set_destroy (const struct nft_ctx * ctx ,
484
+ const struct nft_expr * expr )
511
485
{
512
486
const struct nft_meta * priv = nft_expr_priv (expr );
513
487
514
488
if (priv -> key == NFT_META_NFTRACE )
515
489
static_branch_dec (& nft_trace_enabled );
516
490
}
491
+ EXPORT_SYMBOL_GPL (nft_meta_set_destroy );
517
492
518
493
static const struct nft_expr_ops nft_meta_get_ops = {
519
494
.type = & nft_meta_type ,
0 commit comments