diff options
author | Florian Westphal <fw@strlen.de> | 2021-01-30 19:58:42 +0100 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2021-02-22 14:57:49 +0100 |
commit | 4ab1e5e6077918b5b0b4553daa907a725d4cd0fe (patch) | |
tree | 21bb70c5b86ad2d89372c7a7374637886ae19f02 /src/expression.c | |
parent | b9e871cb6f5bf17376955acff55bce264e8355aa (diff) |
src: allow use of 'verdict' in typeof definitions
'verdict' cannot be used as part of a map typeof-based key definition,
its a datatype and not an expression, e.g.:
typeof iifname . ip protocol . th dport : verdic
... will fail.
Make the parser convert a 'verdict' symbol to a verdict expression
and allow to store its presence as part of the typeof key definition.
Reported-by: Frank Myhr <fmyhr@fhmtech.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'src/expression.c')
-rw-r--r-- | src/expression.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/expression.c b/src/expression.c index a90a89ca..8c6beef9 100644 --- a/src/expression.c +++ b/src/expression.c @@ -252,6 +252,21 @@ static void verdict_expr_destroy(struct expr *expr) expr_free(expr->chain); } +static int verdict_expr_build_udata(struct nftnl_udata_buf *udbuf, + const struct expr *expr) +{ + return 0; +} + +static struct expr *verdict_expr_parse_udata(const struct nftnl_udata *attr) +{ + struct expr *e = verdict_expr_alloc(&internal_location, 0, NULL); + + e = symbol_expr_alloc(&internal_location, SYMBOL_VALUE, NULL, "verdict"); + e->len = NFT_REG_SIZE * BITS_PER_BYTE; + return e; +} + static const struct expr_ops verdict_expr_ops = { .type = EXPR_VERDICT, .name = "verdict", @@ -260,6 +275,8 @@ static const struct expr_ops verdict_expr_ops = { .cmp = verdict_expr_cmp, .clone = verdict_expr_clone, .destroy = verdict_expr_destroy, + .build_udata = verdict_expr_build_udata, + .parse_udata = verdict_expr_parse_udata, }; struct expr *verdict_expr_alloc(const struct location *loc, |