]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: py: fix inet/ip_tcp.t test
authorJeremy Sowden <jeremy@azazel.net>
Tue, 21 Dec 2021 19:36:49 +0000 (19:36 +0000)
committerFlorian Westphal <fw@strlen.de>
Sat, 15 Jan 2022 16:02:39 +0000 (17:02 +0100)
Contrary to the comment and expected output, nft does _not_ eliminate
the redundant `ip protocol` expression from the second test.  Dependency
elimination requires a higher level expression.  `ip saddr` cannot lead
to the elimination of `ip protocol` since they are both L3 expressions.
`tcp dport` cannot because although `ip saddr` and `ip protocol` both
imply that the L3 protocol is `ip`, only protocol matches are stored as
dependencies, so the redundancy is not apparent, and in fact,
`payload_may_dependency_kill` explicitly checks for the combination of
inet, bridge or netdev family, L4 expression and L3 ipv4 or ipv6
dependency and returns false.

Correct the expected output and comment.

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
Signed-off-by: Florian Westphal <fw@strlen.de>
tests/py/inet/ip_tcp.t
tests/py/inet/ip_tcp.t.json.output

index ab76ffa90a9cbab1ea8315511cb92bce3cb5ca4c..03bafc09853654fd0e0b0878bdf108bd6a921673 100644 (file)
@@ -9,8 +9,8 @@
 # must not remove ip dependency -- ONLY ipv4 packets should be matched
 ip protocol tcp tcp dport 22;ok;ip protocol 6 tcp dport 22
 
-# can remove it here, ip protocol is implied via saddr.
-ip protocol tcp ip saddr 1.2.3.4 tcp dport 22;ok;ip saddr 1.2.3.4 tcp dport 22
+# could in principle remove it here since ipv4 is implied via saddr.
+ip protocol tcp ip saddr 1.2.3.4 tcp dport 22;ok;ip protocol 6 ip saddr 1.2.3.4 tcp dport 22
 
 # but not here.
 ip protocol tcp counter ip saddr 1.2.3.4 tcp dport 22;ok;ip protocol 6 counter ip saddr 1.2.3.4 tcp dport 22
index 4a6a05d7f10aa7e80e8a24e380d0d841893d6f70..acad8b1fae767de25834237f7e61db9a5662a983 100644 (file)
 
 # ip protocol tcp ip saddr 1.2.3.4 tcp dport 22
 [
+    {
+        "match": {
+            "left": {
+                "payload": {
+                    "field": "protocol",
+                    "protocol": "ip"
+                }
+            },
+           "op": "==",
+            "right": 6
+        }
+    },
     {
         "match": {
             "left": {