netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Patrick McHardy <kaber@trash.net>
Cc: Florian Westphal <fw@strlen.de>, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nft] expr: do not suppress OP_EQ when RHS is bitmask type
Date: Fri, 4 Apr 2014 16:04:30 +0200	[thread overview]
Message-ID: <20140404140430.GB28581@localhost> (raw)
In-Reply-To: <20140404120946.GD27267@macbook.localnet>

On Fri, Apr 04, 2014 at 02:09:48PM +0200, Patrick McHardy wrote:
> On Fri, Apr 04, 2014 at 11:44:33AM +0200, Pablo Neira Ayuso wrote:
> > On Fri, Apr 04, 2014 at 10:33:28AM +0200, Florian Westphal wrote:
> > > Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > > > On Mon, Mar 17, 2014 at 11:08:38PM +0100, Florian Westphal wrote:
> > > > > bitmask types default to flagcmp now, thus do not suppress OP_EQ.  Else,
> > > > > 
> > > > > rule filter output tcp flags syn
> > > > > rule filter output tcp flags == syn
> > > > > 
> > > > > are both displayed as 'flags syn'.
> > > > 
> > > > I believe that in other selectors:
> > > > 
> > > >         selector == value
> > > >         selector value
> > > > 
> > > > are equivalent.
> > > 
> > > Yes, thats true.
> > > 
> > > > I think it's not just that we have to fix the printing, but make it
> > > > consistent.
> > > 
> > > Not sure, this was changed recently, see
> > > 6bad82aba5d304c7a2dd1b19fe57464dca327f4a
> > > (evaluate: use flagcmp for single RHS bitmask expression).
> > 
> > That change is fine, I think we only have to fix tcp flags == syn to
> > make it equivalent to tcp flags syn. I don't find a good reason why
> > the should behave in a different way.
> 
> Because the implicit op for bitmasks is to test for any of the given bits.
> tcp flags syn really should match on syn and syn/ack.

That's fine with me. The problem that I see is the inconsistent
interpretation depending on if the value is a flag or not.

> If an equality relation is explicitly specified by the user, it also needs
> to be printed. Florian's change is all we need from what I can tell.

Then we have to document that in some cases key == value and key
value are equivalent, and when it comes to flags it is not, which is
still rare to me.

nft --debug=netlink add rule filter output tcp flags == syn ip filter output
  [ payload load 1b @ network header + 9 => reg 1 ]
  [ cmp eq reg 1 0x00000006 ]
  [ payload load 1b @ transport header + 13 => reg 1 ]
  [ cmp eq reg 1 0x00000002 ]

nft --debug=netlink add rule filter output tcp flags syn ip filter output
  [ payload load 1b @ network header + 9 => reg 1 ]
  [ cmp eq reg 1 0x00000006 ]
  [ payload load 1b @ transport header + 13 => reg 1 ]
  [ bitwise reg 1 = (reg=1 & 0x00000002 ) ^ 0x00000000 ]
  [ cmp neq reg 1 0x00000000 ]

  reply	other threads:[~2014-04-04 14:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-17 22:08 [PATCH nft] expr: do not suppress OP_EQ when RHS is bitmask type Florian Westphal
2014-04-04  8:17 ` Pablo Neira Ayuso
2014-04-04  8:33   ` Florian Westphal
2014-04-04  9:44     ` Pablo Neira Ayuso
2014-04-04 12:09       ` Patrick McHardy
2014-04-04 14:04         ` Pablo Neira Ayuso [this message]
2014-04-04 14:24           ` Patrick McHardy
2014-04-04 15:23             ` Pablo Neira Ayuso
2014-04-04 15:39               ` Florian Westphal
2014-04-04 12:07   ` Patrick McHardy

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=20140404140430.GB28581@localhost \
    --to=pablo@netfilter.org \
    --cc=fw@strlen.de \
    --cc=kaber@trash.net \
    --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).