]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
json: icmp: move expected parts to json.output
authorFlorian Westphal <fw@strlen.de>
Thu, 21 Jan 2021 15:46:27 +0000 (16:46 +0100)
committerFlorian Westphal <fw@strlen.de>
Tue, 26 Jan 2021 13:30:16 +0000 (14:30 +0100)
Phil Sutter says:
In general, *.t.json files should contain JSON equivalents for rules as
they are *input* into nft. So we want them to be as close to the
introductory standard syntax comment as possible.

Undo earlier change and place the expected dependency added by
nft internals to json.output rather than icmp.t.json.

Signed-off-by: Florian Westphal <fw@strlen.de>
tests/py/ip/icmp.t.json
tests/py/ip/icmp.t.json.output

index 480740afb52512b5436a675e3c41d6079bb17a70..9691f0727f5eb0ea54ab6f9ea199e6c450991902 100644 (file)
             "op": "==",
             "right": {
                 "set": [
-                    "prot-unreachable",
-                    "frag-needed",
+                    2,
+                    4,
                     33,
                     54,
                     56
 
 # icmp id 1245 log
 [
-    {
-        "match": {
-            "left": {
-                "payload": {
-                    "field": "type",
-                    "protocol": "icmp"
-                }
-            },
-            "op": "==",
-            "right": {
-                "set": [
-                    "echo-reply",
-                    "echo-request"
-                ]
-            }
-        }
-    },
     {
         "match": {
             "left": {
 
 # icmp id 22
 [
-    {
-        "match": {
-            "left": {
-                "payload": {
-                    "field": "type",
-                    "protocol": "icmp"
-                }
-            },
-            "op": "==",
-            "right": {
-                "set": [
-                    "echo-reply",
-                    "echo-request"
-                ]
-            }
-        }
-    },
     {
         "match": {
             "left": {
 
 # icmp id != 233
 [
-    {
-        "match": {
-            "left": {
-                "payload": {
-                    "field": "type",
-                    "protocol": "icmp"
-                }
-            },
-            "op": "==",
-            "right": {
-                "set": [
-                    "echo-reply",
-                    "echo-request"
-                ]
-            }
-        }
-    },
     {
         "match": {
             "left": {
 
 # icmp id { 33-55}
 [
-    {
-        "match": {
-            "left": {
-                "payload": {
-                    "field": "type",
-                    "protocol": "icmp"
-                }
-            },
-            "op": "==",
-            "right": {
-                "set": [
-                    "echo-reply",
-                    "echo-request"
-                ]
-            }
-        }
-    },
     {
         "match": {
             "left": {
         }
     }
 ]
-
index 2391983ab82603faa0841531df59fb0de974981b..5a075858e8fae6bdd1015520ae3aa579446dcb84 100644 (file)
@@ -1,4 +1,28 @@
-# icmp type {echo-reply, destination-unreachable, source-quench, redirect, echo-request, time-exceeded, parameter-problem, timestamp-request, timestamp-reply, info-request, info-reply, address-mask-request, address-mask-reply, router-advertisement, router-solicitation} accept
+# icmp code { 2, 4, 54, 33, 56}
+[
+    {
+        "match": {
+            "left": {
+                "payload": {
+                    "field": "code",
+                    "protocol": "icmp"
+                }
+            },
+            "op": "==",
+            "right": {
+                "set": [
+                    "prot-unreachable",
+                    "frag-needed",
+                    33,
+                    54,
+                    56
+                ]
+            }
+        }
+    }
+]
+
+# icmp id 1245 log
 [
     {
         "match": {
                     "protocol": "icmp"
                 }
             },
-           "op": "==",
+            "op": "==",
             "right": {
                 "set": [
                     "echo-reply",
-                    "destination-unreachable",
-                    "source-quench",
-                    "redirect",
-                    "echo-request",
-                    "router-advertisement",
-                    "router-solicitation",
-                    "time-exceeded",
-                    "parameter-problem",
-                    "timestamp-request",
-                    "timestamp-reply",
-                    "info-request",
-                    "info-reply",
-                    "address-mask-request",
-                    "address-mask-reply"
+                    "echo-request"
                 ]
             }
         }
     },
     {
-        "accept": null
+        "match": {
+            "left": {
+                "payload": {
+                    "field": "id",
+                    "protocol": "icmp"
+                }
+            },
+            "op": "==",
+            "right": 1245
+        }
+    },
+    {
+        "log": null
     }
 ]
 
-# icmp code { 2, 4, 54, 33, 56}
+# icmp id 22
 [
     {
         "match": {
             "left": {
                 "payload": {
-                    "field": "code",
+                    "field": "type",
                     "protocol": "icmp"
                 }
             },
             "op": "==",
             "right": {
                 "set": [
-                    "prot-unreachable",
-                    "frag-needed",
-                    33,
-                    54,
-                    56
+                    "echo-reply",
+                    "echo-request"
                 ]
             }
         }
+    },
+    {
+        "match": {
+            "left": {
+                "payload": {
+                    "field": "id",
+                    "protocol": "icmp"
+                }
+            },
+            "op": "==",
+            "right": 22
+        }
     }
 ]
 
-# icmp checksum { 1111, 222, 343} accept
+# icmp id != 233
 [
     {
         "match": {
             "left": {
                 "payload": {
-                    "field": "checksum",
+                    "field": "type",
                     "protocol": "icmp"
                 }
             },
-           "op": "==",
+            "op": "==",
             "right": {
                 "set": [
-                    222,
-                    343,
-                    1111
+                    "echo-reply",
+                    "echo-request"
                 ]
             }
         }
     },
     {
-        "accept": null
+        "match": {
+            "left": {
+                "payload": {
+                    "field": "id",
+                    "protocol": "icmp"
+                }
+            },
+            "op": "!=",
+            "right": 233
+        }
     }
 ]
 
-# icmp checksum != { 1111, 222, 343} accept
+# icmp id { 33-55}
 [
     {
         "match": {
             "left": {
                 "payload": {
-                    "field": "checksum",
+                    "field": "type",
                     "protocol": "icmp"
                 }
             },
-            "op": "!=",
+            "op": "==",
             "right": {
                 "set": [
-                    222,
-                    343,
-                    1111
+                    "echo-reply",
+                    "echo-request"
                 ]
             }
         }
     },
     {
-        "accept": null
+        "match": {
+            "left": {
+                "payload": {
+                    "field": "id",
+                    "protocol": "icmp"
+                }
+            },
+            "op": "==",
+            "right": {
+                "set": [
+                    {
+                        "range": [
+                            33,
+                            55
+                        ]
+                    }
+                ]
+            }
+        }
     }
 ]
 
+