netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Gao feng <gaofeng@cn.fujitsu.com>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH RESEND] netfilter: bridge: unshare bridge info before change it
Date: Wed, 19 Nov 2014 12:49:09 +0100	[thread overview]
Message-ID: <20141119114909.GA5014@salvia> (raw)
In-Reply-To: <20141119111720.GA4537@salvia>

On Wed, Nov 19, 2014 at 12:17:20PM +0100, Pablo Neira Ayuso wrote:
> On Wed, Nov 19, 2014 at 10:11:25AM +0800, Gao feng wrote:
> > On 11/19/2014 02:34 AM, Pablo Neira Ayuso wrote:
> > > On Mon, Nov 17, 2014 at 01:48:43PM +0800, Gao feng wrote:
> > >> diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
> > >> index 1a4f32c..b4612b9 100644
> > >> --- a/net/bridge/br_netfilter.c
> > >> +++ b/net/bridge/br_netfilter.c
> > >> @@ -653,7 +643,11 @@ static int br_nf_forward_finish(struct sk_buff *skb)
> > >>  		in = nf_bridge->physindev;
> > >>  		if (nf_bridge->mask & BRNF_PKT_TYPE) {
> > >>  			skb->pkt_type = PACKET_OTHERHOST;
> > >> -			nf_bridge->mask ^= BRNF_PKT_TYPE;
> > >> +
> > >> +			if (!nf_bridge_unset_mask(skb, BRNF_PKT_TYPE)) {
> > >> +				kfree_skb(skb);
> > >> +				return 0;
> > >> +			}
> > > 
> > > This can now release the packet and, thus, drop it.
> > > 
> > > However, br_nf_forward_ip() always returns NF_STOLEN.
> > > 
> > > Could you revisit the error paths and confirm they are correct?
> > 
> > Since br_nf_forward_ip() returns NF_STOLEN, br_nf_forward_finish should make
> > sure this skb will be released. if unser_mask for this skb is failed, we free
> > it. if unset successed, the hooks on NF_BR_FORWARD or br_forward_finish will
> > free this skb.
> 
> OK, but I think this should return NF_DROP instead of NF_STOLEN so you
> don't explicitly need to kfree_skb it.

After a further look, I noticed what I suggest needs to replace:

        NF_HOOK_THRESH(...);
        return 0;

by:
        return NF_HOOK_THRESH(...);

And review the return value of all the existing okfn() functions so
they return netfilter verdicts.

The existing code always returns NF_STOLEN from many other hooks, not
only when dropped but also when accepted to make this work...

I'm going to have a look at your v2. Thanks.

  reply	other threads:[~2014-11-19 11:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-17  5:48 [PATCH RESEND] netfilter: bridge: unshare bridge info before change it Gao feng
2014-11-18 18:34 ` Pablo Neira Ayuso
2014-11-19  2:11   ` Gao feng
2014-11-19 11:17     ` Pablo Neira Ayuso
2014-11-19 11:49       ` Pablo Neira Ayuso [this message]
2014-11-20  1:14         ` Gao feng

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=20141119114909.GA5014@salvia \
    --to=pablo@netfilter.org \
    --cc=gaofeng@cn.fujitsu.com \
    --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).