Commit 43dd16ef authored by Pablo Neira Ayuso's avatar Pablo Neira Ayuso

netfilter: nf_tables: store data in offload context registers

Store immediate data into offload context register. This allows follow
up instructions to take it from the corresponding source register.

This patch is required to support for payload mangling, although other
instructions that take data from source register will benefit from this
too.
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent bd8699e9
...@@ -9,6 +9,7 @@ struct nft_offload_reg { ...@@ -9,6 +9,7 @@ struct nft_offload_reg {
u32 len; u32 len;
u32 base_offset; u32 base_offset;
u32 offset; u32 offset;
struct nft_data data;
struct nft_data mask; struct nft_data mask;
}; };
......
...@@ -125,17 +125,13 @@ static int nft_immediate_validate(const struct nft_ctx *ctx, ...@@ -125,17 +125,13 @@ static int nft_immediate_validate(const struct nft_ctx *ctx,
return 0; return 0;
} }
static int nft_immediate_offload(struct nft_offload_ctx *ctx, static int nft_immediate_offload_verdict(struct nft_offload_ctx *ctx,
struct nft_flow_rule *flow, struct nft_flow_rule *flow,
const struct nft_expr *expr) const struct nft_immediate_expr *priv)
{ {
const struct nft_immediate_expr *priv = nft_expr_priv(expr);
struct flow_action_entry *entry; struct flow_action_entry *entry;
const struct nft_data *data; const struct nft_data *data;
if (priv->dreg != NFT_REG_VERDICT)
return -EOPNOTSUPP;
entry = &flow->rule->action.entries[ctx->num_actions++]; entry = &flow->rule->action.entries[ctx->num_actions++];
data = &priv->data; data = &priv->data;
...@@ -153,6 +149,20 @@ static int nft_immediate_offload(struct nft_offload_ctx *ctx, ...@@ -153,6 +149,20 @@ static int nft_immediate_offload(struct nft_offload_ctx *ctx,
return 0; return 0;
} }
static int nft_immediate_offload(struct nft_offload_ctx *ctx,
struct nft_flow_rule *flow,
const struct nft_expr *expr)
{
const struct nft_immediate_expr *priv = nft_expr_priv(expr);
if (priv->dreg == NFT_REG_VERDICT)
return nft_immediate_offload_verdict(ctx, flow, priv);
memcpy(&ctx->regs[priv->dreg].data, &priv->data, sizeof(priv->data));
return 0;
}
static const struct nft_expr_ops nft_imm_ops = { static const struct nft_expr_ops nft_imm_ops = {
.type = &nft_imm_type, .type = &nft_imm_type,
.size = NFT_EXPR_SIZE(sizeof(struct nft_immediate_expr)), .size = NFT_EXPR_SIZE(sizeof(struct nft_immediate_expr)),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment