diff mbox series

[v2,4/7] nftables: tests/py: Add tests for day and hour

Message ID 20190626204402.5257-4-a@juaristi.eus
State Changes Requested
Delegated to: Pablo Neira
Headers show
Series [v2,1/7] nftables: meta: Introduce new conditions 'time', 'day' and 'hour' | expand

Commit Message

Ander Juaristi June 26, 2019, 8:43 p.m. UTC
Signed-off-by: Ander Juaristi <a@juaristi.eus>
---
 tests/py/ip/meta.t         |  2 ++
 tests/py/ip/meta.t.payload | 12 ++++++++++++
 2 files changed, 14 insertions(+)

Comments

Florian Westphal June 26, 2019, 9:06 p.m. UTC | #1
Ander Juaristi <a@juaristi.eus> wrote:
> index 322c087..ad00a1a 100644
> --- a/tests/py/ip/meta.t.payload
> +++ b/tests/py/ip/meta.t.payload
> @@ -1,3 +1,15 @@
> +# meta day "Saturday" drop
> +ip test-ip4 input
> +  [ meta load unknown => reg 1 ]

This 'unknown' is coming from libnftnl.
You will need to make a small patch that adds the new
keys to the string table, similar to

commit 179a43db739b8151d608452d01b66f65ac8aa5e5
meta: secpath support

in libnftnl.
diff mbox series

Patch

diff --git a/tests/py/ip/meta.t b/tests/py/ip/meta.t
index 4db8835..02ba11d 100644
--- a/tests/py/ip/meta.t
+++ b/tests/py/ip/meta.t
@@ -3,6 +3,8 @@ 
 *ip;test-ip4;input
 
 icmp type echo-request;ok
+meta day "Saturday" drop;ok;meta day "Saturday" drop
+meta hour "17:00" drop;ok;meta hour "17:00" drop
 meta l4proto icmp icmp type echo-request;ok;icmp type echo-request
 meta l4proto ipv6-icmp icmpv6 type nd-router-advert;ok;icmpv6 type nd-router-advert
 meta l4proto 58 icmpv6 type nd-router-advert;ok;icmpv6 type nd-router-advert
diff --git a/tests/py/ip/meta.t.payload b/tests/py/ip/meta.t.payload
index 322c087..ad00a1a 100644
--- a/tests/py/ip/meta.t.payload
+++ b/tests/py/ip/meta.t.payload
@@ -1,3 +1,15 @@ 
+# meta day "Saturday" drop
+ip test-ip4 input
+  [ meta load unknown => reg 1 ]
+  [ cmp eq reg 1 0x00000006 ]
+  [ immediate reg 0 drop ]
+
+# meta hour "17:00" drop
+ip test-ip4 input
+  [ meta load unknown => reg 1 ]
+  [ cmp eq reg 1 0x0000d2f0 0x00000000 ]
+  [ immediate reg 0 drop ]
+
 # icmp type echo-request
 ip test-ip4 input
   [ meta load l4proto => reg 1 ]