Commit bee31369ce16fc3898ec9a54161248c9eddb06bc

Authored by Nolan Leake
Committed by David S. Miller
1 parent ae3568adf4

tun: keep link (carrier) state up to date

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>

Showing 1 changed file with 3 additions and 7 deletions Side-by-side Diff

... ... @@ -149,6 +149,7 @@
149 149 tfile->tun = tun;
150 150 tun->tfile = tfile;
151 151 tun->socket.file = file;
  152 + netif_carrier_on(tun->dev);
152 153 dev_hold(tun->dev);
153 154 sock_hold(tun->socket.sk);
154 155 atomic_inc(&tfile->count);
... ... @@ -162,6 +163,7 @@
162 163 {
163 164 /* Detach from net device */
164 165 netif_tx_lock_bh(tun->dev);
  166 + netif_carrier_off(tun->dev);
165 167 tun->tfile = NULL;
166 168 tun->socket.file = NULL;
167 169 netif_tx_unlock_bh(tun->dev);
... ... @@ -1574,12 +1576,6 @@
1574 1576 #endif
1575 1577 }
1576 1578  
1577   -static u32 tun_get_link(struct net_device *dev)
1578   -{
1579   - struct tun_struct *tun = netdev_priv(dev);
1580   - return !!tun->tfile;
1581   -}
1582   -
1583 1579 static u32 tun_get_rx_csum(struct net_device *dev)
1584 1580 {
1585 1581 struct tun_struct *tun = netdev_priv(dev);
... ... @@ -1601,7 +1597,7 @@
1601 1597 .get_drvinfo = tun_get_drvinfo,
1602 1598 .get_msglevel = tun_get_msglevel,
1603 1599 .set_msglevel = tun_set_msglevel,
1604   - .get_link = tun_get_link,
  1600 + .get_link = ethtool_op_get_link,
1605 1601 .get_rx_csum = tun_get_rx_csum,
1606 1602 .set_rx_csum = tun_set_rx_csum
1607 1603 };