Skip to contentSkip to conversation

expression: don't trim off unary expression on delinearization

PATCH New Pablo Neira Ayuso 1 participant 2 messages May 26, 2017 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/2 expression: don't trim off unary expression on delinearization

This transformation introduces an unnecessary asymmetry between the linearization and delinearization steps that prevent rule deletion from definition to work fine.

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

---
 src/expression.c          | 3 ---
 src/netlink_delinearize.c | 5 +----
 2 files changed, 1 insertion(+), 7 deletions(-)
src/expression.c +0 -3
index 5defa63f4a5f..55dd391178c3 100644
@@ -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)
src/netlink_delinearize.c +1 -4
index 49dc6a6016ba..b355eff47222 100644
@@ -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);
Signature · 1 line
2.1.4
author maintainer
#1 lore raw

PATCH 2/2 tests: py: flush stdout on each test run

Useful when redirecting output to file and tail -f it.

---
 tests/py/nft-test.py | 2 ++
 1 file changed, 2 insertions(+)
tests/py/nft-test.py +2 -0
index 8d1df3bc517a..c1da71aaf827 100755
@@ -955,6 +955,8 @@ def run_test_file(filename, force_all_family_option, specific_file):
     tests = passed = total_unit_run = total_warning = total_error = 0
 
     for lineno, line in enumerate(f):
+        sys.stdout.flush()
+
         if signal_received == 1:
             print "\nSignal received. Cleaning up and Exitting..."
             cleanup_on_exit()
Signature · 1 line
2.1.4