Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 026dbca

Browse files
committed
Return Linux NetworkInterface speed as bits per second, not megabits.
* Continue allowing -1 to be returned, as well.
1 parent e6b5ea9 commit 026dbca

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/System.Net.NetworkInformation/src/System/Net/NetworkInformation/LinuxNetworkInterface.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,10 @@ public override long Speed
195195
try
196196
{
197197
string path = Path.Combine(NetworkFiles.SysClassNetFolder, name, NetworkFiles.SpeedFileName);
198-
return StringParsingHelpers.ParseRawLongFile(path);
198+
long megabitsPerSecond = StringParsingHelpers.ParseRawLongFile(path);
199+
return megabitsPerSecond == -1
200+
? megabitsPerSecond
201+
: megabitsPerSecond * 1_000_000; // Value must be returned in bits per second, not megabits.
199202
}
200203
catch (Exception) // Ignore any problems accessing or parsing the file.
201204
{

0 commit comments

Comments
 (0)