From: Bart De Schuymer <bdschuym@pandora.be>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH -next] netfilter: bridge: optionally set indev to vlan
Date: Thu, 05 Apr 2012 19:20:36 +0200 [thread overview]
Message-ID: <4F7DD464.4020405@pandora.be> (raw)
In-Reply-To: <20120404195729.GC23461@Chamillionaire.breakpoint.cc>
Op 4/04/2012 21:57, Florian Westphal schreef:
> if net.bridge.bridge-nf-filter-vlan-tagged sysctl is enabled, bridge
> netfilter removes the vlan header temporarily and then feeds the packet
> to ip(6)tables.
>
> When the new "bridge-nf-pass-vlan-input-device" sysctl is on
> (default off), then bridge netfilter will also change the in/out
> interface to the vlan interface; if such an interface exists.
>
> This is needed to make iptables REDIRECT target work with
> "vlan-on-top-of-bridge" setups. Also, 'iptables -i' can then be used
> to match the vlan device name.
>
> Also update Documentation with current brnf default settings.
>
> proc/sys/net/sctp/* Variables:
>
> diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
> index dec4f38..1d69feb 100644
> --- a/net/bridge/br_netfilter.c
> +++ b/net/bridge/br_netfilter.c
> @@ -53,6 +53,7 @@ static int brnf_call_iptables __read_mostly = 1;
> static int brnf_call_ip6tables __read_mostly = 1;
> static int brnf_call_arptables __read_mostly = 1;
> static int brnf_filter_vlan_tagged __read_mostly = 0;
> +static int brnf_pass_vlan_indev __read_mostly = 0;
> static int brnf_filter_pppoe_tagged __read_mostly = 0;
> #else
> #define brnf_call_iptables 1
> @@ -503,6 +504,19 @@ bridged_dnat:
> return 0;
> }
You should also provide a macro in case the proc file system isn't
enabled: currently it won't compile with your patch.
> /* Some common code for IPv4/IPv6 */
> static struct net_device *setup_pre_routing(struct sk_buff *skb)
> {
> @@ -515,7 +529,7 @@ static struct net_device *setup_pre_routing(struct sk_buff *skb)
>
> nf_bridge->mask |= BRNF_NF_BRIDGE_PREROUTING;
> nf_bridge->physindev = skb->dev;
> - skb->dev = bridge_parent(skb->dev);
> + skb->dev = brnf_get_logical_dev(skb, skb->dev);
> if (skb->protocol == htons(ETH_P_8021Q))
> nf_bridge->mask |= BRNF_8021Q;
> else if (skb->protocol == htons(ETH_P_PPP_SES))
> @@ -737,7 +751,7 @@ static unsigned int br_nf_forward_ip(unsigned int hook, struct sk_buff *skb,
> int (*okfn)(struct sk_buff *))
> {
> struct nf_bridge_info *nf_bridge;
> - struct net_device *parent;
> + struct net_device *parent, *indev;
> u_int8_t pf;
>
> if (!skb->nf_bridge)
> @@ -748,10 +762,6 @@ static unsigned int br_nf_forward_ip(unsigned int hook, struct sk_buff *skb,
> if (!nf_bridge_unshare(skb))
> return NF_DROP;
>
> - parent = bridge_parent(out);
> - if (!parent)
> - return NF_DROP;
> -
> if (IS_IP(skb) || IS_VLAN_IP(skb) || IS_PPPOE_IP(skb))
> pf = PF_INET;
> else if (IS_IPV6(skb) || IS_VLAN_IPV6(skb) || IS_PPPOE_IPV6(skb))
> @@ -759,6 +769,10 @@ static unsigned int br_nf_forward_ip(unsigned int hook, struct sk_buff *skb,
> else
> return NF_ACCEPT;
>
> + parent = brnf_get_logical_dev(skb, out);
> + if (!parent)
> + return NF_DROP;
> +
> nf_bridge_pull_encap_header(skb);
>
> nf_bridge = skb->nf_bridge;
> @@ -778,7 +792,9 @@ static unsigned int br_nf_forward_ip(unsigned int hook, struct sk_buff *skb,
> else
> skb->protocol = htons(ETH_P_IPV6);
>
> - NF_HOOK(pf, NF_INET_FORWARD, skb, bridge_parent(in), parent,
> + indev = brnf_get_logical_dev(skb, in);
> +
> + NF_HOOK(pf, NF_INET_FORWARD, skb, indev, parent,
> br_nf_forward_finish);
>
> return NF_STOLEN;
> @@ -850,7 +866,7 @@ static unsigned int br_nf_post_routing(unsigned int hook, struct sk_buff *skb,
> int (*okfn)(struct sk_buff *))
> {
> struct nf_bridge_info *nf_bridge = skb->nf_bridge;
> - struct net_device *realoutdev = bridge_parent(skb->dev);
> + struct net_device *realoutdev = brnf_get_logical_dev(skb, out);
I think it's best to keep the bridge_parent as output device in the
FOWARD and POSTROUTING chain: only change the input device. Do you have
a reason for changing the output device?
cheers,
Bart
--
Bart De Schuymer
www.artinalgorithms.be
next prev parent reply other threads:[~2012-04-05 17:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-04 19:57 [PATCH -next] netfilter: bridge: optionally set indev to vlan Florian Westphal
2012-04-05 1:09 ` Pablo Neira Ayuso
2012-04-05 7:30 ` Florian Westphal
2012-04-05 11:09 ` Pablo Neira Ayuso
2012-04-05 17:20 ` Bart De Schuymer [this message]
2012-04-05 19:40 ` Florian Westphal
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=4F7DD464.4020405@pandora.be \
--to=bdschuym@pandora.be \
--cc=fw@strlen.de \
--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).