From: Florian Westphal <fw@strlen.de>
To: <netfilter-devel@vger.kernel.org>
Cc: jake.owen@superloop.com, Florian Westphal <fw@strlen.de>
Subject: [PATCH nft 0/8] Enableruntime queue selection via jhash, numgen and map statement
Date: Wed, 16 Jun 2021 23:16:44 +0200 [thread overview]
Message-ID: <20210616211652.11765-1-fw@strlen.de> (raw)
Back in 2016 Liping Zhang added support to kernel and libnftnl to
specify a source register containing the queue number to use.
This was never added to nft itself, so allow this.
On linearization side, check if attached expression is a range.
If its not, allocate a new register and set NFTNL_EXPR_QUEUE_SREG_QNUM
attribute after generating the lowlevel expressions for the kernel.
On delinarization we need to check for presence of
NFTNL_EXPR_QUEUE_SREG_QNUM and decode the expression(s) when present.
Also need to do postprocessing for STMT_QUEUE so that the protocol
context is set correctly, without this only raw payload expressions
will be shown (@nh,32,...) instead of 'ip ...'.
Unfortunately, it turned out that just removing the eval checks
to allow arbitrary statements as 'num' argument results in parser
problems.
One example is this:
queue num jhash ip saddr mod 4 bypass
This fails because scanner is still in 'ip' state, not 'queue', when
"bypass" is read, so this will not be recognized as belonging to the
queue statement.
This series solves this in the following way:
1. On output, nft will now always prepend the flags, i.e.
queue flags bypass num 42
2. On input, 'queue num' is restricted to numbers and ranges.
This is backwards compatible because range and value were the
only permitted inputs (eval step rejects non-constant expressions).
3. To use numgen or jhash, new grammar is added:
queue flags bypass to jhash ip saddr mod 4
I've restricted the 'to' expressions to numgen, (sym)hash and map
for now.
This can be relaxed later on if other usecases become available.
Florian Westphal (8):
evaluate: fix hash expression maxval
parser: restrict queue num expressiveness
src: add queue expr and flags to queue_stmt_alloc
parser: add queue_stmt_compat
parser: new queue flag input format
src: queue: allow use of arbitrary queue expressions
tests: extend queue testcases for new sreg support
src: queue: allow use of MAP statement for queue number retrieval
doc/statements.txt | 10 +++-
include/statement.h | 3 +-
src/evaluate.c | 21 +++++----
src/netlink_delinearize.c | 56 +++++++++++++++-------
src/netlink_linearize.c | 28 +++++++++--
src/parser_bison.y | 38 ++++++++++++---
src/parser_json.c | 22 ++++-----
src/statement.c | 30 +++++++++---
tests/py/any/queue.t | 18 ++++++--
tests/py/any/queue.t.json | 90 ++++++++++++++++++++++++++++++++++++
tests/py/any/queue.t.payload | 25 ++++++++++
11 files changed, 281 insertions(+), 60 deletions(-)
--
2.31.1
next reply other threads:[~2021-06-16 21:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-16 21:16 Florian Westphal [this message]
2021-06-16 21:16 ` [PATCH nft 1/8] evaluate: fix hash expression maxval Florian Westphal
2021-06-16 21:16 ` [PATCH nft 2/8] parser: restrict queue num expressiveness Florian Westphal
2021-06-16 21:16 ` [PATCH nft 3/8] src: add queue expr and flags to queue_stmt_alloc Florian Westphal
2021-06-16 21:16 ` [PATCH nft 4/8] parser: add queue_stmt_compat Florian Westphal
2021-06-16 21:16 ` [PATCH nft 5/8] parser: new queue flag input format Florian Westphal
2021-06-16 21:16 ` [PATCH nft 6/8] src: queue: allow use of arbitrary queue expressions Florian Westphal
2021-06-16 21:16 ` [PATCH nft 7/8] tests: extend queue testcases for new sreg support Florian Westphal
2021-06-16 21:16 ` [PATCH nft 8/8] src: queue: allow use of MAP statement for queue number retrieval Florian Westphal
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=20210616211652.11765-1-fw@strlen.de \
--to=fw@strlen.de \
--cc=jake.owen@superloop.com \
--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 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.