]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
expression: don't trim off unary expression on delinearization
authorPablo Neira Ayuso <pablo@netfilter.org>
Fri, 26 May 2017 10:49:21 +0000 (11:49 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 29 May 2017 11:00:38 +0000 (13:00 +0200)
This transformation introduces an unnecessary asymmetry between the
linearization and delinearization steps that prevent rule deletion by
name to work fine.

Moreover, do not print htonl and ntonl from unary expression, this
syntax is not allowed by the parser.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/expression.c
src/netlink_delinearize.c

index 5defa63f4a5f43f9148f7430893a213714a651cd..55dd391178c3b40e42581163c47096c6c782a86f 100644 (file)
@@ -460,10 +460,7 @@ const char *expr_op_symbols[] = {
 
 static void unary_expr_print(const struct expr *expr)
 {
-       if (expr_op_symbols[expr->op] != NULL)
-               printf("%s(", expr_op_symbols[expr->op]);
        expr_print(expr->arg);
-       printf(")");
 }
 
 static void unary_expr_clone(struct expr *new, const struct expr *expr)
index 49dc6a6016bad3616187a721aa48f80e972a9d16..b355eff47222e56d548a9a42f82de7a71d914b1c 100644 (file)
@@ -1759,10 +1759,7 @@ static void expr_postprocess(struct rule_pp_ctx *ctx, struct expr **exprp)
        }
        case EXPR_UNARY:
                expr_postprocess(ctx, &expr->arg);
-               expr_set_type(expr->arg, expr->arg->dtype, !expr->arg->byteorder);
-
-               *exprp = expr_get(expr->arg);
-               expr_free(expr);
+               expr_set_type(expr, expr->arg->dtype, !expr->arg->byteorder);
                break;
        case EXPR_BINOP:
                expr_postprocess(ctx, &expr->left);