lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200327024552.22170-1-kai.heng.feng@canonical.com>
Date:   Fri, 27 Mar 2020 10:45:51 +0800
From:   Kai-Heng Feng <kai.heng.feng@...onical.com>
To:     davem@...emloft.net, kuba@...nel.org
Cc:     alexander.duyck@...il.com,
        Kai-Heng Feng <kai.heng.feng@...onical.com>,
        Jeff Kirsher <jeffrey.t.kirsher@...el.com>,
        Aaron Brown <aaron.f.brown@...el.com>,
        Michal Kubecek <mkubecek@...e.cz>,
        Florian Fainelli <f.fainelli@...il.com>,
        Andrew Lunn <andrew@...n.ch>,
        Maxime Chevallier <maxime.chevallier@...tlin.com>,
        netdev@...r.kernel.org (open list:NETWORKING [GENERAL]),
        linux-kernel@...r.kernel.org (open list)
Subject: [PATCH] ethtool: Report speed and duplex as unknown when device is runtime suspended

Device like igb gets runtime suspended when there's no link partner. We
can't get correct speed under that state:
$ cat /sys/class/net/enp3s0/speed
1000

In addition to that, an error can also be spotted in dmesg:
[  385.991957] igb 0000:03:00.0 enp3s0: PCIe link lost

Since device can only be runtime suspended when there's no link partner,
we can directly report the speed and duplex as unknown.

Cc: Jeff Kirsher <jeffrey.t.kirsher@...el.com>
Cc: Aaron Brown <aaron.f.brown@...el.com>
Suggested-by: Alexander Duyck <alexander.duyck@...il.com>
Signed-off-by: Kai-Heng Feng <kai.heng.feng@...onical.com>
---
 net/ethtool/ioctl.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 10d929abdf6a..2ba04aa9d775 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -28,6 +28,7 @@
 #include <net/xdp_sock.h>
 #include <net/flow_offload.h>
 #include <linux/ethtool_netlink.h>
+#include <linux/pm_runtime.h>
 
 #include "common.h"
 
@@ -429,6 +430,13 @@ int __ethtool_get_link_ksettings(struct net_device *dev,
 		return -EOPNOTSUPP;
 
 	memset(link_ksettings, 0, sizeof(*link_ksettings));
+
+	if (pm_runtime_suspended(dev->dev.parent)) {
+		link_ksettings->base.duplex = DUPLEX_UNKNOWN;
+		link_ksettings->base.speed = SPEED_UNKNOWN;
+		return 0;
+	}
+
 	return dev->ethtool_ops->get_link_ksettings(dev, link_ksettings);
 }
 EXPORT_SYMBOL(__ethtool_get_link_ksettings);
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ