From: Florian Westphal <fw@strlen.de>
To: netfilter-devel@vger.kernel.org
Subject: vmaps and default action
Date: Mon, 13 Jan 2020 12:05:33 +0100 [thread overview]
Message-ID: <20200113110533.GH795@breakpoint.cc> (raw)
Hi,
currently a ruleset like this loads fine:
table inet filter {
chain input {
type filter hook input priority filter; policy accept;
meta l4proto vmap { tcp : jump tcp_chain, udp : jump udp_chain } counter packets 0 bytes 0 jump other_chain
}
chain forward {
type filter hook forward priority filter; policy accept;
}
chain output {
type filter hook output priority filter; policy accept;
}
chain tcp_chain {
counter packets 18 bytes 1017
}
chain udp_chain {
counter packets 0 bytes 0
}
chain other_chain {
counter packets 0 bytes 0
}
}
but it doesn't do what would be expected, tcp or udp traffic will
jump to the appropriate chain, but 'other' protocols will never
make it to other_chain.
Instead, users need a workaround like this:
table inet filter {
chain input {
type filter hook input priority filter; policy accept;
jump test_proto_chain
}
chain test_proto_chain {
meta l4proto vmap { tcp : goto tcp_chain, udp : goto udp_chain }
counter packets 2 bytes 168 goto other_chain
}
chain forward {
type filter hook forward priority filter; policy accept;
}
chain output {
type filter hook output priority filter; policy accept;
}
chain tcp_chain {
counter packets 29 bytes 1966
}
chain udp_chain {
counter packets 4 bytes 774
}
chain other_chain {
counter packets 2 bytes 168
}
}
The intermediate chain (test_proto_chain) allows to then call the real chains
via goto, so the remaining rules in test_proto_chain get omitted in case the
goto label is found, and if not the next rule does the catchall/default handling.
This isn't really nice, there should be a better way to do this.
It would be possible to make ruleset A just work by resurrecting my old patch
to not set NFT_BREAK in case no vmap entry is found, then the rule would
continue evaluation and hit the '... jump other' expression.
If thats unwanted, nft should at least complain/warn that the 'counter jump other_chain'
part will never be run, i.e. similar to how nft handles constructs like this:
inet-filter:7:25-31: Error: Statement after terminal statement has no effect
jump test_proto_chain counter accept
~~~~~~~~~~~~~~~~~~~~~ ^^^^^^^
I can make a patch that adds this warning, are there any suggestions on how to handle/add
default/catchall support?
I still think making 'A' "just work" is the most sane option, it needs very little
kernel changes, needs no extra keywords and it looks "natural" to me to make vmap a no-op
if no jump/goto was executed.
reply other threads:[~2020-01-13 11:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20200113110533.GH795@breakpoint.cc \
--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).