From 99f1ef9abba353b0c33b4db21e8f45e4f638c5bf Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Tue, 21 Dec 2021 19:36:49 +0000 Subject: tests: py: fix inet/ip_tcp.t test 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 Signed-off-by: Florian Westphal --- tests/py/inet/ip_tcp.t | 4 ++-- tests/py/inet/ip_tcp.t.json.output | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'tests/py') diff --git a/tests/py/inet/ip_tcp.t b/tests/py/inet/ip_tcp.t index ab76ffa9..03bafc09 100644 --- a/tests/py/inet/ip_tcp.t +++ b/tests/py/inet/ip_tcp.t @@ -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 diff --git a/tests/py/inet/ip_tcp.t.json.output b/tests/py/inet/ip_tcp.t.json.output index 4a6a05d7..acad8b1f 100644 --- a/tests/py/inet/ip_tcp.t.json.output +++ b/tests/py/inet/ip_tcp.t.json.output @@ -28,6 +28,18 @@ # ip protocol tcp ip saddr 1.2.3.4 tcp dport 22 [ + { + "match": { + "left": { + "payload": { + "field": "protocol", + "protocol": "ip" + } + }, + "op": "==", + "right": 6 + } + }, { "match": { "left": { -- cgit v1.2.3