Skip to content

Commit

Permalink
Linux NIC speed type made long to fit the actual value (#32223)
Browse files Browse the repository at this point in the history
Fixes #18090

Linux pal level struct for network info had only int32 field for speed. Even though our public API has it as long. The problem was in value overflowing in calculation MBits --> Bits.
  • Loading branch information
ManickaP authored Feb 14, 2020
1 parent 571f972 commit fd6bee6
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public unsafe struct IpAddressInfo
public unsafe struct NetworkInterfaceInfo
{
public fixed byte Name[16];
public long Speed;
public int InterfaceIndex;
public int Speed;
public int Mtu;
public ushort HardwareType;
public byte OperationalState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ int32_t SystemNative_GetNetworkInterfaces(int32_t * interfaceCount, NetworkInter
ecmd.cmd = ETHTOOL_GSET;
if (ioctl(socketfd, SIOCETHTOOL, &ifr) == 0)
{
nii->Speed = (int)ethtool_cmd_speed(&ecmd);
nii->Speed = (int64_t)ethtool_cmd_speed(&ecmd);
if (nii->Speed > 0)
{
// If we did not get -1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ typedef struct
typedef struct
{
char Name[16]; // OS Interface name.
int64_t Speed; // Link speed for physical interfaces.
uint32_t InterfaceIndex; // Interface index.
int32_t Speed; // Link speed for physical interfaces.
int32_t Mtu; // Interface MTU.
uint16_t HardwareType; // Interface mapped from L2 to NetworkInterfaceType.
uint8_t OperationalState; // Operational status.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public void BasicTest_AccessInstanceProperties_NoExceptions()

[Fact]
[PlatformSpecific(TestPlatforms.Linux)] // Some APIs are not supported on Linux
[ActiveIssue("https://github.com/dotnet/runtime/issues/18090")]
public void BasicTest_AccessInstanceProperties_NoExceptions_Linux()
{
foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
Expand Down

0 comments on commit fd6bee6

Please sign in to comment.