tun: fix carrier on/off status
Commit c8d68e6be1
removed carrier off call
from tun_detach since it's now called on queue disable and not only on
tun close. This confuses userspace which used this flag to detect a
free tun. To fix, put this back but under if (clean).
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Tested-by: Jason Wang <jasowang@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Tested-by: Toralf Förster <toralf.foerster@gmx.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
604dfd6efc
commit
af668b3c27
@ -439,10 +439,13 @@ static void __tun_detach(struct tun_file *tfile, bool clean)
|
||||
}
|
||||
|
||||
if (clean) {
|
||||
if (tun && tun->numqueues == 0 && tun->numdisabled == 0 &&
|
||||
!(tun->flags & TUN_PERSIST))
|
||||
if (tun->dev->reg_state == NETREG_REGISTERED)
|
||||
if (tun && tun->numqueues == 0 && tun->numdisabled == 0) {
|
||||
netif_carrier_off(tun->dev);
|
||||
|
||||
if (!(tun->flags & TUN_PERSIST) &&
|
||||
tun->dev->reg_state == NETREG_REGISTERED)
|
||||
unregister_netdevice(tun->dev);
|
||||
}
|
||||
|
||||
BUG_ON(!test_bit(SOCK_EXTERNALLY_ALLOCATED,
|
||||
&tfile->socket.flags));
|
||||
@ -1658,9 +1661,9 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
|
||||
device_create_file(&tun->dev->dev, &dev_attr_owner) ||
|
||||
device_create_file(&tun->dev->dev, &dev_attr_group))
|
||||
pr_err("Failed to create tun sysfs files\n");
|
||||
}
|
||||
|
||||
netif_carrier_on(tun->dev);
|
||||
}
|
||||
|
||||
tun_debug(KERN_INFO, tun, "tun_set_iff\n");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user