Skip to contentSkip to conversation

optimize: skip variables in nat statements

PATCH New Pablo Neira Ayuso 1 participant 1 message Jul 18, 2024 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 optimize: skip variables in nat statements

Do not hit assert():

nft: optimize.c:486: rule_build_stmt_matrix_stmts: Assertion `k >= 0' failed.

variables are not supported by -o/--optimize at this stage.

Fixes 9be404a153bc ("optimize: ignore existing nat mapping")
---
 src/optimize.c                                |  6 ++-
 tests/shell/testcases/optimizations/variables | 52 ++++++++++++++++---
 2 files changed, 49 insertions(+), 9 deletions(-)
src/optimize.c +4 -2
index 62dd9082a587..9f0965cd5fe9 100644
@@ -408,9 +408,11 @@ static int rule_collect_stmts(struct optimize_ctx *ctx, struct rule *rule)
 			break;
 		case STMT_NAT:
 			if ((stmt->nat.addr &&
-			     stmt->nat.addr->etype == EXPR_MAP) ||
+			     (stmt->nat.addr->etype == EXPR_MAP ||
+			      stmt->nat.addr->etype == EXPR_VARIABLE)) ||
 			    (stmt->nat.proto &&
-			     stmt->nat.proto->etype == EXPR_MAP)) {
+			     (stmt->nat.proto->etype == EXPR_MAP ||
+			      stmt->nat.proto->etype == EXPR_VARIABLE))) {
 				clone->ops = &unsupported_stmt_ops;
 				break;
 			}
tests/shell/testcases/optimizations/variables +45 -7

59 lines not on this page · raw message

Signature · 1 line
2.30.2