diff options
author | Vlad Yasevich <vyasevic@redhat.com> | 2013-02-13 07:00:10 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-02-13 19:41:46 -0500 |
commit | a37b85c9fbd1dc69fbec3985763f373203eaf9e3 (patch) | |
tree | 3585bf258d87459b48b2d94b66dac9de729ef699 /net/bridge/br_vlan.c | |
parent | 243a2e63f5f47763b802e9dee8dbf1611a1c1322 (diff) |
bridge: Validate that vlan is permitted on ingress
When a frame arrives on a port or transmitted by the bridge,
if we have VLANs configured, validate that a given VLAN is allowed
to enter the bridge.
Signed-off-by: Vlad Yasevich <vyasevic@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/bridge/br_vlan.c')
-rw-r--r-- | net/bridge/br_vlan.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c index 209464ef5242..8b4bcd8ff46e 100644 --- a/net/bridge/br_vlan.c +++ b/net/bridge/br_vlan.c | |||
@@ -64,6 +64,31 @@ static void __vlan_flush(struct net_port_vlans *v) | |||
64 | kfree_rcu(v, rcu); | 64 | kfree_rcu(v, rcu); |
65 | } | 65 | } |
66 | 66 | ||
67 | /* Called under RCU */ | ||
68 | bool br_allowed_ingress(struct net_bridge *br, struct net_port_vlans *v, | ||
69 | struct sk_buff *skb) | ||
70 | { | ||
71 | u16 vid; | ||
72 | |||
73 | /* If VLAN filtering is disabled on the bridge, all packets are | ||
74 | * permitted. | ||
75 | */ | ||
76 | if (!br->vlan_enabled) | ||
77 | return true; | ||
78 | |||
79 | /* If there are no vlan in the permitted list, all packets are | ||
80 | * rejected. | ||
81 | */ | ||
82 | if (!v) | ||
83 | return false; | ||
84 | |||
85 | br_vlan_get_tag(skb, &vid); | ||
86 | if (test_bit(vid, v->vlan_bitmap)) | ||
87 | return true; | ||
88 | |||
89 | return false; | ||
90 | } | ||
91 | |||
67 | /* Must be protected by RTNL */ | 92 | /* Must be protected by RTNL */ |
68 | int br_vlan_add(struct net_bridge *br, u16 vid) | 93 | int br_vlan_add(struct net_bridge *br, u16 vid) |
69 | { | 94 | { |