From: Florian Westphal <fw@strlen.de>
To: Thomas Haller <thaller@redhat.com>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>,
NetFilter <netfilter-devel@vger.kernel.org>
Subject: Re: [PATCH nft 2/2] json: drop handling missing json() hook for "struct expr_ops"
Date: Fri, 3 Nov 2023 13:14:44 +0100 [thread overview]
Message-ID: <20231103121444.GA20723@breakpoint.cc> (raw)
In-Reply-To: <b0a495847e1c88b9cca27f3fc80f68b46c8391d5.camel@redhat.com>
Thomas Haller <thaller@redhat.com> wrote:
> What is the correct JSON syntax for printing a chain?
Thats the problem, the chain has no user-visible name :-)
Its a shortcut syntax alias. Essentially, this:
meta l4proto { tcp, udp } th dport domain jump {
ip6 saddr != $private_ip6 counter reject
accept
}
is the same as
chain $RANDOM_NAME {
ip6 saddr != $private_ip6 counter reject
accept
}
meta l4proto { tcp, udp } th dport domain jump $RANDOM_NAME
Except that, if you remove the rule, then $RANDOM_NAME chain
is deleted as well and that $RANDOM_NAME is readonly after creation
(you cannot add or remove rules from it).
> For example, for test "tests/shell/testcases/nft-f/sample-ruleset" I
> get the following from `nft -j list ruleset`:
>
> [...]
> {
> "rule": {
> "family": "inet",
> "table": "filter",
> "chain": "home_input",
> "handle": 91,
> "expr": [
> {
> "match": {
> "op": "==",
> "left": {
> "meta": {
> "key": "l4proto"
> }
> },
> "right": {
> "set": [
> "tcp",
> "udp"
> ]
> }
> }
> },
> {
> "match": {
> "op": "==",
> "left": {
> "payload": {
> "protocol": "th",
> "field": "dport"
> }
> },
> "right": 53
> }
> },
> "jump {\n\t\t\tip6 saddr != { fd00::/8, fe80::/64 } counter packets 0 bytes 0 reject with icmpv6 port-unreachable\n\t\t\taccept\n\t\t}"
> ]
> }
> },
> [...]
>
>
> In `man libnftables-json`, searching for "jump" only gives:
>
> { "jump": { "target": * STRING *}}
>
> Is there an example how this JSON output should look like?
We need to define a new syntax for this case.
I think it would be best to recurse, i.e. something like:
# i.e., make it clear that this is a jump ("left" :)
and that the target is a complete, anonymous chain with
0 or more rules embedded within.
},
"jump" : {"chain" : { "rule" : {
"family" : "inet",
"table": "t", "chain": "c",
"handle": 5,
"expr":
[{"match": {"op": "!=", "left": {
"payload": {
"protocol": "ip6",
"field": "saddr"}},
"right": {
"set":
[{"prefix": {"addr": "fd00::", "len": 8}}, { ....
next prev parent reply other threads:[~2023-11-03 12:14 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-02 11:20 [PATCH nft 1/2] json: implement json() hook for "symbol_expr_ops"/"variabl_expr_ops" Thomas Haller
2023-11-02 11:20 ` [PATCH nft 2/2] json: drop handling missing json() hook for "struct expr_ops" Thomas Haller
2023-11-02 11:27 ` Pablo Neira Ayuso
2023-11-02 14:09 ` Thomas Haller
2023-11-02 15:54 ` Pablo Neira Ayuso
2023-11-02 16:17 ` Thomas Haller
2023-11-02 20:51 ` Pablo Neira Ayuso
2023-11-03 8:45 ` Thomas Haller
2023-11-03 11:53 ` Pablo Neira Ayuso
2023-11-03 12:19 ` Florian Westphal
2023-11-03 15:16 ` Pablo Neira Ayuso
2023-11-03 12:14 ` Florian Westphal [this message]
2023-11-02 17:39 ` Thomas Haller
2023-11-02 19:49 ` Thomas Haller
2023-11-02 11:24 ` [PATCH nft 1/2] json: implement json() hook for "symbol_expr_ops"/"variabl_expr_ops" 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=20231103121444.GA20723@breakpoint.cc \
--to=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=thaller@redhat.com \
/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.