[nft PATCH 3/3] tests/py: Add missing meta tests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ensure invalid values are rejected. Also add basic positive tests for
{i,o}ifkind.

Signed-off-by: Phil Sutter <phil@xxxxxx>
---
 tests/py/any/meta.t         | 10 ++++++++++
 tests/py/any/meta.t.json    | 30 ++++++++++++++++++++++++++++++
 tests/py/any/meta.t.payload | 10 ++++++++++
 3 files changed, 50 insertions(+)

diff --git a/tests/py/any/meta.t b/tests/py/any/meta.t
index 4b3c604de110d..9771d9dd585a3 100644
--- a/tests/py/any/meta.t
+++ b/tests/py/any/meta.t
@@ -63,6 +63,7 @@ meta mark xor 0x03 != 0x01;ok;meta mark != 0x00000002
 
 meta iif "lo" accept;ok;iif "lo" accept
 meta iif != "lo" accept;ok;iif != "lo" accept
+meta iif 0;fail
 
 meta iifname "dummy0";ok;iifname "dummy0"
 meta iifname != "dummy0";ok;iifname != "dummy0"
@@ -78,9 +79,14 @@ meta iiftype != ether;ok
 meta iiftype ether;ok
 meta iiftype != ppp;ok
 meta iiftype ppp;ok
+meta iiftype 0xffff;fail
+
+meta iifkind "bond";ok
+meta iifkind "";fail
 
 meta oif "lo" accept;ok;oif "lo" accept
 meta oif != "lo" accept;ok;oif != "lo" accept
+meta oif 0;fail
 
 meta oifname "dummy0";ok;oifname "dummy0"
 meta oifname != "dummy0";ok;oifname != "dummy0"
@@ -93,6 +99,10 @@ meta oiftype {ether, ppp, ipip, ipip6, loopback, sit, ipgre};ok
 meta oiftype != {ether, ppp, ipip, ipip6, loopback, sit, ipgre};ok
 meta oiftype != ether;ok
 meta oiftype ether;ok
+meta oiftype 0xffff;fail
+
+meta oifkind "bond";ok
+meta oifkind "";fail
 
 meta skuid {"bin", "root", "daemon"} accept;ok;meta skuid { 0, 1, 2} accept
 meta skuid != {"bin", "root", "daemon"} accept;ok;meta skuid != { 1, 0, 2} accept
diff --git a/tests/py/any/meta.t.json b/tests/py/any/meta.t.json
index 447e553f8ba78..cff557f48a3ab 100644
--- a/tests/py/any/meta.t.json
+++ b/tests/py/any/meta.t.json
@@ -952,6 +952,21 @@
     }
 ]
 
+# meta iifkind "bond"
+[
+    {
+        "match": {
+            "left": {
+                "meta": {
+                    "key": "iifkind"
+                }
+            },
+            "op": "==",
+            "right": "bond"
+        }
+    }
+]
+
 # meta oif "lo" accept
 [
     {
@@ -1113,6 +1128,21 @@
     }
 ]
 
+# meta oifkind "bond"
+[
+    {
+        "match": {
+            "left": {
+                "meta": {
+                    "key": "oifkind"
+                }
+            },
+            "op": "==",
+            "right": "bond"
+        }
+    }
+]
+
 # meta oiftype ether
 [
     {
diff --git a/tests/py/any/meta.t.payload b/tests/py/any/meta.t.payload
index 1d8426de9632d..915101b3f70c4 100644
--- a/tests/py/any/meta.t.payload
+++ b/tests/py/any/meta.t.payload
@@ -263,6 +263,11 @@ ip test-ip4 input
   [ meta load iiftype => reg 1 ]
   [ cmp eq reg 1 0x00000200 ]
 
+# meta iifkind "bond"
+ip test-ip4 input 
+  [ meta load iifkind => reg 1 ]
+  [ cmp eq reg 1 0x646e6f62 0x00000000 0x00000000 0x00000000 ]
+
 # meta oif "lo" accept
 ip test-ip4 input
   [ meta load oif => reg 1 ]
@@ -329,6 +334,11 @@ ip test-ip4 input
   [ meta load oiftype => reg 1 ]
   [ cmp eq reg 1 0x00000001 ]
 
+# meta oifkind "bond"
+ip test-ip4 input 
+  [ meta load oifkind => reg 1 ]
+  [ cmp eq reg 1 0x646e6f62 0x00000000 0x00000000 0x00000000 ]
+
 # meta skuid {"bin", "root", "daemon"} accept
 __set%d test-ip4 3
 __set%d test-ip4 0
-- 
2.22.0




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux