From: Willy Tarreau <w@1wt.eu>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Ben Hutchings <bhutchings@solarflare.com>,
"David S. Miller" <davem@davemloft.net>,
Wang Weidong <wangweidong1@huawei.com>, Willy Tarreau <w@1wt.eu>
Subject: [ 1/9] ethtool: Report link-down while interface is down
Date: Sat, 14 Jun 2014 21:12:51 +0200 [thread overview]
Message-ID: <20140614191250.169302421@1wt.eu> (raw)
In-Reply-To: <57d1129d02f4fc14423dd66474950cb7@local>
2.6.32-longterm review patch. If anyone has any objections, please let me know.
------------------
From: Ben Hutchings <bhutchings@solarflare.com>
While an interface is down, many implementations of
ethtool_ops::get_link, including the default, ethtool_op_get_link(),
will report the last link state seen while the interface was up. In
general the current physical link state is not available if the
interface is down.
Define ETHTOOL_GLINK to reflect whether the interface *and* any
physical port have a working link, and consistently return 0 when the
interface is down.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit e596e6e4d578f2639416e620d367a3af34814a40)
Cc: Wang Weidong <wangweidong1@huawei.com>
Signed-off-by: Willy Tarreau <w@1wt.eu>
---
include/linux/ethtool.h | 4 +++-
net/core/ethtool.c | 17 +++++++++++++++--
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h
index 7ffab7cb..3a0fae6 100644
--- a/include/linux/ethtool.h
+++ b/include/linux/ethtool.h
@@ -517,7 +517,9 @@ struct ethtool_ops {
#define ETHTOOL_GMSGLVL 0x00000007 /* Get driver message level */
#define ETHTOOL_SMSGLVL 0x00000008 /* Set driver msg level. */
#define ETHTOOL_NWAY_RST 0x00000009 /* Restart autonegotiation. */
-#define ETHTOOL_GLINK 0x0000000a /* Get link status (ethtool_value) */
+/* Get link status for host, i.e. whether the interface *and* the
+ * physical port (if there is one) are up (ethtool_value). */
+#define ETHTOOL_GLINK 0x0000000a
#define ETHTOOL_GEEPROM 0x0000000b /* Get EEPROM data */
#define ETHTOOL_SEEPROM 0x0000000c /* Set EEPROM data. */
#define ETHTOOL_GCOALESCE 0x0000000e /* Get coalesce config */
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index abbe8fa..f9e7179 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -365,6 +365,20 @@ static int ethtool_nway_reset(struct net_device *dev)
return dev->ethtool_ops->nway_reset(dev);
}
+static int ethtool_get_link(struct net_device *dev, char __user *useraddr)
+{
+ struct ethtool_value edata = { .cmd = ETHTOOL_GLINK };
+
+ if (!dev->ethtool_ops->get_link)
+ return -EOPNOTSUPP;
+
+ edata.data = netif_running(dev) && dev->ethtool_ops->get_link(dev);
+
+ if (copy_to_user(useraddr, &edata, sizeof(edata)))
+ return -EFAULT;
+ return 0;
+}
+
static int ethtool_get_eeprom(struct net_device *dev, void __user *useraddr)
{
struct ethtool_eeprom eeprom;
@@ -1016,8 +1030,7 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
rc = ethtool_nway_reset(dev);
break;
case ETHTOOL_GLINK:
- rc = ethtool_get_value(dev, useraddr, ethcmd,
- dev->ethtool_ops->get_link);
+ rc = ethtool_get_link(dev, useraddr);
break;
case ETHTOOL_GEEPROM:
rc = ethtool_get_eeprom(dev, useraddr);
--
1.7.12.2.21.g234cd45.dirty
next prev parent reply other threads:[~2014-06-14 20:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <57d1129d02f4fc14423dd66474950cb7@local>
2014-06-14 19:12 ` [ 0/9] 2.6.32.63-longterm review Willy Tarreau
2014-06-14 19:12 ` Willy Tarreau [this message]
2014-06-14 19:12 ` [ 2/9] futex: Add another early deadlock detection check Willy Tarreau
2014-06-14 19:12 ` [ 3/9] futex: Prevent attaching to kernel threads Willy Tarreau
2014-06-14 19:12 ` [ 4/9] futex-prevent-requeue-pi-on-same-futex.patch futex: Willy Tarreau
2014-06-14 19:12 ` [ 5/9] futex: Validate atomic acquisition in Willy Tarreau
2014-06-14 19:12 ` [ 6/9] futex: Always cleanup owner tid in unlock_pi Willy Tarreau
2014-06-14 19:12 ` [ 7/9] futex: Make lookup_pi_state more robust Willy Tarreau
2014-06-14 19:12 ` [ 8/9] auditsc: audit_krule mask accesses need bounds checking Willy Tarreau
2014-06-14 19:12 ` [ 9/9] net: fix regression introduced in 2.6.32.62 by sysctl Willy Tarreau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140614191250.169302421@1wt.eu \
--to=w@1wt.eu \
--cc=bhutchings@solarflare.com \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=wangweidong1@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®