Skip to contentSkip to conversation

json: limit: Always include burst value

PATCH New Phil Sutter 1 participant 1 message Jan 26, 2021 netfilter

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/1 json: limit: Always include burst value

The default burst value is non-zero, so JSON output should include it.

---
 src/json.c                       |  12 +-
 tests/py/any/limit.t.json.output | 277 +++++++++++++++++++++++++++++++
 2 files changed, 282 insertions(+), 7 deletions(-)
 create mode 100644 tests/py/any/limit.t.json.output
src/json.c +5 -7
index 585d35326ac01..8371714147de8 100644
@@ -1168,19 +1168,17 @@ json_t *limit_stmt_json(const struct stmt *stmt, struct output_ctx *octx)
 		burst_unit = get_rate(stmt->limit.burst, &burst);
 	}
 
-	root = json_pack("{s:I, s:s}",
+	root = json_pack("{s:I, s:I, s:s}",
 			 "rate", rate,
+			 "burst", burst,
 			 "per", get_unit(stmt->limit.unit));
 	if (inv)
 		json_object_set_new(root, "inv", json_boolean(inv));
 	if (rate_unit)
 		json_object_set_new(root, "rate_unit", json_string(rate_unit));
-	if (burst && burst != 5) {
-		json_object_set_new(root, "burst", json_integer(burst));
-		if (burst_unit)
-			json_object_set_new(root, "burst_unit",
-					    json_string(burst_unit));
-	}
+	if (burst_unit)
+		json_object_set_new(root, "burst_unit",
+				    json_string(burst_unit));
 
 	return json_pack("{s:o}", "limit", root);
 }
tests/py/any/limit.t.json.output new file +277 -0

277 lines not on this page · raw message

Signature · 1 line
2.28.0