Skip to contentSkip to conversation

tests: monitor: Fix monitor JSON output for insert command

PATCH In review Phil Sutter 1 participant 5 messages Aug 29, 2023 netfilter

lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/4 tests: monitor: Fix monitor JSON output for insert command

Looks like commit ba786ac758fba ("tests: monitor: update insert and replace commands") missed to also fix expected JSON output.

Fixes 48d20b8cf162e ("monitor: honor NLM_F_APPEND flag for rules")
---
 tests/monitor/testcases/simple.t | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/monitor/testcases/simple.t +1 -1
index 2d9c92de25dd3..c1c7bcfc08beb 100644
@@ -15,7 +15,7 @@ J {"add": {"rule": {"family": "ip", "table": "t", "chain": "c", "handle": 0, "ex
 
 I insert rule ip t c counter accept
 O insert rule ip t c counter packets 0 bytes 0 accept
-J {"add": {"rule": {"family": "ip", "table": "t", "chain": "c", "handle": 0, "expr": [{"counter": {"packets": 0, "bytes": 0}}, {"accept": null}]}}}
+J {"insert": {"rule": {"family": "ip", "table": "t", "chain": "c", "handle": 0, "expr": [{"counter": {"packets": 0, "bytes": 0}}, {"accept": null}]}}}
 
 I replace rule ip t c handle 2 accept comment "foo bar"
 O delete rule ip t c handle 2
Signature · 1 line
2.41.0
author reviewer
#1 lore raw

PATCH 2/4 tests: monitor: Fix time format in ct timeout test

The old "plain" numbers are still accepted (and assumed to be in seconds), but output will use units which is unexpected due to 'O -'. Adjust input instead of adding this subtly different output line.

Fixes 5c25c5a35cbd2 ("parser: allow ct timeouts to use time_spec values")
---
 tests/monitor/testcases/object.t | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/monitor/testcases/object.t +1 -1
index 2afe33c812571..53a9f8c59836b 100644
@@ -37,7 +37,7 @@ I delete ct helper ip t cth
 O -
 J {"delete": {"ct helper": {"family": "ip", "name": "cth", "table": "t", "handle": 0, "type": "sip", "protocol": "tcp", "l3proto": "ip"}}}
 
-I add ct timeout ip t ctt { protocol udp; l3proto ip; policy = { unreplied : 15, replied : 12 }; }
+I add ct timeout ip t ctt { protocol udp; l3proto ip; policy = { unreplied : 15s, replied : 12s }; }
 O -
 J {"add": {"ct timeout": {"family": "ip", "name": "ctt", "table": "t", "handle": 0, "protocol": "udp", "l3proto": "ip", "policy": {"unreplied": 15, "replied": 12}}}}
 
Signature · 1 line
2.41.0
author reviewer
#2 lore raw

PATCH 3/4 tests: monitor: Fix for wrong syntax in set-interval.t

In reply to Phil Sutter

Expected JSON output must be prefixed 'J'.

Fixes 7ab453a033c9a ("monitor: do not call interval_map_decompose() for concat intervals")
---
 tests/monitor/testcases/set-interval.t | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/monitor/testcases/set-interval.t +1 -1
index b0649cdfe01e6..5053c596b3b1b 100644
@@ -27,4 +27,4 @@ J {"add": {"rule": {"family": "ip", "table": "t", "chain": "c", "handle": 0, "ex
 # ... and anon concat range
 I add rule ip t c ether saddr . ip saddr { 08:00:27:40:f7:09 . 192.168.56.10-192.168.56.12 }
 O -
-{"add": {"rule": {"family": "ip", "table": "t", "chain": "c", "handle": 0, "expr": [{"match": {"op": "==", "left": {"concat": [{"payload": {"protocol": "ether", "field": "saddr"}}, {"payload": {"protocol": "ip", "field": "saddr"}}]}, "right": {"set": [{"concat": ["08:00:27:40:f7:09", {"range": ["192.168.56.10", "192.168.56.12"]}]}]}}}]}}}
+J {"add": {"rule": {"family": "ip", "table": "t", "chain": "c", "handle": 0, "expr": [{"match": {"op": "==", "left": {"concat": [{"payload": {"protocol": "ether", "field": "saddr"}}, {"payload": {"protocol": "ip", "field": "saddr"}}]}, "right": {"set": [{"concat": ["08:00:27:40:f7:09", {"range": ["192.168.56.10", "192.168.56.12"]}]}]}}}]}}}
Signature · 1 line
2.41.0
author reviewer
#3 lore raw

PATCH 4/4 tests: monitor: Fix for wrong ordering in expected JSON output

In reply to Phil Sutter

Adjust JSON for delete before add for replace after respective kernel fix, too.

Fixes ba786ac758fba ("tests: monitor: update insert and replace commands")
---
 tests/monitor/testcases/simple.t | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/monitor/testcases/simple.t +1 -1
index c1c7bcfc08beb..67be5c85ab85d 100644
@@ -20,8 +20,8 @@ J {"insert": {"rule": {"family": "ip", "table": "t", "chain": "c", "handle": 0,
 I replace rule ip t c handle 2 accept comment "foo bar"
 O delete rule ip t c handle 2
 O add rule ip t c handle 5 accept comment "foo bar"
-J {"add": {"rule": {"family": "ip", "table": "t", "chain": "c", "handle": 0, "comment": "foo bar", "expr": [{"accept": null}]}}}
 J {"delete": {"rule": {"family": "ip", "table": "t", "chain": "c", "handle": 0, "expr": [{"accept": null}]}}}
+J {"add": {"rule": {"family": "ip", "table": "t", "chain": "c", "handle": 0, "comment": "foo bar", "expr": [{"accept": null}]}}}
 
 I add counter ip t cnt
 O add counter ip t cnt { packets 0 bytes 0 }
Signature · 1 line
2.41.0