[PATCH nftables 5/8] json: add support for shifted nat port-ranges

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Jeremy Sowden <jeremy@xxxxxxxxxx>
---
 src/json.c        | 4 ++++
 src/parser_json.c | 8 ++++++++
 2 files changed, 12 insertions(+)

diff --git a/src/json.c b/src/json.c
index f15461d33894..f6874b94c7ec 100644
--- a/src/json.c
+++ b/src/json.c
@@ -1407,6 +1407,10 @@ json_t *nat_stmt_json(const struct stmt *stmt, struct output_ctx *octx)
 		json_object_set_new(root, "port",
 				    expr_print_json(stmt->nat.proto, octx));
 
+	if (stmt->nat.proto_base)
+		json_object_set_new(root, "base_port",
+				    expr_print_json(stmt->nat.proto_base, octx));
+
 	nat_stmt_add_array(root, "flags", array);
 
 	if (stmt->nat.type_flags) {
diff --git a/src/parser_json.c b/src/parser_json.c
index d8d4f1b79e6e..fca9645c7e57 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -2153,6 +2153,14 @@ static struct stmt *json_parse_nat_stmt(struct json_ctx *ctx,
 			return NULL;
 		}
 	}
+	if (!json_unpack(value, "{s:o}", "base_port", &tmp)) {
+		stmt->nat.proto_base = json_parse_stmt_expr(ctx, tmp);
+		if (!stmt->nat.proto) {
+			json_error(ctx, "Invalid nat base port.");
+			stmt_free(stmt);
+			return NULL;
+		}
+	}
 	if (!json_unpack(value, "{s:o}", "flags", &tmp)) {
 		int flags = json_parse_nat_flags(ctx, tmp);
 
-- 
2.39.2




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux