Skip to contentSkip to conversation

json: Do not abbreviate reject statement object

PATCH New Phil Sutter 1 participant 1 message Feb 2, 2021 netfilter

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/1 json: Do not abbreviate reject statement object

No need to reduce output size, also this way output is more predictable.

While being at it, drop some pointless chunks from tests/py/bridge/reject.t.json.output.

---
 src/json.c                           |   8 --
 tests/py/bridge/reject.t.json.output | 130 ++++++---------------------
 tests/py/inet/reject.t.json.output   |  15 ++--
 tests/py/ip/reject.t.json.output     |   7 +-
 tests/py/ip6/reject.t.json.output    |   7 +-
 5 files changed, 47 insertions(+), 120 deletions(-)
src/json.c +0 -8
index 8371714147de8..0ccbbe8a75d2d 100644
@@ -1380,24 +1380,16 @@ json_t *reject_stmt_json(const struct stmt *stmt, struct output_ctx *octx)
 		type = "tcp reset";
 		break;
 	case NFT_REJECT_ICMPX_UNREACH:
-		if (stmt->reject.icmp_code == NFT_REJECT_ICMPX_PORT_UNREACH)
-			break;
 		type = "icmpx";
 		jexpr = expr_print_json(stmt->reject.expr, octx);
 		break;
 	case NFT_REJECT_ICMP_UNREACH:
 		switch (stmt->reject.family) {
 		case NFPROTO_IPV4:
-			if (!stmt->reject.verbose_print &&
-			    stmt->reject.icmp_code == ICMP_PORT_UNREACH)
-				break;
 			type = "icmp";
 			jexpr = expr_print_json(stmt->reject.expr, octx);
 			break;
 		case NFPROTO_IPV6:
-			if (!stmt->reject.verbose_print &&
-			    stmt->reject.icmp_code == ICMP6_DST_UNREACH_NOPORT)
-				break;
 			type = "icmpv6";
 			jexpr = expr_print_json(stmt->reject.expr, octx);
 			break;
tests/py/bridge/reject.t.json.output +28 -102

144 lines not on this page · raw message

tests/py/inet/reject.t.json.output +9 -6
index 6e18b96bd807d..043617a721ea4 100644
@@ -25,30 +25,33 @@
     }
 ]
 
-# meta nfproto ipv4 reject
+# reject
 [
     {
         "reject": {
             "expr": "port-unreachable",
-            "type": "icmp"
+            "type": "icmpx"
         }
     }
 ]
 
-# meta nfproto ipv6 reject
+# meta nfproto ipv4 reject
 [
     {
         "reject": {
             "expr": "port-unreachable",
-            "type": "icmpv6"
+            "type": "icmp"
         }
     }
 ]
 
-# reject with icmpx type port-unreachable
+# meta nfproto ipv6 reject
 [
     {
-        "reject": null
+        "reject": {
+            "expr": "port-unreachable",
+            "type": "icmpv6"
+        }
     }
 ]
 
tests/py/ip/reject.t.json.output +5 -2
index b2529dd75fb51..3917413dcfbe4 100644
@@ -1,7 +1,10 @@
-# reject with icmp type port-unreachable
+# reject
 [
     {
-        "reject": null
+        "reject": {
+            "expr": "port-unreachable",
+            "type": "icmp"
+        }
     }
 ]
 
tests/py/ip6/reject.t.json.output +5 -2
index 4e2058feceed6..04f12f56e9765 100644
@@ -1,7 +1,10 @@
-# reject with icmpv6 type port-unreachable
+# reject
 [
     {
-        "reject": null
+        "reject": {
+            "expr": "port-unreachable",
+            "type": "icmpv6"
+        }
     }
 ]
 
Signature · 1 line
2.28.0