diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2021-07-13 20:18:15 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2021-07-13 20:21:32 +0200 |
commit | 9b169bfc650ebeb81aff80ba2bf87d729dc3143e (patch) | |
tree | a1d74be596b5d715a80cdac6f460ace1ea556115 /src | |
parent | b73ff88cf011ec53ee66a9b1a99b34aea0db63f4 (diff) |
src: remove STMT_NAT_F_INTERVAL flags and interval keyword
STMT_NAT_F_INTERVAL is not useful, the keyword interval can be removed
to simplify the syntax, e.g.
snat to ip saddr map { 10.141.11.4 : 192.168.2.2-192.168.2.4 }
This patch reworks 9599d9d25a6b ("src: NAT support for intervals in
maps").
Do not remove STMT_NAT_F_INTERVAL yet since this flag is needed for
interval concatenations coming in a follow up patch.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/evaluate.c | 20 | ||||
-rw-r--r-- | src/json.c | 2 | ||||
-rw-r--r-- | src/netlink_delinearize.c | 1 | ||||
-rw-r--r-- | src/parser_bison.y | 8 | ||||
-rw-r--r-- | src/statement.c | 2 |
5 files changed, 2 insertions, 31 deletions
diff --git a/src/evaluate.c b/src/evaluate.c index dbc773d1..13888e5b 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -3200,26 +3200,6 @@ static int stmt_evaluate_nat(struct eval_ctx *ctx, struct stmt *stmt) return err; } - if (stmt->nat.type_flags & STMT_NAT_F_INTERVAL) { - switch (stmt->nat.addr->etype) { - case EXPR_MAP: - if (!(stmt->nat.addr->mappings->set->data->flags & EXPR_F_INTERVAL)) - return expr_error(ctx->msgs, stmt->nat.addr, - "map is not defined as interval"); - break; - case EXPR_RANGE: - case EXPR_PREFIX: - break; - default: - return expr_error(ctx->msgs, stmt->nat.addr, - "neither prefix, range nor map expression"); - } - - stmt->flags |= STMT_F_TERMINAL; - - return 0; - } - if (stmt->nat.proto != NULL) { err = nat_evaluate_transport(ctx, stmt, &stmt->nat.proto); if (err < 0) @@ -1329,8 +1329,6 @@ static json_t *nat_type_flags_json(uint32_t type_flags) { json_t *array = json_array(); - if (type_flags & STMT_NAT_F_INTERVAL) - json_array_append_new(array, json_string("interval")); if (type_flags & STMT_NAT_F_PREFIX) json_array_append_new(array, json_string("prefix")); if (type_flags & STMT_NAT_F_CONCAT) diff --git a/src/netlink_delinearize.c b/src/netlink_delinearize.c index fd994b8b..a4ae938a 100644 --- a/src/netlink_delinearize.c +++ b/src/netlink_delinearize.c @@ -1119,7 +1119,6 @@ static void netlink_parse_nat(struct netlink_parse_ctx *ctx, if (is_nat_addr_map(addr, family)) { stmt->nat.family = family; - stmt->nat.type_flags |= STMT_NAT_F_INTERVAL; ctx->stmt = stmt; return; } diff --git a/src/parser_bison.y b/src/parser_bison.y index 872d7cdb..790cd832 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -3623,28 +3623,24 @@ nat_stmt_args : stmt_expr { $<stmt>0->nat.family = $1; $<stmt>0->nat.addr = $4; - $<stmt>0->nat.type_flags = STMT_NAT_F_INTERVAL; } | INTERVAL TO stmt_expr { $<stmt>0->nat.addr = $3; - $<stmt>0->nat.type_flags = STMT_NAT_F_INTERVAL; } | nf_key_proto PREFIX TO stmt_expr { $<stmt>0->nat.family = $1; $<stmt>0->nat.addr = $4; $<stmt>0->nat.type_flags = - STMT_NAT_F_PREFIX | - STMT_NAT_F_INTERVAL; + STMT_NAT_F_PREFIX; $<stmt>0->nat.flags |= NF_NAT_RANGE_NETMAP; } | PREFIX TO stmt_expr { $<stmt>0->nat.addr = $3; $<stmt>0->nat.type_flags = - STMT_NAT_F_PREFIX | - STMT_NAT_F_INTERVAL; + STMT_NAT_F_PREFIX; $<stmt>0->nat.flags |= NF_NAT_RANGE_NETMAP; } ; diff --git a/src/statement.c b/src/statement.c index dfd27510..6db7e397 100644 --- a/src/statement.c +++ b/src/statement.c @@ -677,8 +677,6 @@ static void nat_stmt_print(const struct stmt *stmt, struct output_ctx *octx) nft_print(octx, " addr . port"); else if (stmt->nat.type_flags & STMT_NAT_F_PREFIX) nft_print(octx, " prefix"); - else if (stmt->nat.type_flags & STMT_NAT_F_INTERVAL) - nft_print(octx, " interval"); nft_print(octx, " to"); } |