const struct net_port_vlans *pv;
struct bridge_vlan_info vinfo;
u16 vid;
+ u16 pvid;
if (port)
pv = nbp_get_vlan_info(port);
if (!af)
goto nla_put_failure;
+ pvid = br_get_pvid(pv);
for (vid = find_first_bit(pv->vlan_bitmap, BR_VLAN_BITMAP_LEN);
vid < BR_VLAN_BITMAP_LEN;
vid = find_next_bit(pv->vlan_bitmap,
BR_VLAN_BITMAP_LEN, vid+1)) {
vinfo.vid = vid;
vinfo.flags = 0;
+ if (vid == pvid)
+ vinfo.flags |= BRIDGE_VLAN_INFO_PVID;
if (nla_put(skb, IFLA_BRIDGE_VLAN_INFO,
sizeof(vinfo), &vinfo))
goto nla_put_failure;
switch (cmd) {
case RTM_SETLINK:
if (p) {
- err = nbp_vlan_add(p, vinfo->vid);
+ err = nbp_vlan_add(p, vinfo->vid, vinfo->flags);
if (err)
break;
if (vinfo->flags & BRIDGE_VLAN_INFO_MASTER)
- err = br_vlan_add(p->br, vinfo->vid);
+ err = br_vlan_add(p->br, vinfo->vid,
+ vinfo->flags);
} else
- err = br_vlan_add(br, vinfo->vid);
+ err = br_vlan_add(br, vinfo->vid, vinfo->flags);
if (err)
break;
extern struct sk_buff *br_handle_vlan(struct net_bridge *br,
const struct net_port_vlans *v,
struct sk_buff *skb);
-extern int br_vlan_add(struct net_bridge *br, u16 vid);
+extern int br_vlan_add(struct net_bridge *br, u16 vid, u16 flags);
extern int br_vlan_delete(struct net_bridge *br, u16 vid);
extern void br_vlan_flush(struct net_bridge *br);
extern int br_vlan_filter_toggle(struct net_bridge *br, unsigned long val);
-extern int nbp_vlan_add(struct net_bridge_port *port, u16 vid);
+extern int nbp_vlan_add(struct net_bridge_port *port, u16 vid, u16 flags);
extern int nbp_vlan_delete(struct net_bridge_port *port, u16 vid);
extern void nbp_vlan_flush(struct net_bridge_port *port);
return skb;
}
-static inline int br_vlan_add(struct net_bridge *br, u16 vid)
+static inline int br_vlan_add(struct net_bridge *br, u16 vid, u16 flags)
{
return -EOPNOTSUPP;
}
{
}
-static inline int nbp_vlan_add(struct net_bridge_port *port, u16 vid)
+static inline int nbp_vlan_add(struct net_bridge_port *port, u16 vid, u16 flags)
{
return -EOPNOTSUPP;
}
#include "br_private.h"
-static int __vlan_add(struct net_port_vlans *v, u16 vid)
+static void __vlan_add_pvid(struct net_port_vlans *v, u16 vid)
+{
+ if (v->pvid == vid)
+ return;
+
+ smp_wmb();
+ v->pvid = vid;
+}
+
+static void __vlan_delete_pvid(struct net_port_vlans *v, u16 vid)
+{
+ if (v->pvid != vid)
+ return;
+
+ smp_wmb();
+ v->pvid = 0;
+}
+
+static int __vlan_add(struct net_port_vlans *v, u16 vid, u16 flags)
{
int err;
- if (test_bit(vid, v->vlan_bitmap))
- return -EEXIST;
+ if (test_bit(vid, v->vlan_bitmap)) {
+ if (flags & BRIDGE_VLAN_INFO_PVID)
+ __vlan_add_pvid(v, vid);
+ return 0;
+ }
if (v->port_idx && vid) {
struct net_device *dev = v->parent.port->dev;
set_bit(vid, v->vlan_bitmap);
v->num_vlans++;
+ if (flags & BRIDGE_VLAN_INFO_PVID)
+ __vlan_add_pvid(v, vid);
+
return 0;
}
if (!test_bit(vid, v->vlan_bitmap))
return -EINVAL;
+ __vlan_delete_pvid(v, vid);
+
if (v->port_idx && vid) {
struct net_device *dev = v->parent.port->dev;
static void __vlan_flush(struct net_port_vlans *v)
{
+ smp_wmb();
+ v->pvid = 0;
bitmap_zero(v->vlan_bitmap, BR_VLAN_BITMAP_LEN);
if (v->port_idx)
rcu_assign_pointer(v->parent.port->vlan_info, NULL);
}
/* Must be protected by RTNL */
-int br_vlan_add(struct net_bridge *br, u16 vid)
+int br_vlan_add(struct net_bridge *br, u16 vid, u16 flags)
{
struct net_port_vlans *pv = NULL;
int err;
pv = rtnl_dereference(br->vlan_info);
if (pv)
- return __vlan_add(pv, vid);
+ return __vlan_add(pv, vid, flags);
/* Create port vlan infomration
*/
return -ENOMEM;
pv->parent.br = br;
- err = __vlan_add(pv, vid);
+ err = __vlan_add(pv, vid, flags);
if (err)
goto out;
struct net_port_vlans *pv;
ASSERT_RTNL();
-
pv = rtnl_dereference(br->vlan_info);
if (!pv)
return;
}
/* Must be protected by RTNL */
-int nbp_vlan_add(struct net_bridge_port *port, u16 vid)
+int nbp_vlan_add(struct net_bridge_port *port, u16 vid, u16 flags)
{
struct net_port_vlans *pv = NULL;
int err;
pv = rtnl_dereference(port->vlan_info);
if (pv)
- return __vlan_add(pv, vid);
+ return __vlan_add(pv, vid, flags);
/* Create port vlan infomration
*/
pv->port_idx = port->port_no;
pv->parent.port = port;
- err = __vlan_add(pv, vid);
+ err = __vlan_add(pv, vid, flags);
if (err)
goto clean_up;