Commit 19236837 authored by Toshiaki Makita's avatar Toshiaki Makita Committed by David S. Miller

bridge: Use vlan_vid_[add/del] instead of direct ndo_vlan_rx_[add/kill]_vid calls

We should use wrapper functions vlan_vid_[add/del] instead of
ndo_vlan_rx_[add/kill]_vid. Otherwise, we might be not able to communicate
using vlan interface in a certain situation.

Example of problematic case:
  vconfig add eth0 10
  brctl addif br0 eth0
  bridge vlan add dev eth0 vid 10
  bridge vlan del dev eth0 vid 10
  brctl delif br0 eth0
In this case, we cannot communicate via eth0.10 because vlan 10 is
filtered by NIC that has the vlan filtering feature.
Signed-off-by: default avatarToshiaki Makita <makita.toshiaki@lab.ntt.co.jp>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0125737a
...@@ -34,7 +34,6 @@ static void __vlan_add_flags(struct net_port_vlans *v, u16 vid, u16 flags) ...@@ -34,7 +34,6 @@ static void __vlan_add_flags(struct net_port_vlans *v, u16 vid, u16 flags)
static int __vlan_add(struct net_port_vlans *v, u16 vid, u16 flags) static int __vlan_add(struct net_port_vlans *v, u16 vid, u16 flags)
{ {
const struct net_device_ops *ops;
struct net_bridge_port *p = NULL; struct net_bridge_port *p = NULL;
struct net_bridge *br; struct net_bridge *br;
struct net_device *dev; struct net_device *dev;
...@@ -53,17 +52,15 @@ static int __vlan_add(struct net_port_vlans *v, u16 vid, u16 flags) ...@@ -53,17 +52,15 @@ static int __vlan_add(struct net_port_vlans *v, u16 vid, u16 flags)
br = v->parent.br; br = v->parent.br;
dev = br->dev; dev = br->dev;
} }
ops = dev->netdev_ops;
if (p && (dev->features & NETIF_F_HW_VLAN_CTAG_FILTER)) { if (p) {
/* Add VLAN to the device filter if it is supported. /* Add VLAN to the device filter if it is supported.
* Stricly speaking, this is not necessary now, since * Stricly speaking, this is not necessary now, since
* devices are made promiscuous by the bridge, but if * devices are made promiscuous by the bridge, but if
* that ever changes this code will allow tagged * that ever changes this code will allow tagged
* traffic to enter the bridge. * traffic to enter the bridge.
*/ */
err = ops->ndo_vlan_rx_add_vid(dev, htons(ETH_P_8021Q), err = vlan_vid_add(dev, htons(ETH_P_8021Q), vid);
vid);
if (err) if (err)
return err; return err;
} }
...@@ -82,8 +79,8 @@ static int __vlan_add(struct net_port_vlans *v, u16 vid, u16 flags) ...@@ -82,8 +79,8 @@ static int __vlan_add(struct net_port_vlans *v, u16 vid, u16 flags)
return 0; return 0;
out_filt: out_filt:
if (p && (dev->features & NETIF_F_HW_VLAN_CTAG_FILTER)) if (p)
ops->ndo_vlan_rx_kill_vid(dev, htons(ETH_P_8021Q), vid); vlan_vid_del(dev, htons(ETH_P_8021Q), vid);
return err; return err;
} }
...@@ -95,13 +92,8 @@ static int __vlan_del(struct net_port_vlans *v, u16 vid) ...@@ -95,13 +92,8 @@ static int __vlan_del(struct net_port_vlans *v, u16 vid)
__vlan_delete_pvid(v, vid); __vlan_delete_pvid(v, vid);
clear_bit(vid, v->untagged_bitmap); clear_bit(vid, v->untagged_bitmap);
if (v->port_idx) { if (v->port_idx)
struct net_device *dev = v->parent.port->dev; vlan_vid_del(v->parent.port->dev, htons(ETH_P_8021Q), vid);
const struct net_device_ops *ops = dev->netdev_ops;
if (dev->features & NETIF_F_HW_VLAN_CTAG_FILTER)
ops->ndo_vlan_rx_kill_vid(dev, htons(ETH_P_8021Q), vid);
}
clear_bit(vid, v->vlan_bitmap); clear_bit(vid, v->vlan_bitmap);
v->num_vlans--; v->num_vlans--;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment