diff options
author | Jiri Pirko <jpirko@redhat.com> | 2011-12-08 04:11:17 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-12-08 19:52:42 -0500 |
commit | 87002b03baabd2b8f6281ab6411ed88d24958de1 (patch) | |
tree | 0e5730c0d1ba887488ba420d4ea89a230f272c51 /drivers/net/team | |
parent | 8e586137e6b63af1e881b328466ab5ffbe562510 (diff) | |
download | talos-obmc-linux-87002b03baabd2b8f6281ab6411ed88d24958de1.tar.gz talos-obmc-linux-87002b03baabd2b8f6281ab6411ed88d24958de1.zip |
net: introduce vlan_vid_[add/del] and use them instead of direct [add/kill]_vid ndo calls
This patch adds wrapper for ndo_vlan_rx_add_vid/ndo_vlan_rx_kill_vid
functions. Check for NETIF_F_HW_VLAN_FILTER feature is done in this
wrapper.
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/team')
-rw-r--r-- | drivers/net/team/team.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c index 8e8bf958539e..79c2d1b52eb6 100644 --- a/drivers/net/team/team.c +++ b/drivers/net/team/team.c @@ -18,6 +18,7 @@ #include <linux/ctype.h> #include <linux/notifier.h> #include <linux/netdevice.h> +#include <linux/if_vlan.h> #include <linux/if_arp.h> #include <linux/socket.h> #include <linux/etherdevice.h> @@ -906,17 +907,28 @@ static int team_vlan_rx_add_vid(struct net_device *dev, uint16_t vid) { struct team *team = netdev_priv(dev); struct team_port *port; + int err; - rcu_read_lock(); - list_for_each_entry_rcu(port, &team->port_list, list) { - const struct net_device_ops *ops = port->dev->netdev_ops; - - if (ops->ndo_vlan_rx_add_vid) - ops->ndo_vlan_rx_add_vid(port->dev, vid); + /* + * Alhough this is reader, it's guarded by team lock. It's not possible + * to traverse list in reverse under rcu_read_lock + */ + mutex_lock(&team->lock); + list_for_each_entry(port, &team->port_list, list) { + err = vlan_vid_add(port->dev, vid); + if (err) + goto unwind; } - rcu_read_unlock(); + mutex_unlock(&team->lock); return 0; + +unwind: + list_for_each_entry_continue_reverse(port, &team->port_list, list) + vlan_vid_del(port->dev, vid); + mutex_unlock(&team->lock); + + return err; } static int team_vlan_rx_kill_vid(struct net_device *dev, uint16_t vid) @@ -925,12 +937,8 @@ static int team_vlan_rx_kill_vid(struct net_device *dev, uint16_t vid) struct team_port *port; rcu_read_lock(); - list_for_each_entry_rcu(port, &team->port_list, list) { - const struct net_device_ops *ops = port->dev->netdev_ops; - - if (ops->ndo_vlan_rx_kill_vid) - ops->ndo_vlan_rx_kill_vid(port->dev, vid); - } + list_for_each_entry_rcu(port, &team->port_list, list) + vlan_vid_del(port->dev, vid); rcu_read_unlock(); return 0; |