From 4ab1e5e6077918b5b0b4553daa907a725d4cd0fe Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Sat, 30 Jan 2021 19:58:42 +0100 Subject: 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 Signed-off-by: Florian Westphal --- src/expression.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/expression.c') 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, -- cgit v1.2.3