bridge: netfilter: don't call iptables on vlan packets if sysctl is off
authorFlorian Westphal <fw@strlen.de>
Tue, 6 Mar 2012 01:22:54 +0000 (01:22 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 6 Mar 2012 19:43:49 +0000 (14:43 -0500)
commit739e4505a0e8209622dc71743bfa1c804eacf7f4
treedf98d368f510e4e58f93e10bb8c77a8f7094b036
parenta157b9d5b5b626e46eba2ac4e342da8db25cabc4
bridge: netfilter: don't call iptables on vlan packets if sysctl is off

When net.bridge.bridge-nf-filter-vlan-tagged is 0 (default), vlan packets
arriving should not be sent to ip(6)tables by bridge netfilter.

However, it turns out that we currently always send VLAN packets to
netfilter, if ..
a), CONFIG_VLAN_8021Q is enabled ; or
b), CONFIG_VLAN_8021Q is not set but rx vlan offload is enabled
   on the bridge port.

This is because bridge netfilter treats skb with
skb->protocol == ETH_P_IP{V6} as "non-vlan packet".

With rx vlan offload on or CONFIG_VLAN_8021Q=y, the vlan header has
already been removed here, and we cannot rely on skb->protocol alone.

Fix this by only using skb->protocol if the skb has no vlan tag,
or if a vlan tag is present and filter-vlan-tagged bridge netfilter
sysctl is enabled.

We cannot remove the skb->protocol == htons(ETH_P_8021Q) test
because the vlan tag is still around in the CONFIG_VLAN_8021Q=n &&
"ethtool -K $itf rxvlan off" case.

reproducer:
iptables -t raw -I PREROUTING -i br0
iptables -t raw -I PREROUTING -i br0.1

Then send packets to an ip address configured on br0.1 interface.
Even with net.bridge.bridge-nf-filter-vlan-tagged=0, the 1st rule
will match instead of the 2nd one.

With this patch applied, the 2nd rule will match instead.
In the non-local address case, netfilter won't be consulted after
this patch unless the sysctl is switched on.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/bridge/br_netfilter.c
This page took 0.034954 seconds and 5 git commands to generate.