netfilter: nf_tables: handle meta/lookup with direct call
Currently nft uses inlined variants for common operations such as 'ip saddr 1.2.3.4' instead of an indirect call. Also handle meta get operations and lookups without indirect call, both are builtin. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
committed by
Pablo Neira Ayuso
parent
ecbcd689d7
commit
222440b4e8
@@ -71,4 +71,11 @@ extern struct nft_set_type nft_set_hash_fast_type;
|
||||
extern struct nft_set_type nft_set_rbtree_type;
|
||||
extern struct nft_set_type nft_set_bitmap_type;
|
||||
|
||||
struct nft_expr;
|
||||
struct nft_regs;
|
||||
struct nft_pktinfo;
|
||||
void nft_meta_get_eval(const struct nft_expr *expr,
|
||||
struct nft_regs *regs, const struct nft_pktinfo *pkt);
|
||||
void nft_lookup_eval(const struct nft_expr *expr,
|
||||
struct nft_regs *regs, const struct nft_pktinfo *pkt);
|
||||
#endif /* _NET_NF_TABLES_CORE_H */
|
||||
|
||||
@@ -120,6 +120,20 @@ struct nft_jumpstack {
|
||||
struct nft_rule *const *rules;
|
||||
};
|
||||
|
||||
static void expr_call_ops_eval(const struct nft_expr *expr,
|
||||
struct nft_regs *regs,
|
||||
struct nft_pktinfo *pkt)
|
||||
{
|
||||
unsigned long e = (unsigned long)expr->ops->eval;
|
||||
|
||||
if (e == (unsigned long)nft_meta_get_eval)
|
||||
nft_meta_get_eval(expr, regs, pkt);
|
||||
else if (e == (unsigned long)nft_lookup_eval)
|
||||
nft_lookup_eval(expr, regs, pkt);
|
||||
else
|
||||
expr->ops->eval(expr, regs, pkt);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
nft_do_chain(struct nft_pktinfo *pkt, void *priv)
|
||||
{
|
||||
@@ -153,7 +167,7 @@ next_rule:
|
||||
nft_cmp_fast_eval(expr, ®s);
|
||||
else if (expr->ops != &nft_payload_fast_ops ||
|
||||
!nft_payload_fast_eval(expr, ®s, pkt))
|
||||
expr->ops->eval(expr, ®s, pkt);
|
||||
expr_call_ops_eval(expr, ®s, pkt);
|
||||
|
||||
if (regs.verdict.code != NFT_CONTINUE)
|
||||
break;
|
||||
|
||||
@@ -26,7 +26,7 @@ struct nft_lookup {
|
||||
struct nft_set_binding binding;
|
||||
};
|
||||
|
||||
static void nft_lookup_eval(const struct nft_expr *expr,
|
||||
void nft_lookup_eval(const struct nft_expr *expr,
|
||||
struct nft_regs *regs,
|
||||
const struct nft_pktinfo *pkt)
|
||||
{
|
||||
|
||||
@@ -41,7 +41,7 @@ static DEFINE_PER_CPU(struct rnd_state, nft_prandom_state);
|
||||
#include "../bridge/br_private.h"
|
||||
#endif
|
||||
|
||||
static void nft_meta_get_eval(const struct nft_expr *expr,
|
||||
void nft_meta_get_eval(const struct nft_expr *expr,
|
||||
struct nft_regs *regs,
|
||||
const struct nft_pktinfo *pkt)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user