Replace ipportmap boolean field by flags. Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx> --- include/statement.h | 2 +- src/evaluate.c | 2 +- src/netlink_delinearize. | 0 src/netlink_delinearize.c | 2 +- src/netlink_linearize.c | 6 +++--- src/parser_bison.y | 2 +- src/statement.c | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) create mode 100644 src/netlink_delinearize. diff --git a/include/statement.h b/include/statement.h index 01fe416c415a..7d96b3947dfc 100644 --- a/include/statement.h +++ b/include/statement.h @@ -122,6 +122,7 @@ extern const char *nat_etype2str(enum nft_nat_etypes type); enum { STMT_NAT_F_INTERVAL = (1 << 0), STMT_NAT_F_PREFIX = (1 << 1), + STMT_NAT_F_CONCAT = (1 << 2), }; struct nat_stmt { @@ -130,7 +131,6 @@ struct nat_stmt { struct expr *proto; uint32_t flags; uint8_t family; - bool ipportmap; uint32_t type_flags; }; diff --git a/src/evaluate.c b/src/evaluate.c index a116f7b66e07..cad65cfb7343 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -2973,7 +2973,7 @@ static int stmt_evaluate_nat(struct eval_ctx *ctx, struct stmt *stmt) if (err < 0) return err; - if (stmt->nat.ipportmap) { + if (stmt->nat.type_flags & STMT_NAT_F_CONCAT) { err = stmt_evaluate_nat_map(ctx, stmt); if (err < 0) return err; diff --git a/src/netlink_delinearize. b/src/netlink_delinearize. new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/src/netlink_delinearize.c b/src/netlink_delinearize.c index b039a1e3c7ac..772559c838f5 100644 --- a/src/netlink_delinearize.c +++ b/src/netlink_delinearize.c @@ -1110,7 +1110,7 @@ static void netlink_parse_nat(struct netlink_parse_ctx *ctx, if (is_nat_proto_map(addr, family)) { stmt->nat.family = family; - stmt->nat.ipportmap = true; + stmt->nat.type_flags |= STMT_NAT_F_CONCAT; ctx->stmt = stmt; return; } diff --git a/src/netlink_linearize.c b/src/netlink_linearize.c index 944fcdae4ee9..08f7f89f1066 100644 --- a/src/netlink_linearize.c +++ b/src/netlink_linearize.c @@ -1127,15 +1127,15 @@ static void netlink_gen_nat_stmt(struct netlink_linearize_ctx *ctx, } } - if (stmt->nat.ipportmap) { + if (stmt->nat.type_flags & STMT_NAT_F_CONCAT) { /* nat_stmt evaluation step doesn't allow - * stmt->nat.ipportmap && stmt->nat.proto. + * STMT_NAT_F_CONCAT && stmt->nat.proto. */ assert(stmt->nat.proto == NULL); pmin_reg = amin_reg; - /* if ipportmap is set, the mapped type is a + /* if STMT_NAT_F_CONCAT is set, the mapped type is a * concatenation of 'addr . inet_service'. * The map lookup will then return the * concatenated value, so we need to skip diff --git a/src/parser_bison.y b/src/parser_bison.y index 3b470cc63235..b1e869d568a1 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -3192,7 +3192,7 @@ nat_stmt_args : stmt_expr { $<stmt>0->nat.family = $1; $<stmt>0->nat.addr = $6; - $<stmt>0->nat.ipportmap = true; + $<stmt>0->nat.type_flags = STMT_NAT_F_CONCAT; } | nf_key_proto INTERVAL TO stmt_expr { diff --git a/src/statement.c b/src/statement.c index 8a1cd6e04f61..21a1bc8d40dd 100644 --- a/src/statement.c +++ b/src/statement.c @@ -607,7 +607,7 @@ static void nat_stmt_print(const struct stmt *stmt, struct output_ctx *octx) break; } - if (stmt->nat.ipportmap) + if (stmt->nat.type_flags & STMT_NAT_F_CONCAT) nft_print(octx, " addr . port"); else if (stmt->nat.type_flags & STMT_NAT_F_PREFIX) nft_print(octx, " prefix"); -- 2.20.1