Re: [PATCH 1/1] Solves Bug 1462 - `nft -j list set` does not show counters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Gopal,

On 3/10/20 14:58, Gopal Yadav wrote:
Solves Bug 1462 - `nft -j list set` does not show counters

Signed-off-by: Gopal Yadav <gopunop@xxxxxxxxx>
---
  src/json.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/json.c b/src/json.c
index 5856f9fc..6ad48fdd 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,10 @@ 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 = expr->stmt->ops->json(expr->stmt, octx);

You can compact this using stmt_print_json

+			json_object_update(root, tmp);

ASAN reports memleaks when using json_object_update. You should use json_object_update_new, or maybe json_object_update_missing_new to ensure only new keys are created.

+		}
  		return json_pack("{s:o}", "elem", root);
  	}




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux