netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net-sysfs: Report link speed as signed integer
@ 2014-06-02 14:25 Michal Privoznik
  2014-06-02 14:35 ` Jiri Pirko
  0 siblings, 1 reply; 9+ messages in thread
From: Michal Privoznik @ 2014-06-02 14:25 UTC (permalink / raw)
  To: davem; +Cc: gregkh, jiri, linux-kernel, netdev

The link speed is available at /sys/class/net/$nic/speed.
However, the speed is printed in unsigned integer format. This
makes userspace applications read an incorrect value (which
moreover changes through several architectures) while in fact
'-1' should be reported.

Before the change:
  # cat /sys/class/net/eth0/speed
  4294967295

After the change:
  # cat /sys/class/net/eth0/speed
  -1

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 net/core/net-sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 1cac29e..99afdea 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -173,7 +173,7 @@ static ssize_t speed_show(struct device *dev,
 	if (netif_running(netdev)) {
 		struct ethtool_cmd cmd;
 		if (!__ethtool_get_settings(netdev, &cmd))
-			ret = sprintf(buf, fmt_udec, ethtool_cmd_speed(&cmd));
+			ret = sprintf(buf, fmt_dec, ethtool_cmd_speed(&cmd));
 	}
 	rtnl_unlock();
 	return ret;
-- 
2.0.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-06-03 12:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-02 14:25 [PATCH] net-sysfs: Report link speed as signed integer Michal Privoznik
2014-06-02 14:35 ` Jiri Pirko
2014-06-02 14:40   ` Bjørn Mork
2014-06-02 14:43   ` Michal Privoznik
2014-06-02 15:01   ` Veaceslav Falico
2014-06-02 17:21     ` Florian Fainelli
2014-06-02 18:10     ` David Miller
2014-06-03  7:07       ` Michal Privoznik
2014-06-03 12:05         ` Michal Privoznik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).