From: Florian Westphal <fw@strlen.de>
To: <netfilter-devel@vger.kernel.org>
Subject: [PATCH nft v3 00/10] add typeof keyword
Date: Tue, 17 Dec 2019 12:27:03 +0100 [thread overview]
Message-ID: <20191217112713.6017-1-fw@strlen.de> (raw)
This patch series adds the typeof keyword.
This depends on Pablos extensions to libnftnls udata parsing facilities.
named set can be configured as follows:
set os {
typeof osf name
elements = { "Linux", "Windows" }
}
The type is stored in the kernel via the udata infrastructure.
On listing -- if a udata type is present -- nft will validate that this
type matches the set key length and, if so, will print back the 'typeof'
information.
Note that while 'typeof' can be used with concatenations, they
only work as aliases for known types -- its currently not possible
to use integer/string types via the 'typeof' keyword (its rejected
at evaluation stage due to 0-length sub expression types).
Doing so requires a bit more work to dissect the correct key
geometry on netlink dumps.
In case typeof udata is not there/invalid, the normal 'type' syntax
is used.
This patch set isn't complete -- the test cases will not work
yet because 'meta' and 'osf' lack the udata parse/buil callbacks.
This is caught at the parsing stage.
The following changes since commit ddbe652bf0f4ed300bae9497250130d68e4cbf5b:
py: load the SONAME-versioned shared object (2019-12-10 19:07:16 +0100)
are available in the Git repository at:
git://git.breakpoint.cc/fw/nftables.git typeof_rework_09
for you to fetch changes up to 02485d775dea55a067c6dbea0826ab3fc9ff7398:
tests: add typeof test cases (2019-12-17 12:19:51 +0100)
----------------------------------------------------------------
Florian Westphal (7):
parser: add a helper for concat expression handling
src: store expr, not dtype to track data in sets
src: add "typeof" build/parse/print support
mnl: round up the map data size too
evaluate: print a hint about 'typeof' syntax on 0 keylen
doc: mention 'typeof' as alternative to 'type' keyword
tests: add typeof test cases
Pablo Neira Ayuso (3):
proto: add proto_desc_id enumeration
expr: add expr_ops_by_type()
parser: add typeof keyword for declarations
doc/nft.txt | 12 +-
include/datatype.h | 1 -
include/expression.h | 5 +
include/netlink.h | 1 -
include/proto.h | 27 ++++
include/rule.h | 7 +-
src/datatype.c | 5 -
src/evaluate.c | 81 +++++++----
src/expression.c | 14 +-
src/json.c | 4 +-
src/mnl.c | 30 ++++-
src/monitor.c | 2 +-
src/netlink.c | 149 +++++++++++++++++----
src/parser_bison.y | 148 +++++++++++---------
src/parser_json.c | 8 +-
src/payload.c | 75 +++++++++++
src/proto.c | 46 +++++++
src/rule.c | 48 +++++--
src/scanner.l | 1 +
src/segtree.c | 8 +-
tests/shell/testcases/maps/dumps/typeof_maps_0.nft | 16 +++
tests/shell/testcases/maps/typeof_maps_0 | 27 ++++
tests/shell/testcases/sets/dumps/typeof_sets_0.nft | 19 +++
tests/shell/testcases/sets/typeof_sets_0 | 29 ++++
24 files changed, 621 insertions(+), 142 deletions(-)
create mode 100644 tests/shell/testcases/maps/dumps/typeof_maps_0.nft
create mode 100755 tests/shell/testcases/maps/typeof_maps_0
create mode 100644 tests/shell/testcases/sets/dumps/typeof_sets_0.nft
create mode 100755 tests/shell/testcases/sets/typeof_sets_0
next reply other threads:[~2019-12-17 11:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-17 11:27 Florian Westphal [this message]
2019-12-17 11:27 ` [PATCH nft v3 01/10] parser: add a helper for concat expression handling Florian Westphal
2019-12-17 11:27 ` [PATCH nft v3 02/10] src: store expr, not dtype to track data in sets Florian Westphal
2019-12-17 11:27 ` [PATCH nft v3 03/10] proto: add proto_desc_id enumeration Florian Westphal
2019-12-17 11:27 ` [PATCH nft v3 04/10] expr: add expr_ops_by_type() Florian Westphal
2019-12-17 11:27 ` [PATCH nft v3 05/10] parser: add typeof keyword for declarations Florian Westphal
2019-12-17 11:27 ` [PATCH nft v3 06/10] src: add "typeof" build/parse/print support Florian Westphal
2019-12-17 11:27 ` [PATCH nft v3 07/10] mnl: round up the map data size too Florian Westphal
2019-12-17 11:27 ` [PATCH nft v3 08/10] evaluate: print a hint about 'typeof' syntax on 0 keylen Florian Westphal
2019-12-17 11:27 ` [PATCH nft v3 09/10] doc: mention 'typeof' as alternative to 'type' keyword Florian Westphal
2019-12-17 11:27 ` [PATCH nft v3 10/10] tests: add typeof test cases 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=20191217112713.6017-1-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