From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Jozsef Kadlecsik <kadlec@netfilter.org>
Cc: "Ramsay, Lincoln" <Lincoln.Ramsay@digi.com>,
"netfilter@vger.kernel.org" <netfilter@vger.kernel.org>
Subject: Re: cannot use != with ct status
Date: Wed, 14 Oct 2020 20:54:11 +0200 [thread overview]
Message-ID: <20201014185411.GA18063@salvia> (raw)
In-Reply-To: <alpine.DEB.2.23.453.2010141825050.25415@blackhole.kfki.hu>
On Wed, Oct 14, 2020 at 08:09:45PM +0200, Jozsef Kadlecsik wrote:
> On Wed, 14 Oct 2020, Pablo Neira Ayuso wrote:
>
> > > > > I've just confirmed that I can't make a rule that matches ct
> > > > > status != dnat.
> > > >
> > > > ct status == dnat and ct state != dnat checks for _exact_ matching.
> > > >
> > > > Then:
> > > >
> > > > ct status dnat
> > > >
> > > > based on the datatype, provides a shortcut for
> > > >
> > > > ct status and dnat == dnat
> > >
> > > Sorry, but it looks like really strange. "ct status nat" would be more
> > > natural to me.
> >
> > This is based on the ct status bits, so dnat is matching for
> > destination NAT updates (ie. IPS_DST_NAT). Then, snat is matching for
> > IPS_SRC_NAT.
>
> I could not express myself properly. I had no problem with the shortcut
> "ct status dnat" at all but with the expression "ct status and dnat ==
> dnat".
>
> One could split it at the "and" part and thus the "dnat == dnat" part
> looks confusing. If one splits at "==" then the "and" in "ct status and
> dnat" is not quite intuitive. (I could not find the description of "and"
> in the manpage, at least at
> http://netfilter.org/projects/nftables/index.html.) Why is the "and"
> keyword required? Why couldn't the same syntax be used like at "ct state"?
This uses the same syntax as ct state, for most cases:
ct state new
is just enough.
The original thread refers to matching if the dnat bit is _unset_, ie.
inverted matching.
# nft -i
# add rule x y (ct status & dnat) != dnat
'&' is equivalent to 'and', it's the same token actually in the
parser. I was using 'and' instead because I was in the shell, and I
wanted to avoid escaping the &.
The parens are optional, without the parens, bitwise operation takes
precedence over comparison.
Still confusing?
next prev parent reply other threads:[~2020-10-14 18:54 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-14 4:16 cannot use != with ct status Ramsay, Lincoln
2020-10-14 10:04 ` Pablo Neira Ayuso
2020-10-14 10:25 ` Jozsef Kadlecsik
2020-10-14 10:30 ` Pablo Neira Ayuso
2020-10-14 18:09 ` Jozsef Kadlecsik
2020-10-14 18:54 ` Pablo Neira Ayuso [this message]
2020-10-14 11:02 ` G.W. Haywood
2020-10-14 12:50 ` Pablo Neira Ayuso
2020-10-14 13:54 ` G.W. Haywood
2020-10-14 14:11 ` Pablo Neira Ayuso
2020-10-14 14:22 ` G.W. Haywood
2020-10-14 23:29 ` Ramsay, Lincoln
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=20201014185411.GA18063@salvia \
--to=pablo@netfilter.org \
--cc=Lincoln.Ramsay@digi.com \
--cc=kadlec@netfilter.org \
--cc=netfilter@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