]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
json: Do not abbreviate reject statement object
authorPhil Sutter <phil@nwl.cc>
Tue, 2 Feb 2021 18:47:46 +0000 (19:47 +0100)
committerPhil Sutter <phil@nwl.cc>
Wed, 3 Feb 2021 10:31:30 +0000 (11:31 +0100)
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.

Signed-off-by: Phil Sutter <phil@nwl.cc>
src/json.c
tests/py/bridge/reject.t.json.output
tests/py/inet/reject.t.json.output
tests/py/ip/reject.t.json.output
tests/py/ip6/reject.t.json.output

index 8371714147de8b59f1b881f876e8a9032f6ebf68..0ccbbe8a75d2dff164272530cfbe2a0feb79997b 100644 (file)
@@ -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;
index 4f83f80374b9a5d2e42097509697cbf2ea35f60e..e01a63af5a354bc2f886613f66e46204170842c4 100644 (file)
@@ -1,103 +1,3 @@
-# reject with icmp type host-unreachable
-[
-    {
-        "reject": {
-            "expr": "host-unreachable",
-            "type": "icmp"
-        }
-    }
-]
-
-# reject with icmp type net-unreachable
-[
-    {
-        "reject": {
-            "expr": "net-unreachable",
-            "type": "icmp"
-        }
-    }
-]
-
-# reject with icmp type prot-unreachable
-[
-    {
-        "reject": {
-            "expr": "prot-unreachable",
-            "type": "icmp"
-        }
-    }
-]
-
-# reject with icmp type net-prohibited
-[
-    {
-        "reject": {
-            "expr": "net-prohibited",
-            "type": "icmp"
-        }
-    }
-]
-
-# reject with icmp type host-prohibited
-[
-    {
-        "reject": {
-            "expr": "host-prohibited",
-            "type": "icmp"
-        }
-    }
-]
-
-# reject with icmp type admin-prohibited
-[
-    {
-        "reject": {
-            "expr": "admin-prohibited",
-            "type": "icmp"
-        }
-    }
-]
-
-# reject with icmpv6 type no-route
-[
-    {
-        "reject": {
-            "expr": "no-route",
-            "type": "icmpv6"
-        }
-    }
-]
-
-# reject with icmpv6 type admin-prohibited
-[
-    {
-        "reject": {
-            "expr": "admin-prohibited",
-            "type": "icmpv6"
-        }
-    }
-]
-
-# reject with icmpv6 type addr-unreachable
-[
-    {
-        "reject": {
-            "expr": "addr-unreachable",
-            "type": "icmpv6"
-        }
-    }
-]
-
-# reject with icmpv6 type port-unreachable
-[
-    {
-         "reject": {
-            "expr": "port-unreachable",
-            "type": "icmpv6"
-        }
-    }
-]
-
 # mark 12345 ip protocol tcp reject with tcp reset
 [
     {
     }
 ]
 
-# reject with icmpx type port-unreachable
+# reject
 [
     {
-        "reject": null
+        "reject": {
+            "expr": "port-unreachable",
+            "type": "icmpx"
+        }
     }
 ]
 
         }
     }
 ]
+
+# ether type vlan reject
+[
+    {
+        "match": {
+            "left": {
+                "payload": {
+                    "field": "type",
+                    "protocol": "ether"
+                }
+            },
+            "op": "==",
+            "right": "vlan"
+        }
+    },
+    {
+        "reject": {
+            "expr": "port-unreachable",
+            "type": "icmpx"
+        }
+    }
+]
+
index 6e18b96bd807dfb41af494ea252bf2dc7f35d441..043617a721ea42b0cc14a1f6afc23ed974e2d4a9 100644 (file)
     }
 ]
 
-# 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"
+        }
     }
 ]
 
index b2529dd75fb51aeb978a3cefd2937926df6f9cc3..3917413dcfbe4fc7e4874392b9304418ba368bc0 100644 (file)
@@ -1,7 +1,10 @@
-# reject with icmp type port-unreachable
+# reject
 [
     {
-        "reject": null
+        "reject": {
+            "expr": "port-unreachable",
+            "type": "icmp"
+        }
     }
 ]
 
index 4e2058feceed6e504ee4abefe6572de4f38ad25c..04f12f56e9765bd59d5eb4515535ce32df0e9f62 100644 (file)
@@ -1,7 +1,10 @@
-# reject with icmpv6 type port-unreachable
+# reject
 [
     {
-        "reject": null
+        "reject": {
+            "expr": "port-unreachable",
+            "type": "icmpv6"
+        }
     }
 ]