diff options
author | Nolan Leake <nolan@cumulusnetworks.com> | 2010-07-27 09:53:43 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-07-31 01:06:41 -0400 |
commit | bee31369ce16fc3898ec9a54161248c9eddb06bc (patch) | |
tree | 5c5752c2263e7523941f663788ed406328b81b1b /drivers/net/tun.c | |
parent | ae3568adf42d5d3bb3cfa505b94351c5d1ce4924 (diff) |
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>
Diffstat (limited to 'drivers/net/tun.c')
-rw-r--r-- | drivers/net/tun.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 63042596f0cf..55f3a3e667a9 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c | |||
@@ -149,6 +149,7 @@ static int tun_attach(struct tun_struct *tun, struct file *file) | |||
149 | tfile->tun = tun; | 149 | tfile->tun = tun; |
150 | tun->tfile = tfile; | 150 | tun->tfile = tfile; |
151 | tun->socket.file = file; | 151 | tun->socket.file = file; |
152 | netif_carrier_on(tun->dev); | ||
152 | dev_hold(tun->dev); | 153 | dev_hold(tun->dev); |
153 | sock_hold(tun->socket.sk); | 154 | sock_hold(tun->socket.sk); |
154 | atomic_inc(&tfile->count); | 155 | atomic_inc(&tfile->count); |
@@ -162,6 +163,7 @@ static void __tun_detach(struct tun_struct *tun) | |||
162 | { | 163 | { |
163 | /* Detach from net device */ | 164 | /* Detach from net device */ |
164 | netif_tx_lock_bh(tun->dev); | 165 | netif_tx_lock_bh(tun->dev); |
166 | netif_carrier_off(tun->dev); | ||
165 | tun->tfile = NULL; | 167 | tun->tfile = NULL; |
166 | tun->socket.file = NULL; | 168 | tun->socket.file = NULL; |
167 | netif_tx_unlock_bh(tun->dev); | 169 | netif_tx_unlock_bh(tun->dev); |
@@ -1574,12 +1576,6 @@ static void tun_set_msglevel(struct net_device *dev, u32 value) | |||
1574 | #endif | 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 | static u32 tun_get_rx_csum(struct net_device *dev) | 1579 | static u32 tun_get_rx_csum(struct net_device *dev) |
1584 | { | 1580 | { |
1585 | struct tun_struct *tun = netdev_priv(dev); | 1581 | struct tun_struct *tun = netdev_priv(dev); |
@@ -1601,7 +1597,7 @@ static const struct ethtool_ops tun_ethtool_ops = { | |||
1601 | .get_drvinfo = tun_get_drvinfo, | 1597 | .get_drvinfo = tun_get_drvinfo, |
1602 | .get_msglevel = tun_get_msglevel, | 1598 | .get_msglevel = tun_get_msglevel, |
1603 | .set_msglevel = tun_set_msglevel, | 1599 | .set_msglevel = tun_set_msglevel, |
1604 | .get_link = tun_get_link, | 1600 | .get_link = ethtool_op_get_link, |
1605 | .get_rx_csum = tun_get_rx_csum, | 1601 | .get_rx_csum = tun_get_rx_csum, |
1606 | .set_rx_csum = tun_set_rx_csum | 1602 | .set_rx_csum = tun_set_rx_csum |
1607 | }; | 1603 | }; |