From: Florian Westphal <fw@strlen.de>
To: <netfilter-devel@vger.kernel.org>
Cc: Florian Westphal <fw@strlen.de>
Subject: [PATCH nft 4/4] netlink_delinarize: shift constant for ranges too
Date: Wed, 9 Mar 2016 00:09:48 +0100 [thread overview]
Message-ID: <1457478588-12592-4-git-send-email-fw@strlen.de> (raw)
In-Reply-To: <1457478588-12592-1-git-send-email-fw@strlen.de>
... else rule like vlan pcp 1-3 won't work and will be displayed
as 0-0 (reverse direction already works since range is represented
as two lte/gte compare expressions).
Signed-off-by: Florian Westphal <fw@strlen.de>
---
src/netlink_linearize.c | 2 ++
tests/py/bridge/vlan.t.payload | 4 ++--
tests/py/bridge/vlan.t.payload.netdev | 4 ++--
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/netlink_linearize.c b/src/netlink_linearize.c
index 49b4676..bb51de7 100644
--- a/src/netlink_linearize.c
+++ b/src/netlink_linearize.c
@@ -446,6 +446,7 @@ static void netlink_gen_range(struct netlink_linearize_ctx *ctx,
BUG("invalid range operation %u\n", expr->op);
}
+ payload_shift_value(expr->left, range->left);
netlink_gen_data(range->left, &nld);
nftnl_expr_set(nle, NFTNL_EXPR_CMP_DATA, nld.value, nld.len);
nftnl_rule_add_expr(ctx->nlr, nle);
@@ -466,6 +467,7 @@ static void netlink_gen_range(struct netlink_linearize_ctx *ctx,
BUG("invalid range operation %u\n", expr->op);
}
+ payload_shift_value(expr->left, range->right);
netlink_gen_data(range->right, &nld);
nftnl_expr_set(nle, NFTNL_EXPR_CMP_DATA, nld.value, nld.len);
nftnl_rule_add_expr(ctx->nlr, nle);
diff --git a/tests/py/bridge/vlan.t.payload b/tests/py/bridge/vlan.t.payload
index 02242d2..78ee7ef 100644
--- a/tests/py/bridge/vlan.t.payload
+++ b/tests/py/bridge/vlan.t.payload
@@ -196,6 +196,6 @@ bridge test-bridge input
[ lookup reg 1 set set%d ]
[ payload load 1b @ link header + 14 => reg 1 ]
[ bitwise reg 1 = (reg=1 & 0x000000e0 ) ^ 0x00000000 ]
- [ cmp gte reg 1 0x00000001 ]
- [ cmp lte reg 1 0x00000003 ]
+ [ cmp gte reg 1 0x00000020 ]
+ [ cmp lte reg 1 0x00000060 ]
diff --git a/tests/py/bridge/vlan.t.payload.netdev b/tests/py/bridge/vlan.t.payload.netdev
index 62c7adf..f60587f 100644
--- a/tests/py/bridge/vlan.t.payload.netdev
+++ b/tests/py/bridge/vlan.t.payload.netdev
@@ -230,6 +230,6 @@ netdev test-netdev ingress
[ lookup reg 1 set set%d ]
[ payload load 1b @ link header + 14 => reg 1 ]
[ bitwise reg 1 = (reg=1 & 0x000000e0 ) ^ 0x00000000 ]
- [ cmp gte reg 1 0x00000001 ]
- [ cmp lte reg 1 0x00000003 ]
+ [ cmp gte reg 1 0x00000020 ]
+ [ cmp lte reg 1 0x00000060 ]
--
2.4.10
next prev parent reply other threads:[~2016-03-08 23:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-08 23:09 [PATCH nft 1/4] tests: frag: enable more tests Florian Westphal
2016-03-08 23:09 ` [PATCH nft 2/4] netlink_delinearize: fix bogus offset w exthdr expressions Florian Westphal
2016-03-08 23:09 ` [PATCH nft 3/4] nft-test: don't zap remainder of rule after handling a set Florian Westphal
2016-03-08 23:09 ` Florian Westphal [this message]
2016-03-10 11:10 ` [PATCH nft 1/4] tests: frag: enable more tests 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=1457478588-12592-4-git-send-email-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).