Skip to content

Commit e35259a

Browse files
Izabela48davem330
authored andcommitted
tun: Persistent devices can get stuck in xoff state
The scenario goes like this. App stops reading from tun/tap. TX queue gets full and driver does netif_stop_queue(). App closes fd and TX queue gets flushed as part of the cleanup. Next time the app opens tun/tap and starts reading from it but the xoff state is not cleared. We're stuck. Normally xoff state is cleared when netdev is brought up. But in the case of persistent devices this happens only during initial setup. The fix is trivial. If device is already up when an app opens it we clear xoff state and that gets things moving again. Signed-off-by: Max Krasnyansky <maxk@qualcomm.com> Tested-by: Christian Borntraeger <borntraeger@de.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ccf9b3b commit e35259a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/net/tun.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,12 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
602602
tun->attached = 1;
603603
get_net(dev_net(tun->dev));
604604

605+
/* Make sure persistent devices do not get stuck in
606+
* xoff state.
607+
*/
608+
if (netif_running(tun->dev))
609+
netif_wake_queue(tun->dev);
610+
605611
strcpy(ifr->ifr_name, tun->dev->name);
606612
return 0;
607613

0 commit comments

Comments
 (0)