vlan: Invoke driver vlan hooks only if device is present
authorPadmanabh Ratnakar <padmanabh.ratnakar@avagotech.com>
Tue, 3 Nov 2015 14:55:59 +0000 (20:25 +0530)
committerDavid S. Miller <davem@davemloft.net>
Tue, 3 Nov 2015 16:29:56 +0000 (11:29 -0500)
NIC drivers mark device as detached during error recovery.
It expects no manangement hooks to be invoked in this state.
Invoke driver vlan hooks only if device is present.

Signed-off-by: Padmanabh Ratnakar <padmanabh.ratnakar@avagotech.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/8021q/vlan_core.c

index 61bf2a06e85d62ce9d319b02f1bf1ebb569e3964..496b27588493ded6edb0bf408440ecaa56dcd59c 100644 (file)
@@ -206,7 +206,10 @@ static int __vlan_vid_add(struct vlan_info *vlan_info, __be16 proto, u16 vid,
                return -ENOMEM;
 
        if (vlan_hw_filter_capable(dev, vid_info)) {
-               err =  ops->ndo_vlan_rx_add_vid(dev, proto, vid);
+               if (netif_device_present(dev))
+                       err = ops->ndo_vlan_rx_add_vid(dev, proto, vid);
+               else
+                       err = -ENODEV;
                if (err) {
                        kfree(vid_info);
                        return err;
@@ -264,7 +267,10 @@ static void __vlan_vid_del(struct vlan_info *vlan_info,
        int err;
 
        if (vlan_hw_filter_capable(dev, vid_info)) {
-               err = ops->ndo_vlan_rx_kill_vid(dev, proto, vid);
+               if (netif_device_present(dev))
+                       err = ops->ndo_vlan_rx_kill_vid(dev, proto, vid);
+               else
+                       err = -ENODEV;
                if (err) {
                        pr_warn("failed to kill vid %04x/%d for device %s\n",
                                proto, vid, dev->name);