diff options
author | Jiri Pirko <jpirko@redhat.com> | 2011-12-07 23:11:17 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-12-08 19:52:42 -0500 |
commit | 87002b03baabd2b8f6281ab6411ed88d24958de1 (patch) | |
tree | 0e5730c0d1ba887488ba420d4ea89a230f272c51 /net/8021q | |
parent | 8e586137e6b63af1e881b328466ab5ffbe562510 (diff) |
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 'net/8021q')
-rw-r--r-- | net/8021q/vlan.c | 14 | ||||
-rw-r--r-- | net/8021q/vlan_core.c | 23 |
2 files changed, 28 insertions, 9 deletions
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index e075625efeeb..dd9aa400888b 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c | |||
@@ -101,7 +101,6 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head) | |||
101 | { | 101 | { |
102 | struct vlan_dev_priv *vlan = vlan_dev_priv(dev); | 102 | struct vlan_dev_priv *vlan = vlan_dev_priv(dev); |
103 | struct net_device *real_dev = vlan->real_dev; | 103 | struct net_device *real_dev = vlan->real_dev; |
104 | const struct net_device_ops *ops = real_dev->netdev_ops; | ||
105 | struct vlan_group *grp; | 104 | struct vlan_group *grp; |
106 | u16 vlan_id = vlan->vlan_id; | 105 | u16 vlan_id = vlan->vlan_id; |
107 | 106 | ||
@@ -114,8 +113,8 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head) | |||
114 | * HW accelerating devices or SW vlan input packet processing if | 113 | * HW accelerating devices or SW vlan input packet processing if |
115 | * VLAN is not 0 (leave it there for 802.1p). | 114 | * VLAN is not 0 (leave it there for 802.1p). |
116 | */ | 115 | */ |
117 | if (vlan_id && (real_dev->features & NETIF_F_HW_VLAN_FILTER)) | 116 | if (vlan_id) |
118 | ops->ndo_vlan_rx_kill_vid(real_dev, vlan_id); | 117 | vlan_vid_del(real_dev, vlan_id); |
119 | 118 | ||
120 | grp->nr_vlans--; | 119 | grp->nr_vlans--; |
121 | 120 | ||
@@ -169,7 +168,6 @@ int register_vlan_dev(struct net_device *dev) | |||
169 | { | 168 | { |
170 | struct vlan_dev_priv *vlan = vlan_dev_priv(dev); | 169 | struct vlan_dev_priv *vlan = vlan_dev_priv(dev); |
171 | struct net_device *real_dev = vlan->real_dev; | 170 | struct net_device *real_dev = vlan->real_dev; |
172 | const struct net_device_ops *ops = real_dev->netdev_ops; | ||
173 | u16 vlan_id = vlan->vlan_id; | 171 | u16 vlan_id = vlan->vlan_id; |
174 | struct vlan_group *grp, *ngrp = NULL; | 172 | struct vlan_group *grp, *ngrp = NULL; |
175 | int err; | 173 | int err; |
@@ -207,8 +205,7 @@ int register_vlan_dev(struct net_device *dev) | |||
207 | if (ngrp) { | 205 | if (ngrp) { |
208 | rcu_assign_pointer(real_dev->vlgrp, ngrp); | 206 | rcu_assign_pointer(real_dev->vlgrp, ngrp); |
209 | } | 207 | } |
210 | if (real_dev->features & NETIF_F_HW_VLAN_FILTER) | 208 | vlan_vid_add(real_dev, vlan_id); |
211 | ops->ndo_vlan_rx_add_vid(real_dev, vlan_id); | ||
212 | 209 | ||
213 | return 0; | 210 | return 0; |
214 | 211 | ||
@@ -369,11 +366,10 @@ static int vlan_device_event(struct notifier_block *unused, unsigned long event, | |||
369 | __vlan_device_event(dev, event); | 366 | __vlan_device_event(dev, event); |
370 | 367 | ||
371 | if ((event == NETDEV_UP) && | 368 | if ((event == NETDEV_UP) && |
372 | (dev->features & NETIF_F_HW_VLAN_FILTER) && | 369 | (dev->features & NETIF_F_HW_VLAN_FILTER)) { |
373 | dev->netdev_ops->ndo_vlan_rx_add_vid) { | ||
374 | pr_info("adding VLAN 0 to HW filter on device %s\n", | 370 | pr_info("adding VLAN 0 to HW filter on device %s\n", |
375 | dev->name); | 371 | dev->name); |
376 | dev->netdev_ops->ndo_vlan_rx_add_vid(dev, 0); | 372 | vlan_vid_add(dev, 0); |
377 | } | 373 | } |
378 | 374 | ||
379 | grp = rtnl_dereference(dev->vlgrp); | 375 | grp = rtnl_dereference(dev->vlgrp); |
diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c index 85241f044294..544f9cb9678c 100644 --- a/net/8021q/vlan_core.c +++ b/net/8021q/vlan_core.c | |||
@@ -146,3 +146,26 @@ err_free: | |||
146 | kfree_skb(skb); | 146 | kfree_skb(skb); |
147 | return NULL; | 147 | return NULL; |
148 | } | 148 | } |
149 | |||
150 | int vlan_vid_add(struct net_device *dev, unsigned short vid) | ||
151 | { | ||
152 | const struct net_device_ops *ops = dev->netdev_ops; | ||
153 | |||
154 | if ((dev->features & NETIF_F_HW_VLAN_FILTER) && | ||
155 | ops->ndo_vlan_rx_add_vid) { | ||
156 | return ops->ndo_vlan_rx_add_vid(dev, vid); | ||
157 | } | ||
158 | return 0; | ||
159 | } | ||
160 | EXPORT_SYMBOL(vlan_vid_add); | ||
161 | |||
162 | void vlan_vid_del(struct net_device *dev, unsigned short vid) | ||
163 | { | ||
164 | const struct net_device_ops *ops = dev->netdev_ops; | ||
165 | |||
166 | if ((dev->features & NETIF_F_HW_VLAN_FILTER) && | ||
167 | ops->ndo_vlan_rx_kill_vid) { | ||
168 | ops->ndo_vlan_rx_kill_vid(dev, vid); | ||
169 | } | ||
170 | } | ||
171 | EXPORT_SYMBOL(vlan_vid_del); | ||