netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH nft 1/2] expression: don't trim off unary expression on delinearization
@ 2017-05-26 12:36 Pablo Neira Ayuso
  2017-05-26 12:36 ` [PATCH nft 2/2] tests: py: flush stdout on each test run Pablo Neira Ayuso
  0 siblings, 1 reply; 2+ messages in thread
From: Pablo Neira Ayuso @ 2017-05-26 12:36 UTC (permalink / raw)
  To: netfilter-devel

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.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 src/expression.c          | 3 ---
 src/netlink_delinearize.c | 5 +----
 2 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/src/expression.c b/src/expression.c
index 5defa63f4a5f..55dd391178c3 100644
--- a/src/expression.c
+++ b/src/expression.c
@@ -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)
diff --git a/src/netlink_delinearize.c b/src/netlink_delinearize.c
index 49dc6a6016ba..b355eff47222 100644
--- a/src/netlink_delinearize.c
+++ b/src/netlink_delinearize.c
@@ -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);
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH nft 2/2] tests: py: flush stdout on each test run
  2017-05-26 12:36 [PATCH nft 1/2] expression: don't trim off unary expression on delinearization Pablo Neira Ayuso
@ 2017-05-26 12:36 ` Pablo Neira Ayuso
  0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2017-05-26 12:36 UTC (permalink / raw)
  To: netfilter-devel

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

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 tests/py/nft-test.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/py/nft-test.py b/tests/py/nft-test.py
index 8d1df3bc517a..c1da71aaf827 100755
--- a/tests/py/nft-test.py
+++ b/tests/py/nft-test.py
@@ -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()
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-05-26 12:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-26 12:36 [PATCH nft 1/2] expression: don't trim off unary expression on delinearization Pablo Neira Ayuso
2017-05-26 12:36 ` [PATCH nft 2/2] tests: py: flush stdout on each test run Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).