Skip to contentSkip to conversation

tests: py: extend meta time coverage

PATCH In review Pablo Neira Ayuso 3 participants 3 messages Apr 8, 2022 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 tests: py: extend meta time coverage

Add meta time tests using < and > operands.

---
 tests/py/any/meta.t         |  2 ++
 tests/py/any/meta.t.json    | 36 ++++++++++++++++++++++++++++++++++++
 tests/py/any/meta.t.payload | 14 ++++++++++++++
 3 files changed, 52 insertions(+)
tests/py/any/meta.t +2 -0
index fcf4292d63c0..e3beea2eed6c 100644
@@ -208,6 +208,8 @@ meta time "2019-06-21 17:00:00" drop;ok
 meta time "2019-07-01 00:00:00" drop;ok
 meta time "2019-07-01 00:01:00" drop;ok
 meta time "2019-07-01 00:00:01" drop;ok
+meta time < "2022-07-01 11:00:00" accept;ok
+meta time > "2022-07-01 11:00:00" accept;ok
 meta day "Saturday" drop;ok
 meta day 6 drop;ok;meta day "Saturday" drop
 meta day "Satturday" drop;fail
tests/py/any/meta.t.json +36 -0
index b140aaaa0e1c..5472dc85cfb5 100644
@@ -2561,6 +2561,42 @@
     }
 ]
 
+# meta time < "2022-07-01 11:00:00" accept
+[
+    {
+        "match": {
+            "left": {
+                "meta": {
+                    "key": "time"
+                }
+            },
+            "op": "<",
+            "right": "2022-07-01 11:00:00"
+        }
+    },
+    {
+        "accept": null
+    }
+]
+
+# meta time > "2022-07-01 11:00:00" accept
+[
+    {
+        "match": {
+            "left": {
+                "meta": {
+                    "key": "time"
+                }
+            },
+            "op": ">",
+            "right": "2022-07-01 11:00:00"
+        }
+    },
+    {
+        "accept": null
+    }
+]
+
 # meta day "Saturday" drop
 [
     {
tests/py/any/meta.t.payload +14 -0
index d8351c275e64..1543906273c0 100644
@@ -1003,6 +1003,20 @@ ip meta-test input
   [ cmp eq reg 1 0x22eb8a00 0x15ad18e1 ]
   [ immediate reg 0 drop ]
 
+# meta time < "2022-07-01 11:00:00" accept
+ip test-ip4 input
+  [ meta load time => reg 1 ]
+  [ byteorder reg 1 = hton(reg 1, 8, 8) ]
+  [ cmp lt reg 1 0xf3a8fd16 0x00a07719 ]
+  [ immediate reg 0 accept ]
+
+# meta time > "2022-07-01 11:00:00" accept
+ip test-ip4 input
+  [ meta load time => reg 1 ]
+  [ byteorder reg 1 = hton(reg 1, 8, 8) ]
+  [ cmp gt reg 1 0xf3a8fd16 0x00a07719 ]
+  [ immediate reg 0 accept ]
+
 # meta day "Saturday" drop
 ip test-ip4 input
   [ meta load day => reg 1 ]
Signature · 1 line
2.30.2
#1 lore raw

By the way, I have just noticed that while this gives an error on 1.0.2:

    add rule inet filter input iif lo time < "2022-07-01 11:00" accept

This does not:

    add rule inet filter input iif lo meta time < "2022-07-01 11:00" accept

The use of 'meta' in front of 'time' works around the bug.

Should the tests include a few statements *without* 'meta'?

-Martin

Quoted 98 lines · Pablo Neira Ayuso

Add meta time tests using < and > operands.

---
 tests/py/any/meta.t         |  2 ++
 tests/py/any/meta.t.json    | 36 ++++++++++++++++++++++++++++++++++++
 tests/py/any/meta.t.payload | 14 ++++++++++++++
 3 files changed, 52 insertions(+)
tests/py/any/meta.t +2 -0
index fcf4292d63c0..e3beea2eed6c 100644
@@ -208,6 +208,8 @@ meta time "2019-06-21 17:00:00" drop;ok
 meta time "2019-07-01 00:00:00" drop;ok
 meta time "2019-07-01 00:01:00" drop;ok
 meta time "2019-07-01 00:00:01" drop;ok
+meta time < "2022-07-01 11:00:00" accept;ok
+meta time > "2022-07-01 11:00:00" accept;ok
 meta day "Saturday" drop;ok
 meta day 6 drop;ok;meta day "Saturday" drop
 meta day "Satturday" drop;fail
tests/py/any/meta.t.json +36 -0
index b140aaaa0e1c..5472dc85cfb5 100644
@@ -2561,6 +2561,42 @@
     }
 ]
 
+# meta time < "2022-07-01 11:00:00" accept
+[
+    {
+        "match": {
+            "left": {
+                "meta": {
+                    "key": "time"
+                }
+            },
+            "op": "<",
+            "right": "2022-07-01 11:00:00"
+        }
+    },
+    {
+        "accept": null
+    }
+]
+
+# meta time > "2022-07-01 11:00:00" accept
+[
+    {
+        "match": {
+            "left": {
+                "meta": {
+                    "key": "time"
+                }
+            },
+            "op": ">",
+            "right": "2022-07-01 11:00:00"
+        }
+    },
+    {
+        "accept": null
+    }
+]
+
 # meta day "Saturday" drop
 [
     {
tests/py/any/meta.t.payload +14 -1
index d8351c275e64..1543906273c0 100644
@@ -1003,6 +1003,20 @@ ip meta-test input
   [ cmp eq reg 1 0x22eb8a00 0x15ad18e1 ]
   [ immediate reg 0 drop ]
 
+# meta time < "2022-07-01 11:00:00" accept
+ip test-ip4 input
+  [ meta load time => reg 1 ]
+  [ byteorder reg 1 = hton(reg 1, 8, 8) ]
+  [ cmp lt reg 1 0xf3a8fd16 0x00a07719 ]
+  [ immediate reg 0 accept ]
+
+# meta time > "2022-07-01 11:00:00" accept
+ip test-ip4 input
+  [ meta load time => reg 1 ]
+  [ byteorder reg 1 = hton(reg 1, 8, 8) ]
+  [ cmp gt reg 1 0xf3a8fd16 0x00a07719 ]
+  [ immediate reg 0 accept ]
+
 # meta day "Saturday" drop
 ip test-ip4 input
   [ meta load day => reg 1 ]
--

2.30.2

maintainer
#2 lore raw
Quoted 11 lines · Martin Gignac

By the way, I have just noticed that while this gives an error on 1.0.2:

    add rule inet filter input iif lo time < "2022-07-01 11:00" accept

This does not:

    add rule inet filter input iif lo meta time < "2022-07-01 11:00" accept

The use of 'meta' in front of 'time' works around the bug.

Should the tests include a few statements *without* 'meta'?

Yes, please consider sending a patch to extend the tests.