diff options
author | Gopal Yadav <gopunop@gmail.com> | 2020-10-07 19:33:37 +0530 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2020-10-08 18:57:06 +0200 |
commit | d63064681a91fdfbd53e1ef07b6a8283f48fedb5 (patch) | |
tree | 15dbc4cb166082d5b0086f8bed9f924a2b067019 /src | |
parent | 032c9f745c6daab8c27176a95963b1c32b0a5d12 (diff) |
Solves Bug 1462 - `nft -j list set` does not show counters
Element counters reside in 'stmt' field as counter statement. Append
them to 'elem' object as additional 'counter' property, generated by
counter_stmt_json().
Signed-off-by: Gopal Yadav <gopunop@gmail.com>
Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'src')
-rw-r--r-- | src/json.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -589,7 +589,7 @@ json_t *set_elem_expr_json(const struct expr *expr, struct output_ctx *octx) return NULL; /* these element attributes require formal set elem syntax */ - if (expr->timeout || expr->expiration || expr->comment) { + if (expr->timeout || expr->expiration || expr->comment || expr->stmt) { root = json_pack("{s:o}", "val", root); if (expr->timeout) { @@ -604,6 +604,12 @@ json_t *set_elem_expr_json(const struct expr *expr, struct output_ctx *octx) tmp = json_string(expr->comment); json_object_set_new(root, "comment", tmp); } + if (expr->stmt) { + tmp = stmt_print_json(expr->stmt, octx); + /* XXX: detect and complain about clashes? */ + json_object_update_missing(root, tmp); + json_decref(tmp); + } return json_pack("{s:o}", "elem", root); } |