netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Phil Sutter <phil@nwl.cc>
Cc: Florian Westphal <fwestpha@redhat.com>, netfilter-devel@vger.kernel.org
Subject: Re: [nf PATCH] net: nf_tables: Make nft_meta expression more robust
Date: Thu, 18 Jul 2019 20:12:53 +0200	[thread overview]
Message-ID: <20190718181253.dh6thcfxhnqdz74s@salvia> (raw)
In-Reply-To: <20190718181034.gwe5tu4z2j4m7zyv@salvia>

On Thu, Jul 18, 2019 at 08:10:34PM +0200, Pablo Neira Ayuso wrote:
> On Thu, Jul 18, 2019 at 05:37:29AM +0200, Phil Sutter wrote:
> > nft_meta_get_eval()'s tendency to bail out setting NFT_BREAK verdict in
> > situations where required data is missing breaks inverted checks
> > like e.g.:
> > 
> > | meta iifname != eth0 accept
> > 
> > This rule will never match if there is no input interface (or it is not
> > known) which is not intuitive and, what's worse, breaks consistency of
> > iptables-nft with iptables-legacy.
> > 
> > Fix this by falling back to placing a value in dreg which never matches
> > (avoiding accidental matches):
> > 
> > {I,O}IF:
> > 	Use invalid ifindex value zero.
> > 
> > {I,O}IFNAME, {I,O}IFKIND:
> > 	Use an empty string which is neither a valid interface name nor
> > 	kind.
> > 
> > {I,O}IFTYPE:
> > 	Use ARPHRD_VOID (0xFFFF).
> > 
> > Signed-off-by: Phil Sutter <phil@nwl.cc>
> > ---
> >  net/netfilter/nft_meta.c | 45 +++++++++++++++++-----------------------
> 
> Missing update for:
> 
>  net/bridge/netfilter/nft_meta_bridge.c

While you update this, would you also disentangle the default: case?

        default:
                goto out;

        ...
out:
        return nft_meta_get_eval(expr, regs, pkt);

not good to use goto like that.

I'd suggest:

        default:
                nft_meta_get_eval(expr, regs, pkt);
                return;

Thanks.

      reply	other threads:[~2019-07-18 18:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-18  3:37 [nf PATCH] net: nf_tables: Make nft_meta expression more robust Phil Sutter
2019-07-18 18:10 ` Pablo Neira Ayuso
2019-07-18 18:12   ` 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=20190718181253.dh6thcfxhnqdz74s@salvia \
    --to=pablo@netfilter.org \
    --cc=fwestpha@redhat.com \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=phil@nwl.cc \
    /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).