diff options
author | Fernando Fernandez Mancera <ffmancera@riseup.net> | 2022-09-10 09:59:48 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2022-09-16 09:37:31 +0200 |
commit | a7d2a042442494abae2970db53fa21bbef1a280a (patch) | |
tree | 01ee3d9e222ce54febc0fa7ef55e012ed2e941d2 /src | |
parent | 4ad6414830bde372d609c3c1caa5f9e7a879dcb8 (diff) |
json: add secmark object reference support
The secmark object reference requires a json parser function and it was
missing. In addition, extends the shell testcases.
Link: https://bugzilla.netfilter.org/show_bug.cgi?id=1630
Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/parser_json.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/parser_json.c b/src/parser_json.c index 46dca9fd..1ffca2d1 100644 --- a/src/parser_json.c +++ b/src/parser_json.c @@ -1966,6 +1966,23 @@ static struct stmt *json_parse_dup_stmt(struct json_ctx *ctx, return stmt; } +static struct stmt *json_parse_secmark_stmt(struct json_ctx *ctx, + const char *key, json_t *value) +{ + struct stmt *stmt; + + stmt = objref_stmt_alloc(int_loc); + stmt->objref.type = NFT_OBJECT_SECMARK; + stmt->objref.expr = json_parse_stmt_expr(ctx, value); + if (!stmt->objref.expr) { + json_error(ctx, "Invalid secmark reference."); + stmt_free(stmt); + return NULL; + } + + return stmt; +} + static int json_parse_nat_flag(struct json_ctx *ctx, json_t *root, int *flags) { @@ -2727,6 +2744,7 @@ static struct stmt *json_parse_stmt(struct json_ctx *ctx, json_t *root) { "tproxy", json_parse_tproxy_stmt }, { "synproxy", json_parse_synproxy_stmt }, { "reset", json_parse_optstrip_stmt }, + { "secmark", json_parse_secmark_stmt }, }; const char *type; unsigned int i; |