Skip to contentSkip to conversation

Solves Bug 1462 - `nft -j list set` does not show counters

PATCH In review Gopal Yadav 2 participants 4 messages Oct 7, 2020 – Oct 9, 2020 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Solves Bug 1462 - `nft -j list set` does not show counters

Solves Bug 1462 - nft -j list set does not show counters

---
 src/json.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
src/json.c +6 -1
index 5856f9fc..ea6e392c 100644
@@ -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,11 @@ 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);
+			json_object_update_missing(root, tmp);
+			json_decref(tmp);
+		}
 		return json_pack("{s:o}", "elem", root);
 	}
 
Signature · 1 line
2.17.1
reviewer
#1 lore raw
Quoted 3 lines · Gopal Yadav

Solves Bug 1462 - nft -j list set does not show counters

Added a comment about potential clashes (json_object_update_missing() hides those) and replaced the duplicate subject line by a commit message, then applied the result.

Thanks, Phil

#2 lore raw
Quoted 9 lines · Phil Sutter
Quoted 3 lines · Gopal Yadav

Solves Bug 1462 - nft -j list set does not show counters

Added a comment about potential clashes (json_object_update_missing() hides those) and replaced the duplicate subject line by a commit message, then applied the result.

Any description of those potential clashes?

reviewer
#3 lore raw
Quoted 5 lines · Gopal Yadav
Quoted 4 lines · Phil Sutter
Quoted 2 lines · Gopal Yadav

Solves Bug 1462 - nft -j list set does not show counters

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Added a comment about potential clashes (json_object_update_missing() hides those) and replaced the duplicate subject line by a commit message, then applied the result.

Any description of those potential clashes?

AFAICT, none are possible right now. Though the design allows for it and we might miss that.

Cheers, Phil