From: Gopal Yadav Date: Wed, 7 Oct 2020 14:03:37 +0000 (+0530) Subject: Solves Bug 1462 - `nft -j list set` does not show counters X-Git-Tag: v0.9.7~15 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d63064681a91fdfbd53e1ef07b6a8283f48fedb5;p=thirdparty%2Fnftables.git 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 Signed-off-by: Phil Sutter --- diff --git a/src/json.c b/src/json.c index 5856f9fc..121dfb24 100644 --- a/src/json.c +++ b/src/json.c @@ -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); }