From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nft] proto: add pseudo th protocol to match d/sport in generic way
Date: Mon, 15 Jul 2019 10:07:46 +0200 [thread overview]
Message-ID: <20190715080746.la2ujeu5achauf6f@salvia> (raw)
In-Reply-To: <20190713172327.13928-1-fw@strlen.de>
On Sat, Jul 13, 2019 at 07:23:27PM +0200, Florian Westphal wrote:
> Problem: Its not possible to easily match both udp and tcp in a single
> rule.
>
> ... input ip protocol { tcp,udp } dport 53
>
> will not work, as bison expects "tcp dport" or "sctp dport", or any
> other transport protocol name.
>
> Its possible to match the sport and dport via raw payload expressions,
> e.g.:
> ... input ip protocol { tcp,udp } @th,16,16 53
>
> but its not very readable.
> Furthermore, its not possible to use this for set definitions:
>
> table inet filter {
> set myset {
> type ipv4_addr . inet_proto . inet_service
> }
>
> chain forward {
> type filter hook forward priority filter; policy accept;
> ip daddr . ip protocol . @th,0,16 @myset
> }
> }
> # nft -f test
> test:7:26-35: Error: can not use variable sized data types (integer) in concat expressions
>
> During the netfilter workshop Pablo suggested to add an alias to do raw
> sport/dport matching more readable, and make it use the inet_service
> type automatically.
>
> So, this change makes @th,0,16 work for the set definition case by
> setting the data type to inet_service.
>
> A new "th s|dport" syntax is provided as readable alternative:
>
> ip protocol { tcp, udp } th dport 53
>
> As "th" is an alias for the raw expression, no dependency is
> generated -- its the users responsibility to add a suitable test to
> select the l4 header types that should be matched.
>
> Suggested-by: Pablo Neira Ayuso <pablo@netfilter.org>
> Signed-off-by: Florian Westphal <fw@strlen.de>
Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
Thanks Florian.
prev parent reply other threads:[~2019-07-15 8:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-13 17:23 [PATCH nft] proto: add pseudo th protocol to match d/sport in generic way Florian Westphal
2019-07-15 8:07 ` Pablo Neira Ayuso [this message]
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=20190715080746.la2ujeu5achauf6f@salvia \
--to=pablo@netfilter.org \
--cc=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).