FULL PRODUCT VERSION :
A DESCRIPTION OF THE PROBLEM :
This defect seems to be closely related to "JDK-8021372 : NetworkInterface.getNetworkInterfaces() returns duplicate hardware address". However the fix for JDK-8021372 has not solved this issue. On a PC with three NICs (Network Interface cards), one of which is internal (ntel(R) 82567LM-3 Gigabit Network Connection) and two of which are PCI NICs (Realtek RTL8169/8110-Familie-PCI-Gigabit-Ethernet-NIC (NDIS 6.20) and D-Link DFE-530TX PCI-Fast-Ethernet-Adapter (rev.C)) I see a problem where NetworkInterface.isUp() and NetworkInterface.getHardwareAddress() return incorrect information.
If all three NICs are active and we retrieve the hardware addresses of the NICs using NetworkInterface.getHardwareAddress() the same address is returned for the two PCI NICs. This sounds exactly like the defectJDK-8021372. We downloaded the jre that JDK-8021372 was fixed in and the problem also occurs in that version.
More seriously for us NetworkInterface.isUp() also returns incorrect information. If we power down the switch that the first PCI NIC is connected to and call NetworkInterface.isUp() for both PCI NICs both are reported as being not up (we would expect only the first network interface to be marked as not up). If we power down only the switch that the second PCI NIC is connected to and call NetworkInterface.isUp() for both PCI NICs we see the expected result i.e. the first network interface is reported as up and the second is reported to be not up. Given this and the fact that the same hardware address is returned for both PCI NICs we are suspicious that the two PCI NICs are being confused internally in these methods and that the same information is being returned for both interfaces. Interstingly if we disable the first PCI NIC in windows the correct hardware address is now returned by NetworkInterface.getHardwareAddress() for the second PCI NIC (when both PIC NICs are active the hardware address of the first PCI NIC is returned).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
We have only seen this issue on PCs with the hardware set up described above (PC with three NICs (Network Interface cards), one of which is internal (Intel(R) 82567LM-3 Gigabit Network Connection) and two of which are PCI NICs (Realtek RTL8169/8110-Familie-PCI-Gigabit-Ethernet-NIC (NDIS 6.20) and D-Link DFE-530TX PCI-Fast-Ethernet-Adapter (rev.C))). NOTE: We have failed to reproduce it with other hardware setups e.g. PC with one internal NIC and two external USB ethernet adapters.
Steps [Duplicate Hardware Addresses]:
- Connect all NICs to live networks/powered up switches
- Run the source code pasted into this defect
Steps [sUp returning incorrect information]:
- Connect all NICs to live networks/powered up switches
- Power down the switch that the first PCI NIC is connected to
- Run the source code pasted into this defect
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Duplicate Hardware Addresses:
Correct hardware addresses returned for each network interface.
isUp returning incorrect information:
The isUp method should return a result of false for the network interface representing the first PCI NIC. The isUp method should return a result of true for the network interface representing the second PCI NIC.
ACTUAL -
Duplicate Hardware Addresses:
The same hardware address is returned for the network interfaces representing both PCI NICs. Note: this is the MAC address of the first PCI NIC. If we run ipconfig /all in windows we can see that both NICs have unqiue addresses.
isUp returning incorrect information:
The isUp method returns a result of false for the network interfaces representing both PCI NICs. The information for the second interface is inaccurate as this interface is actually up and functioning correctly.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.*;
import java.net.*;
import java.util.*;
public class Test
{
public static void main(String args[])
{
try
{
StringBuffer netIfInfo = new StringBuffer();
for(Enumeration e = NetworkInterface.getNetworkInterfaces(); e.hasMoreElements(); netIfInfo.append(System.getProperty("line.separator")))
{
NetworkInterface netIf = (NetworkInterface)e.nextElement();
netIfInfo.append("DisplayName: ");
netIfInfo.append(netIf.getDisplayName());
netIfInfo.append(System.getProperty("line.separator"));
netIfInfo.append("Name: ");
netIfInfo.append(netIf.getName());
netIfInfo.append(System.getProperty("line.separator"));
netIfInfo.append("isUp: ");
netIfInfo.append(netIf.isUp());
netIfInfo.append(System.getProperty("line.separator"));
netIfInfo.append("isLoopback: ");
netIfInfo.append(netIf.isLoopback());
netIfInfo.append(System.getProperty("line.separator"));
netIfInfo.append("isVirtual: ");
netIfInfo.append(netIf.isVirtual());
netIfInfo.append(System.getProperty("line.separator"));
netIfInfo.append("isPointToPoint: ");
netIfInfo.append(netIf.isPointToPoint());
netIfInfo.append(System.getProperty("line.separator"));
netIfInfo.append("HardwareAddress: ");
netIfInfo.append(byteArrayToHexString(netIf.getHardwareAddress()));
netIfInfo.append(System.getProperty("line.separator"));
netIfInfo.append("InetAddress Info: ");
netIfInfo.append(System.getProperty("line.separator"));
for(Enumeration e2 = netIf.getInetAddresses(); e2.hasMoreElements(); netIfInfo.append(System.getProperty("line.separator")))
{
InetAddress address = (InetAddress)e2.nextElement();
String ipAddress = address.getHostAddress();
netIfInfo.append("\t");
netIfInfo.append(ipAddress);
if(address != null)
{
netIfInfo.append("\t");
netIfInfo.append((new StringBuilder("isLoopBackAddress: ")).append(address.isLoopbackAddress()).toString());
}
}
netIfInfo.append("InterfaceAddress Info: ");
netIfInfo.append(System.getProperty("line.separator"));
for(Iterator iterator = netIf.getInterfaceAddresses().iterator(); iterator.hasNext(); netIfInfo.append(System.getProperty("line.separator")))
{
InterfaceAddress interfaceAddress = (InterfaceAddress)iterator.next();
String address = getIpAsString(interfaceAddress.getAddress());
netIfInfo.append("\t");
netIfInfo.append((new StringBuilder("getAddress: ")).append(address).toString());
}
netIfInfo.append("Available in Tool (netIf.isUp() && !(netIf.isLoopback() || netIf.isVirtual()): ");
netIfInfo.append(netIf.isUp() && !netIf.isLoopback() && !netIf.isVirtual());
netIfInfo.append(System.getProperty("line.separator"));
netIfInfo.append(System.getProperty("line.separator"));
}
System.out.println(netIfInfo);
printToFile(netIfInfo.toString());
}
catch(Exception e)
{
e.printStackTrace();
}
}
private static String byteArrayToHexString(byte b[])
{
String result = null;
if(b != null)
{
StringBuffer sb = new StringBuffer(b.length * 2);
for(int i = 0; i < b.length; i++)
{
int v = b[i] & 0xff;
if(v < 16)
sb.append('0');
sb.append(Integer.toHexString(v));
}
result = sb.toString().toUpperCase();
}
return result;
}
private static void printToFile(String content)
{
try
{
String fileName = (new StringBuilder("NetworkInterface_")).append((new Date()).getTime()).toString();
FileWriter outFile = new FileWriter(fileName);
PrintWriter out = new PrintWriter(outFile);
out.println(content);
out.close();
}
catch(IOException e)
{
e.printStackTrace();
}
}
private static String getIpAsString(InetAddress address)
{
int IPMASK = 255;
byte ipAddress[] = address.getAddress();
StringBuilder str = new StringBuilder();
for(int i = 0; i < ipAddress.length; i++)
{
if(i > 0)
str.append('.');
str.append(ipAddress[i] & 0xff);
}
return str.toString();
}
}
---------- END SOURCE ----------
A DESCRIPTION OF THE PROBLEM :
This defect seems to be closely related to "
If all three NICs are active and we retrieve the hardware addresses of the NICs using NetworkInterface.getHardwareAddress() the same address is returned for the two PCI NICs. This sounds exactly like the defect
More seriously for us NetworkInterface.isUp() also returns incorrect information. If we power down the switch that the first PCI NIC is connected to and call NetworkInterface.isUp() for both PCI NICs both are reported as being not up (we would expect only the first network interface to be marked as not up). If we power down only the switch that the second PCI NIC is connected to and call NetworkInterface.isUp() for both PCI NICs we see the expected result i.e. the first network interface is reported as up and the second is reported to be not up. Given this and the fact that the same hardware address is returned for both PCI NICs we are suspicious that the two PCI NICs are being confused internally in these methods and that the same information is being returned for both interfaces. Interstingly if we disable the first PCI NIC in windows the correct hardware address is now returned by NetworkInterface.getHardwareAddress() for the second PCI NIC (when both PIC NICs are active the hardware address of the first PCI NIC is returned).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
We have only seen this issue on PCs with the hardware set up described above (PC with three NICs (Network Interface cards), one of which is internal (Intel(R) 82567LM-3 Gigabit Network Connection) and two of which are PCI NICs (Realtek RTL8169/8110-Familie-PCI-Gigabit-Ethernet-NIC (NDIS 6.20) and D-Link DFE-530TX PCI-Fast-Ethernet-Adapter (rev.C))). NOTE: We have failed to reproduce it with other hardware setups e.g. PC with one internal NIC and two external USB ethernet adapters.
Steps [Duplicate Hardware Addresses]:
- Connect all NICs to live networks/powered up switches
- Run the source code pasted into this defect
Steps [sUp returning incorrect information]:
- Connect all NICs to live networks/powered up switches
- Power down the switch that the first PCI NIC is connected to
- Run the source code pasted into this defect
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Duplicate Hardware Addresses:
Correct hardware addresses returned for each network interface.
isUp returning incorrect information:
The isUp method should return a result of false for the network interface representing the first PCI NIC. The isUp method should return a result of true for the network interface representing the second PCI NIC.
ACTUAL -
Duplicate Hardware Addresses:
The same hardware address is returned for the network interfaces representing both PCI NICs. Note: this is the MAC address of the first PCI NIC. If we run ipconfig /all in windows we can see that both NICs have unqiue addresses.
isUp returning incorrect information:
The isUp method returns a result of false for the network interfaces representing both PCI NICs. The information for the second interface is inaccurate as this interface is actually up and functioning correctly.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.*;
import java.net.*;
import java.util.*;
public class Test
{
public static void main(String args[])
{
try
{
StringBuffer netIfInfo = new StringBuffer();
for(Enumeration e = NetworkInterface.getNetworkInterfaces(); e.hasMoreElements(); netIfInfo.append(System.getProperty("line.separator")))
{
NetworkInterface netIf = (NetworkInterface)e.nextElement();
netIfInfo.append("DisplayName: ");
netIfInfo.append(netIf.getDisplayName());
netIfInfo.append(System.getProperty("line.separator"));
netIfInfo.append("Name: ");
netIfInfo.append(netIf.getName());
netIfInfo.append(System.getProperty("line.separator"));
netIfInfo.append("isUp: ");
netIfInfo.append(netIf.isUp());
netIfInfo.append(System.getProperty("line.separator"));
netIfInfo.append("isLoopback: ");
netIfInfo.append(netIf.isLoopback());
netIfInfo.append(System.getProperty("line.separator"));
netIfInfo.append("isVirtual: ");
netIfInfo.append(netIf.isVirtual());
netIfInfo.append(System.getProperty("line.separator"));
netIfInfo.append("isPointToPoint: ");
netIfInfo.append(netIf.isPointToPoint());
netIfInfo.append(System.getProperty("line.separator"));
netIfInfo.append("HardwareAddress: ");
netIfInfo.append(byteArrayToHexString(netIf.getHardwareAddress()));
netIfInfo.append(System.getProperty("line.separator"));
netIfInfo.append("InetAddress Info: ");
netIfInfo.append(System.getProperty("line.separator"));
for(Enumeration e2 = netIf.getInetAddresses(); e2.hasMoreElements(); netIfInfo.append(System.getProperty("line.separator")))
{
InetAddress address = (InetAddress)e2.nextElement();
String ipAddress = address.getHostAddress();
netIfInfo.append("\t");
netIfInfo.append(ipAddress);
if(address != null)
{
netIfInfo.append("\t");
netIfInfo.append((new StringBuilder("isLoopBackAddress: ")).append(address.isLoopbackAddress()).toString());
}
}
netIfInfo.append("InterfaceAddress Info: ");
netIfInfo.append(System.getProperty("line.separator"));
for(Iterator iterator = netIf.getInterfaceAddresses().iterator(); iterator.hasNext(); netIfInfo.append(System.getProperty("line.separator")))
{
InterfaceAddress interfaceAddress = (InterfaceAddress)iterator.next();
String address = getIpAsString(interfaceAddress.getAddress());
netIfInfo.append("\t");
netIfInfo.append((new StringBuilder("getAddress: ")).append(address).toString());
}
netIfInfo.append("Available in Tool (netIf.isUp() && !(netIf.isLoopback() || netIf.isVirtual()): ");
netIfInfo.append(netIf.isUp() && !netIf.isLoopback() && !netIf.isVirtual());
netIfInfo.append(System.getProperty("line.separator"));
netIfInfo.append(System.getProperty("line.separator"));
}
System.out.println(netIfInfo);
printToFile(netIfInfo.toString());
}
catch(Exception e)
{
e.printStackTrace();
}
}
private static String byteArrayToHexString(byte b[])
{
String result = null;
if(b != null)
{
StringBuffer sb = new StringBuffer(b.length * 2);
for(int i = 0; i < b.length; i++)
{
int v = b[i] & 0xff;
if(v < 16)
sb.append('0');
sb.append(Integer.toHexString(v));
}
result = sb.toString().toUpperCase();
}
return result;
}
private static void printToFile(String content)
{
try
{
String fileName = (new StringBuilder("NetworkInterface_")).append((new Date()).getTime()).toString();
FileWriter outFile = new FileWriter(fileName);
PrintWriter out = new PrintWriter(outFile);
out.println(content);
out.close();
}
catch(IOException e)
{
e.printStackTrace();
}
}
private static String getIpAsString(InetAddress address)
{
int IPMASK = 255;
byte ipAddress[] = address.getAddress();
StringBuilder str = new StringBuilder();
for(int i = 0; i < ipAddress.length; i++)
{
if(i > 0)
str.append('.');
str.append(ipAddress[i] & 0xff);
}
return str.toString();
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-8021372 NetworkInterface.getNetworkInterfaces() returns duplicate hardware address
- Closed