All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Engelhardt <jengelh@medozas.de>
To: Philip Craig <philipc@snapgear.com>
Cc: Nir Tzachar <nir.tzachar@gmail.com>, netfilter-devel@vger.kernel.org
Subject: Re: Fix ipt_REJECT problem with nf_bridge
Date: Thu, 12 Mar 2009 04:25:03 +0100 (CET)	[thread overview]
Message-ID: <alpine.LSU.2.00.0903120341520.31440@fbirervta.pbzchgretzou.qr> (raw)
In-Reply-To: <49B85FA6.9040601@snapgear.com>


On Thursday 2009-03-12 02:04, Philip Craig wrote:
>Nir Tzachar wrote:

>>       if (hook != NF_INET_FORWARD
>>#ifdef CONFIG_BRIDGE_NETFILTER
>>            || (nskb->nf_bridge && nskb->nf_bridge->mask & BRNF_BRIDGED)
>>#endif
>>           )
>>                addr_type = RTN_LOCAL;
>>
>>but, as nskb was newly allocated just a few line back, the
>>oldskb->nf_bridge was never copied, so nskb->nf_bridge is always NULL.
>>The following patch corrects the problem. Please review and apply.
>>
>>I have checked the change you proposed (checking oldskb instead of
>>nskb) , and indeed it works. Should I resubmit a patch for it?
>
>Yes please, but it will need someone that knows more about
>routing internals than me to review it still.

Ok, let me step in then.

(Terminology. Plain packet: whatever triggers RST. RST packet: what
REJECT will send)

If I read the comments in ip_route_me_harder correctly, RTN_LOCAL
must not be used when ipt_REJECT generates the RST packet with a
source address that does not belong to the firewall itself. In other
words, if it is forwarded (hence the NF_INET_FORWARD check).

If hook is INPUT or OUTPUT, saddr will be ours anyway (except maybe
in TPROXY setups, yayay, don't wanna think about that right now ;-)
so RTN_LOCAL is ok.

Now look at (hook == NF_INET_FORWARD && BRNF_BRIDGED). For a plain
packet to arrive in the FORWARD chain, daddr must not be local. So
when the address tuple is reversed for the RST packet, saddr will not
be a local address.

This is the commit that originally introduced the BRNF_BRIDGED clause:

commit dbf3813cdabe3c0336667bbf3347652cb897e365 (v2.6.5-rc3-27-gdbf3813)
Author: Bart De Schuymer <bdschuym@pandora.be>
Date:   Tue Mar 30 23:18:10 2004 -0800

    [NETFILTER]: Do not require ip_forwarding for reset on a bridge.
    
    Currently, to be able to send a reset in the FORWARD chain of iptables
    for bridged traffic, ip forwarding must be enabled. This causes confusion
    and in some situations people really don't want to enable ip forwarding.
    The patch below lets the user send reset packets for bridged frames in
    the FORWARD chain, with ip forwarding disabled (as long as there is a
    route).

FYI: This is talking about "pure"-bridged traffic, i.e. traffic that will
go from one bridge port to another without touching the "routing decision"
box in [1]. In iptables terminology, that's

	FORWARD -i br0 -o br0

style traffic. Since the RST packet REJECT creates goes through
OUTPUT, so I would assume no forwarding would take place, and the
ip_forward flag not be relevant. The BRNF_BRIDGED clause therefore
seems wrong because it will always be a non-local saddr.

[1] http://jengelh.medozas.de/images/nf-packet-flow.png

  reply	other threads:[~2009-03-12  3:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-26  8:48 [PATCH]: Fix ipt_REJECT problem with nf_bridge Nir Tzachar
2009-03-10  5:29 ` Nir Tzachar
2009-03-10  5:43   ` Philip Craig
2009-03-11  9:29     ` Nir Tzachar
2009-03-11 11:44       ` Nir Tzachar
2009-03-12  1:04         ` Philip Craig
2009-03-12  3:25           ` Jan Engelhardt [this message]
2009-03-12  6:04             ` Philip Craig
2009-03-12 10:35               ` Jan Engelhardt
     [not found]                 ` <9b2db90b0903120516n1f9e67ck8994c9b92bb6aa0a@mail.gmail.com>
2009-03-12 12:17                   ` Nir Tzachar
2009-03-13  0:50                 ` Philip Craig
2009-03-16 15:11             ` 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=alpine.LSU.2.00.0903120341520.31440@fbirervta.pbzchgretzou.qr \
    --to=jengelh@medozas.de \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=nir.tzachar@gmail.com \
    --cc=philipc@snapgear.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.