* [PATCH nft] tests: py: extend meta time coverage
@ 2022-04-08 8:33 Pablo Neira Ayuso
2022-04-08 12:26 ` Martin Gignac
0 siblings, 1 reply; 3+ messages in thread
From: Pablo Neira Ayuso @ 2022-04-08 8:33 UTC (permalink / raw)
To: netfilter-devel; +Cc: martin.gignac
Add meta time tests using < and > operands.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
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(+)
diff --git a/tests/py/any/meta.t b/tests/py/any/meta.t
index fcf4292d63c0..e3beea2eed6c 100644
--- a/tests/py/any/meta.t
+++ b/tests/py/any/meta.t
@@ -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
diff --git a/tests/py/any/meta.t.json b/tests/py/any/meta.t.json
index b140aaaa0e1c..5472dc85cfb5 100644
--- a/tests/py/any/meta.t.json
+++ b/tests/py/any/meta.t.json
@@ -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
[
{
diff --git a/tests/py/any/meta.t.payload b/tests/py/any/meta.t.payload
index d8351c275e64..1543906273c0 100644
--- a/tests/py/any/meta.t.payload
+++ b/tests/py/any/meta.t.payload
@@ -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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH nft] tests: py: extend meta time coverage
2022-04-08 8:33 [PATCH nft] tests: py: extend meta time coverage Pablo Neira Ayuso
@ 2022-04-08 12:26 ` Martin Gignac
2022-04-08 12:40 ` Florian Westphal
0 siblings, 1 reply; 3+ messages in thread
From: Martin Gignac @ 2022-04-08 12:26 UTC (permalink / raw)
To: netfilter-devel
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
On Fri, Apr 8, 2022 at 4:33 AM Pablo Neira Ayuso <pablo@netfilter.org> wrote:
>
> Add meta time tests using < and > operands.
>
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> ---
> 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(+)
>
> diff --git a/tests/py/any/meta.t b/tests/py/any/meta.t
> index fcf4292d63c0..e3beea2eed6c 100644
> --- a/tests/py/any/meta.t
> +++ b/tests/py/any/meta.t
> @@ -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
> diff --git a/tests/py/any/meta.t.json b/tests/py/any/meta.t.json
> index b140aaaa0e1c..5472dc85cfb5 100644
> --- a/tests/py/any/meta.t.json
> +++ b/tests/py/any/meta.t.json
> @@ -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
> [
> {
> diff --git a/tests/py/any/meta.t.payload b/tests/py/any/meta.t.payload
> index d8351c275e64..1543906273c0 100644
> --- a/tests/py/any/meta.t.payload
> +++ b/tests/py/any/meta.t.payload
> @@ -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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH nft] tests: py: extend meta time coverage
2022-04-08 12:26 ` Martin Gignac
@ 2022-04-08 12:40 ` Florian Westphal
0 siblings, 0 replies; 3+ messages in thread
From: Florian Westphal @ 2022-04-08 12:40 UTC (permalink / raw)
To: Martin Gignac; +Cc: netfilter-devel
Martin Gignac <martin.gignac@gmail.com> wrote:
> 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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-08 12:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-08 8:33 [PATCH nft] tests: py: extend meta time coverage Pablo Neira Ayuso
2022-04-08 12:26 ` Martin Gignac
2022-04-08 12:40 ` Florian Westphal
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.