diff options
author | Fernando Fernandez Mancera <ffmancera@riseup.net> | 2022-09-02 12:52:04 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2022-09-03 15:54:26 +0200 |
commit | e66f3187d891a7b2f7212f33ab7501d5ee6c3b2f (patch) | |
tree | a69770e7ed81754a439bd623ca5d6b2aef2ae5fe /src/parser_json.c | |
parent | a817ea9655dee1915423a802c0133e3611e02b3a (diff) |
json: add table map statement support
When listing a map with statements with JSON support, the statement list were
ignored.
Output example:
{
"map": {
"family": "ip",
"name": "m",
"table": "t",
"type": "ipv4_addr",
"handle": 1,
"map": "mark",
"stmt": [
{
"counter": {
"packets": 0,
"bytes": 0
}
}
]
}
}
Link: https://bugzilla.netfilter.org/show_bug.cgi?id=1588
Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/parser_json.c')
-rw-r--r-- | src/parser_json.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/parser_json.c b/src/parser_json.c index fc72c25f..7180474e 100644 --- a/src/parser_json.c +++ b/src/parser_json.c @@ -3002,8 +3002,8 @@ static struct cmd *json_parse_cmd_add_set(struct json_ctx *ctx, json_t *root, { struct handle h = { 0 }; const char *family = "", *policy, *dtype_ext = NULL; + json_t *tmp, *stmt_json; struct set *set; - json_t *tmp; if (json_unpack_err(ctx, root, "{s:s, s:s}", "family", &family, @@ -3114,6 +3114,9 @@ static struct cmd *json_parse_cmd_add_set(struct json_ctx *ctx, json_t *root, set->gc_int *= 1000; json_unpack(root, "{s:i}", "size", &set->desc.size); + if (!json_unpack(root, "{s:o}", "stmt", &stmt_json)) + json_parse_set_stmt_list(ctx, &set->stmt_list, stmt_json); + handle_merge(&set->handle, &h); if (op == CMD_ADD) |