From: Florian Westphal <fw@strlen.de>
To: <netfilter-devel@vger.kernel.org>
Cc: Florian Westphal <fw@strlen.de>
Subject: [PATCH nft 2/2] tests: add test case for ttl/protocol set
Date: Wed, 16 Aug 2017 19:01:56 +0200 [thread overview]
Message-ID: <20170816170156.11594-2-fw@strlen.de> (raw)
In-Reply-To: <20170816170156.11594-1-fw@strlen.de>
nft .. ip ttl set 42
did set the protocol field and left ttl alone, add test cases for this.
Signed-off-by: Florian Westphal <fw@strlen.de>
---
tests/py/ip/ip.t | 2 ++
tests/py/ip/ip.t.payload | 16 ++++++++++++++++
tests/py/ip/ip.t.payload.inet | 20 ++++++++++++++++++++
tests/py/ip/ip.t.payload.netdev | 20 ++++++++++++++++++++
4 files changed, 58 insertions(+)
diff --git a/tests/py/ip/ip.t b/tests/py/ip/ip.t
index 9ab15df63a3d..f779dd9aa572 100644
--- a/tests/py/ip/ip.t
+++ b/tests/py/ip/ip.t
@@ -127,6 +127,8 @@ iif "lo" ip checksum set 0;ok
iif "lo" ip id set 0;ok
iif "lo" ip ecn set 1;ok;iif "lo" ip ecn set ect1
iif "lo" ip ecn set ce;ok
+iif "lo" ip ttl set 23;ok
+iif "lo" ip protocol set 1;ok
iif "lo" ip dscp set af23;ok
iif "lo" ip dscp set cs0;ok
diff --git a/tests/py/ip/ip.t.payload b/tests/py/ip/ip.t.payload
index cd54ae0fea7e..dcf5e348c9e9 100644
--- a/tests/py/ip/ip.t.payload
+++ b/tests/py/ip/ip.t.payload
@@ -576,3 +576,19 @@ ip test-ip4 input
[ bitwise reg 1 = (reg=1 & 0x000003ff ) ^ 0x00000000 ]
[ payload write reg 1 => 2b @ network header + 0 csum_type 1 csum_off 10 csum_flags 0x0 ]
+# iif "lo" ip ttl set 23
+ip test-ip4 input
+ [ meta load iif => reg 1 ]
+ [ cmp eq reg 1 0x00000001 ]
+ [ payload load 2b @ network header + 8 => reg 1 ]
+ [ bitwise reg 1 = (reg=1 & 0x0000ff00 ) ^ 0x00000017 ]
+ [ payload write reg 1 => 2b @ network header + 8 csum_type 1 csum_off 10 csum_flags 0x0 ]
+
+# iif "lo" ip protocol set 1
+ip test-ip4 input
+ [ meta load iif => reg 1 ]
+ [ cmp eq reg 1 0x00000001 ]
+ [ payload load 2b @ network header + 8 => reg 1 ]
+ [ bitwise reg 1 = (reg=1 & 0x000000ff ) ^ 0x00000100 ]
+ [ payload write reg 1 => 2b @ network header + 8 csum_type 1 csum_off 10 csum_flags 0x1 ]
+
diff --git a/tests/py/ip/ip.t.payload.inet b/tests/py/ip/ip.t.payload.inet
index 64606d956e10..96a77b5969a2 100644
--- a/tests/py/ip/ip.t.payload.inet
+++ b/tests/py/ip/ip.t.payload.inet
@@ -750,3 +750,23 @@ inet test-inet input
[ bitwise reg 1 = (reg=1 & 0x000003ff ) ^ 0x00000000 ]
[ payload write reg 1 => 2b @ network header + 0 csum_type 1 csum_off 10 csum_flags 0x0 ]
+# iif "lo" ip ttl set 23
+inet test-inet input
+ [ meta load iif => reg 1 ]
+ [ cmp eq reg 1 0x00000001 ]
+ [ meta load nfproto => reg 1 ]
+ [ cmp eq reg 1 0x00000002 ]
+ [ payload load 2b @ network header + 8 => reg 1 ]
+ [ bitwise reg 1 = (reg=1 & 0x0000ff00 ) ^ 0x00000017 ]
+ [ payload write reg 1 => 2b @ network header + 8 csum_type 1 csum_off 10 csum_flags 0x0 ]
+
+# iif "lo" ip protocol set 1
+inet test-inet input
+ [ meta load iif => reg 1 ]
+ [ cmp eq reg 1 0x00000001 ]
+ [ meta load nfproto => reg 1 ]
+ [ cmp eq reg 1 0x00000002 ]
+ [ payload load 2b @ network header + 8 => reg 1 ]
+ [ bitwise reg 1 = (reg=1 & 0x000000ff ) ^ 0x00000100 ]
+ [ payload write reg 1 => 2b @ network header + 8 csum_type 1 csum_off 10 csum_flags 0x1 ]
+
diff --git a/tests/py/ip/ip.t.payload.netdev b/tests/py/ip/ip.t.payload.netdev
index acfa1eab5979..45d29b3491cc 100644
--- a/tests/py/ip/ip.t.payload.netdev
+++ b/tests/py/ip/ip.t.payload.netdev
@@ -850,3 +850,23 @@ netdev test-netdev ingress
[ bitwise reg 1 = (reg=1 & 0x000003ff ) ^ 0x00000000 ]
[ payload write reg 1 => 2b @ network header + 0 csum_type 1 csum_off 10 csum_flags 0x0 ]
+# iif "lo" ip ttl set 23
+netdev test-netdev ingress
+ [ meta load iif => reg 1 ]
+ [ cmp eq reg 1 0x00000001 ]
+ [ meta load protocol => reg 1 ]
+ [ cmp eq reg 1 0x00000008 ]
+ [ payload load 2b @ network header + 8 => reg 1 ]
+ [ bitwise reg 1 = (reg=1 & 0x0000ff00 ) ^ 0x00000017 ]
+ [ payload write reg 1 => 2b @ network header + 8 csum_type 1 csum_off 10 csum_flags 0x0 ]
+
+# iif "lo" ip protocol set 1
+netdev test-netdev ingress
+ [ meta load iif => reg 1 ]
+ [ cmp eq reg 1 0x00000001 ]
+ [ meta load protocol => reg 1 ]
+ [ cmp eq reg 1 0x00000008 ]
+ [ payload load 2b @ network header + 8 => reg 1 ]
+ [ bitwise reg 1 = (reg=1 & 0x000000ff ) ^ 0x00000100 ]
+ [ payload write reg 1 => 2b @ network header + 8 csum_type 1 csum_off 10 csum_flags 0x1 ]
+
--
2.13.0
next prev parent reply other threads:[~2017-08-16 17:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-16 17:01 [PATCH nft 1/2] evaluate: shift immediate value when adjusting size for csum fixup Florian Westphal
2017-08-16 17:01 ` Florian Westphal [this message]
2017-08-17 10:01 ` [PATCH nft 2/2] tests: add test case for ttl/protocol set Pablo Neira Ayuso
2017-08-17 10:00 ` [PATCH nft 1/2] evaluate: shift immediate value when adjusting size for csum fixup Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170816170156.11594-2-fw@strlen.de \
--to=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).