Skip to content

Commit

Permalink
tun: Persistent devices can get stuck in xoff state
Browse files Browse the repository at this point in the history
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 <[email protected]>
Tested-by: Christian Borntraeger <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Izabela48 authored and davem330 committed Jul 10, 2008
1 parent ccf9b3b commit e35259a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/net/tun.c
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,12 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
tun->attached = 1;
get_net(dev_net(tun->dev));

/* Make sure persistent devices do not get stuck in
* xoff state.
*/
if (netif_running(tun->dev))
netif_wake_queue(tun->dev);

strcpy(ifr->ifr_name, tun->dev->name);
return 0;

Expand Down

0 comments on commit e35259a

Please sign in to comment.