]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
tun: keep link (carrier) state up to date
authorNolan Leake <nolan@cumulusnetworks.com>
Tue, 27 Jul 2010 13:53:43 +0000 (13:53 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sat, 31 Jul 2010 05:06:41 +0000 (22:06 -0700)
Currently, only ethtool can get accurate link state of a tap device.
With this patch, IFF_RUNNING and IF_OPER_UP/DOWN are kept up to date as
well.

Signed-off-by: Nolan Leake <nolan@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/tun.c

index 63042596f0cf34962afe9c25133e27b0aa746701..55f3a3e667a9af0291da7c7d4e46c12e84d7ce6a 100644 (file)
@@ -149,6 +149,7 @@ static int tun_attach(struct tun_struct *tun, struct file *file)
        tfile->tun = tun;
        tun->tfile = tfile;
        tun->socket.file = file;
+       netif_carrier_on(tun->dev);
        dev_hold(tun->dev);
        sock_hold(tun->socket.sk);
        atomic_inc(&tfile->count);
@@ -162,6 +163,7 @@ static void __tun_detach(struct tun_struct *tun)
 {
        /* Detach from net device */
        netif_tx_lock_bh(tun->dev);
+       netif_carrier_off(tun->dev);
        tun->tfile = NULL;
        tun->socket.file = NULL;
        netif_tx_unlock_bh(tun->dev);
@@ -1574,12 +1576,6 @@ static void tun_set_msglevel(struct net_device *dev, u32 value)
 #endif
 }
 
-static u32 tun_get_link(struct net_device *dev)
-{
-       struct tun_struct *tun = netdev_priv(dev);
-       return !!tun->tfile;
-}
-
 static u32 tun_get_rx_csum(struct net_device *dev)
 {
        struct tun_struct *tun = netdev_priv(dev);
@@ -1601,7 +1597,7 @@ static const struct ethtool_ops tun_ethtool_ops = {
        .get_drvinfo    = tun_get_drvinfo,
        .get_msglevel   = tun_get_msglevel,
        .set_msglevel   = tun_set_msglevel,
-       .get_link       = tun_get_link,
+       .get_link       = ethtool_op_get_link,
        .get_rx_csum    = tun_get_rx_csum,
        .set_rx_csum    = tun_set_rx_csum
 };