2121#include <net/tcp_states.h> /* for TCP_TIME_WAIT */
2222#include <net/netfilter/nf_tables.h>
2323#include <net/netfilter/nf_tables_core.h>
24+ #include <net/netfilter/nft_meta.h>
2425
2526#include <uapi/linux/netfilter_bridge.h> /* NF_BR_PRE_ROUTING */
2627
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-
3528static DEFINE_PER_CPU (struct rnd_state , nft_prandom_state ) ;
3629
37- #ifdef CONFIG_NF_TABLES_BRIDGE
38- #include "../bridge/br_private.h"
39- #endif
40-
4130void nft_meta_get_eval (const struct nft_expr * expr ,
4231 struct nft_regs * regs ,
4332 const struct nft_pktinfo * pkt )
@@ -47,9 +36,6 @@ void nft_meta_get_eval(const struct nft_expr *expr,
4736 const struct net_device * in = nft_in (pkt ), * out = nft_out (pkt );
4837 struct sock * sk ;
4938 u32 * dest = & regs -> data [priv -> dreg ];
50- #ifdef CONFIG_NF_TABLES_BRIDGE
51- const struct net_bridge_port * p ;
52- #endif
5339
5440 switch (priv -> key ) {
5541 case NFT_META_LEN :
@@ -228,18 +214,6 @@ void nft_meta_get_eval(const struct nft_expr *expr,
228214 case NFT_META_SECPATH :
229215 nft_reg_store8 (dest , secpath_exists (skb ));
230216 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 ;
243217#endif
244218 case NFT_META_IIFKIND :
245219 if (in == NULL || in -> rtnl_link_ops == NULL )
@@ -260,10 +234,11 @@ void nft_meta_get_eval(const struct nft_expr *expr,
260234err :
261235 regs -> verdict .code = NFT_BREAK ;
262236}
237+ EXPORT_SYMBOL_GPL (nft_meta_get_eval );
263238
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 )
267242{
268243 const struct nft_meta * meta = nft_expr_priv (expr );
269244 struct sk_buff * skb = pkt -> skb ;
@@ -300,16 +275,18 @@ static void nft_meta_set_eval(const struct nft_expr *expr,
300275 WARN_ON (1 );
301276 }
302277}
278+ EXPORT_SYMBOL_GPL (nft_meta_set_eval );
303279
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 ] = {
305281 [NFTA_META_DREG ] = { .type = NLA_U32 },
306282 [NFTA_META_KEY ] = { .type = NLA_U32 },
307283 [NFTA_META_SREG ] = { .type = NLA_U32 },
308284};
285+ EXPORT_SYMBOL_GPL (nft_meta_policy );
309286
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 [])
313290{
314291 struct nft_meta * priv = nft_expr_priv (expr );
315292 unsigned int len ;
@@ -359,14 +336,6 @@ static int nft_meta_get_init(const struct nft_ctx *ctx,
359336 case NFT_META_SECPATH :
360337 len = sizeof (u8 );
361338 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 ;
370339#endif
371340 default :
372341 return - EOPNOTSUPP ;
@@ -376,6 +345,7 @@ static int nft_meta_get_init(const struct nft_ctx *ctx,
376345 return nft_validate_register_store (ctx , priv -> dreg , NULL ,
377346 NFT_DATA_VALUE , len );
378347}
348+ EXPORT_SYMBOL_GPL (nft_meta_get_init );
379349
380350static int nft_meta_get_validate (const struct nft_ctx * ctx ,
381351 const struct nft_expr * expr ,
@@ -409,9 +379,9 @@ static int nft_meta_get_validate(const struct nft_ctx *ctx,
409379#endif
410380}
411381
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 )
415385{
416386 struct nft_meta * priv = nft_expr_priv (expr );
417387 unsigned int hooks ;
@@ -437,10 +407,11 @@ static int nft_meta_set_validate(const struct nft_ctx *ctx,
437407
438408 return nft_chain_validate_hooks (ctx -> chain , hooks );
439409}
410+ EXPORT_SYMBOL_GPL (nft_meta_set_validate );
440411
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 [])
444415{
445416 struct nft_meta * priv = nft_expr_priv (expr );
446417 unsigned int len ;
@@ -475,9 +446,10 @@ static int nft_meta_set_init(const struct nft_ctx *ctx,
475446
476447 return 0 ;
477448}
449+ EXPORT_SYMBOL_GPL (nft_meta_set_init );
478450
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 )
481453{
482454 const struct nft_meta * priv = nft_expr_priv (expr );
483455
@@ -490,8 +462,9 @@ static int nft_meta_get_dump(struct sk_buff *skb,
490462nla_put_failure :
491463 return -1 ;
492464}
465+ EXPORT_SYMBOL_GPL (nft_meta_get_dump );
493466
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 )
495468{
496469 const struct nft_meta * priv = nft_expr_priv (expr );
497470
@@ -505,15 +478,17 @@ static int nft_meta_set_dump(struct sk_buff *skb, const struct nft_expr *expr)
505478nla_put_failure :
506479 return -1 ;
507480}
481+ EXPORT_SYMBOL_GPL (nft_meta_set_dump );
508482
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 )
511485{
512486 const struct nft_meta * priv = nft_expr_priv (expr );
513487
514488 if (priv -> key == NFT_META_NFTRACE )
515489 static_branch_dec (& nft_trace_enabled );
516490}
491+ EXPORT_SYMBOL_GPL (nft_meta_set_destroy );
517492
518493static const struct nft_expr_ops nft_meta_get_ops = {
519494 .type = & nft_meta_type ,
0 commit comments