All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steve Hill <steve@opendium.com>
To: Jan Engelhardt <jengelh@medozas.de>
Cc: netfilter@vger.kernel.org
Subject: Re: Filtering on bridges
Date: Thu, 22 Dec 2011 10:56:12 +0000	[thread overview]
Message-ID: <4EF30CCC.4090703@opendium.com> (raw)
In-Reply-To: <alpine.LNX.2.01.1112220028500.22558@frira.zrqbmnf.qr>

On 21/12/11 23:31, Jan Engelhardt wrote:

>>> Yes you do know where it is going; the route is set on FORWARD/OUTPUT
>>> (see nf-packet-flow.svg)
>>
>> I only know it is going to the bridge.  I don't know which member of
>> that bridge it will eventually be sent out of.  In short: I don't know
>> where it is going (in enough detail to be useful).
>
> But the kernel knows, and that's really all that is needed.

I think we have a misunderstanding somewhere:

I need to filter traffic from the local IP stack (whether that be 
locally generated or routed - lets concentrate on the locally generated 
traffic for now), and which set of iptables rules apply is to be based 
on which physical NIC the traffic will egress.

In the iptables/ip6tables OUTPUT chain, the -o option matches against 
which bridge the traffic is going to (not the physical NIC).  However, 
this is not useful because I'm interested in the physical interface, not 
the bridge interface.  I used to be able to use --physdev-out to match 
the physical NIC, but this is no longer allowed in OUTPUT.

Looking at http://jengelh.medozas.de/images/nf-packet-flow.svg, it could 
probably use some arrows to help understand the direction that some of 
the links should be followed in (the direction of the link between 
"routing decision" and "bridging decision" seems ambiguous to me). 
However, I can't see any "bridging decision" for locally generated 
traffic, so I'm not sure at what point the physical output NIC is 
determined.  I _presume_ that the bridging decision is made between 
"iptables-nat-postrouting" and "ebtables-nat-output", in which case 
there does indeed seem to be no way to match the physical output 
interface from iptables, since no iptables rules are invoked after that 
point.  I guess what is really needed is an extra iptables filter chain 
between "ebtables-nat-postrouting" and "egress".

So at the moment, the only way I can think of doing the filtering is to 
allow the packet to run through *all* the iptables rules without 
matching the physical output NIC and set one bit of the fwmark for each 
physical interface I would let the packet egress.  Then in ebtables 
(where we know the physical interface) filter the packets by looking at 
the fwmark bit that I've used to indicate that interface.  This method 
is pretty unscalable (fwmark is 32 bits long, so we're limited to 32 
interfaces, minus any other things that the fwmark will be used for, 
such as QoS) and also will be absolute hell to manage.

So any other good ideas for how to accomplish this filtering?  (I 
understand the reasons for removing the physdev-out support for 
unbridged traffic, but why on earth hasn't it been replaced with 
something to do a similar job, such as an additional iptables chain 
after the bridging decision rather than wholesale removing a useful 
feature?)

-- 

  - Steve Hill
    Technical Director
    Opendium Limited     http://www.opendium.com

Direct contacts:
    Instant messager: xmpp:steve@opendium.com
    Email:            steve@opendium.com
    Phone:            sip:steve@opendium.com

Sales / enquiries contacts:
    Email:            sales@opendium.com
    Phone:            +44-844-9791439 / sip:sales@opendium.com

Support contacts:
    Email:            support@opendium.com
    Phone:            +44-844-4844916 / sip:support@opendium.com

  reply	other threads:[~2011-12-22 10:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-21 10:16 Filtering on bridges Steve Hill
2011-12-21 13:30 ` Jan Engelhardt
2011-12-21 13:48   ` Steve Hill
2011-12-21 15:36     ` Niccolò Belli
2011-12-21 18:36     ` Jan Engelhardt
2011-12-21 23:21       ` Steve Hill
2011-12-21 23:31         ` Jan Engelhardt
2011-12-22 10:56           ` Steve Hill [this message]
2011-12-22 16:28             ` Jan Engelhardt
2011-12-22 17:36               ` Steve Hill
2011-12-22 22:05                 ` Jan Engelhardt
2011-12-23  4:33                   ` Vigneswaran R
2012-01-03 13:15                     ` Steve Hill
2012-01-03 16:09                       ` Jan Engelhardt
2012-01-03 18:43                       ` John A. Sullivan III

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=4EF30CCC.4090703@opendium.com \
    --to=steve@opendium.com \
    --cc=jengelh@medozas.de \
    --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 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.