[lxc-devel] [lxd/master] ethtool: don't report -1 for speed in ethtoolLink()

brauner on Github lxc-bot at linuxcontainers.org
Tue May 19 05:44:50 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 442 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200518/e603dc3e/attachment.bin>
-------------- next part --------------
From 68ee8bd0dfd9671faefb6e95af7eb7cefbf214ef Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Tue, 19 May 2020 07:42:44 +0200
Subject: [PATCH] ethtool: don't report -1 for speed in ethtoolLink()

the same way we don't in the legacy part of the interface.

Closes: #7382.
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
 lxd/resources/network_ethtool.go | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lxd/resources/network_ethtool.go b/lxd/resources/network_ethtool.go
index fd534c4286..1938cc8afe 100644
--- a/lxd/resources/network_ethtool.go
+++ b/lxd/resources/network_ethtool.go
@@ -300,7 +300,10 @@ func ethtoolLink(ethtoolFd int, req *ethtoolReq, info *api.ResourcesNetworkCardP
 		}
 
 		// Link speed
-		info.LinkSpeed = uint64(ethLinkSettings.speed)
+		speed := uint64(ethLinkSettings.speed)
+		if speed < uint64(^uint32(0)) {
+			info.LinkSpeed = speed
+		}
 	}
 
 	// Transceiver


More information about the lxc-devel mailing list