diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2013-01-27 19:38:02 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-01-29 15:43:03 -0500 |
commit | af668b3c276d0f958a3aa46ef8ec47e2d5d333b3 (patch) | |
tree | 68525f9d6ee11d9c1a9033001a4e106c7cb44071 /drivers/net/tun.c | |
parent | 604dfd6efc9b79bce432f2394791708d8e8f6efc (diff) |
tun: fix carrier on/off status
Commit c8d68e6be1c3b242f1c598595830890b65cea64a 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>
Diffstat (limited to 'drivers/net/tun.c')
-rw-r--r-- | drivers/net/tun.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index cc09b67c23bc..ffdb84474c47 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c | |||
@@ -439,10 +439,13 @@ static void __tun_detach(struct tun_file *tfile, bool clean) | |||
439 | } | 439 | } |
440 | 440 | ||
441 | if (clean) { | 441 | if (clean) { |
442 | if (tun && tun->numqueues == 0 && tun->numdisabled == 0 && | 442 | if (tun && tun->numqueues == 0 && tun->numdisabled == 0) { |
443 | !(tun->flags & TUN_PERSIST)) | 443 | netif_carrier_off(tun->dev); |
444 | if (tun->dev->reg_state == NETREG_REGISTERED) | 444 | |
445 | if (!(tun->flags & TUN_PERSIST) && | ||
446 | tun->dev->reg_state == NETREG_REGISTERED) | ||
445 | unregister_netdevice(tun->dev); | 447 | unregister_netdevice(tun->dev); |
448 | } | ||
446 | 449 | ||
447 | BUG_ON(!test_bit(SOCK_EXTERNALLY_ALLOCATED, | 450 | BUG_ON(!test_bit(SOCK_EXTERNALLY_ALLOCATED, |
448 | &tfile->socket.flags)); | 451 | &tfile->socket.flags)); |
@@ -1658,10 +1661,10 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) | |||
1658 | device_create_file(&tun->dev->dev, &dev_attr_owner) || | 1661 | device_create_file(&tun->dev->dev, &dev_attr_owner) || |
1659 | device_create_file(&tun->dev->dev, &dev_attr_group)) | 1662 | device_create_file(&tun->dev->dev, &dev_attr_group)) |
1660 | pr_err("Failed to create tun sysfs files\n"); | 1663 | pr_err("Failed to create tun sysfs files\n"); |
1661 | |||
1662 | netif_carrier_on(tun->dev); | ||
1663 | } | 1664 | } |
1664 | 1665 | ||
1666 | netif_carrier_on(tun->dev); | ||
1667 | |||
1665 | tun_debug(KERN_INFO, tun, "tun_set_iff\n"); | 1668 | tun_debug(KERN_INFO, tun, "tun_set_iff\n"); |
1666 | 1669 | ||
1667 | if (ifr->ifr_flags & IFF_NO_PI) | 1670 | if (ifr->ifr_flags & IFF_NO_PI) |