Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 352450
b: refs/heads/master
c: 35e03f3
h: refs/heads/master
v: v3
  • Loading branch information
Vlad Yasevich authored and David S. Miller committed Feb 14, 2013
1 parent fc4fcfd commit 311efb8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: bc9a25d21ef8bad30e259af5114ccfb845c066db
refs/heads/master: 35e03f3a0275a1ba57e432d7c948cf6f70fbb37a
1 change: 1 addition & 0 deletions trunk/include/uapi/linux/if_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ enum {

#define BRIDGE_VLAN_INFO_MASTER (1<<0) /* Operate on Bridge device as well */
#define BRIDGE_VLAN_INFO_PVID (1<<1) /* VLAN is PVID, ingress untagged */
#define BRIDGE_VLAN_INFO_UNTAGGED (1<<2) /* VLAN egresses untagged */

struct bridge_vlan_info {
u16 flags;
Expand Down
4 changes: 4 additions & 0 deletions trunk/net/bridge/br_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ static int br_fill_ifinfo(struct sk_buff *skb,
vinfo.flags = 0;
if (vid == pvid)
vinfo.flags |= BRIDGE_VLAN_INFO_PVID;

if (test_bit(vid, pv->untagged_bitmap))
vinfo.flags |= BRIDGE_VLAN_INFO_UNTAGGED;

if (nla_put(skb, IFLA_BRIDGE_VLAN_INFO,
sizeof(vinfo), &vinfo))
goto nla_put_failure;
Expand Down
1 change: 1 addition & 0 deletions trunk/net/bridge/br_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ struct net_port_vlans {
} parent;
struct rcu_head rcu;
unsigned long vlan_bitmap[BR_VLAN_BITMAP_LEN];
unsigned long untagged_bitmap[BR_VLAN_BITMAP_LEN];
u16 num_vlans;
};

Expand Down
20 changes: 14 additions & 6 deletions trunk/net/bridge/br_vlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ static void __vlan_delete_pvid(struct net_port_vlans *v, u16 vid)
v->pvid = 0;
}

static void __vlan_add_flags(struct net_port_vlans *v, u16 vid, u16 flags)
{
if (flags & BRIDGE_VLAN_INFO_PVID)
__vlan_add_pvid(v, vid);

if (flags & BRIDGE_VLAN_INFO_UNTAGGED)
set_bit(vid, v->untagged_bitmap);
}

static int __vlan_add(struct net_port_vlans *v, u16 vid, u16 flags)
{
struct net_bridge_port *p = NULL;
Expand All @@ -31,8 +40,7 @@ static int __vlan_add(struct net_port_vlans *v, u16 vid, u16 flags)
int err;

if (test_bit(vid, v->vlan_bitmap)) {
if (flags & BRIDGE_VLAN_INFO_PVID)
__vlan_add_pvid(v, vid);
__vlan_add_flags(v, vid, flags);
return 0;
}

Expand Down Expand Up @@ -69,8 +77,7 @@ static int __vlan_add(struct net_port_vlans *v, u16 vid, u16 flags)

set_bit(vid, v->vlan_bitmap);
v->num_vlans++;
if (flags & BRIDGE_VLAN_INFO_PVID)
__vlan_add_pvid(v, vid);
__vlan_add_flags(v, vid, flags);

return 0;

Expand All @@ -86,6 +93,7 @@ static int __vlan_del(struct net_port_vlans *v, u16 vid)
return -EINVAL;

__vlan_delete_pvid(v, vid);
clear_bit(vid, v->untagged_bitmap);

if (v->port_idx && vid) {
struct net_device *dev = v->parent.port->dev;
Expand Down Expand Up @@ -144,11 +152,11 @@ struct sk_buff *br_handle_vlan(struct net_bridge *br,
goto out;

/* At this point, we know that the frame was filtered and contains
* a valid vlan id. If the vlan id matches the pvid of current port
* a valid vlan id. If the vlan id is set in the untagged bitmap,
* send untagged; otherwise, send taged.
*/
br_vlan_get_tag(skb, &vid);
if (vid == br_get_pvid(pv))
if (test_bit(vid, pv->untagged_bitmap))
skb = br_vlan_untag(skb);
else {
/* Egress policy says "send tagged". If output device
Expand Down

0 comments on commit 311efb8

Please sign in to comment.