xen-netback: disable rogue vif in kthread context
[firefly-linux-kernel-4.4.55.git] / drivers / net / xen-netback / interface.c
index cdc298e3b747b71a58c625f5e1aefe7dc9d8cb7c..ef05c5c49d413d5bb23a3e4adbff88cb0c9ad7cd 100644 (file)
@@ -63,6 +63,15 @@ static int xenvif_poll(struct napi_struct *napi, int budget)
        struct xenvif *vif = container_of(napi, struct xenvif, napi);
        int work_done;
 
+       /* This vif is rogue, we pretend we've there is nothing to do
+        * for this vif to deschedule it from NAPI. But this interface
+        * will be turned off in thread context later.
+        */
+       if (unlikely(vif->disabled)) {
+               napi_complete(napi);
+               return 0;
+       }
+
        work_done = xenvif_tx_action(vif, budget);
 
        if (work_done < budget) {
@@ -363,6 +372,8 @@ struct xenvif *xenvif_alloc(struct device *parent, domid_t domid,
        vif->ip_csum = 1;
        vif->dev = dev;
 
+       vif->disabled = false;
+
        vif->credit_bytes = vif->remaining_credit = ~0UL;
        vif->credit_usec  = 0UL;
        init_timer(&vif->credit_timeout);