8059309: network tests fail with "java.net.SocketException: Couldn't obtain phys addr" when run as "root"

The solaris specific code is changed to use the fallback mechanism if the DLPI interface returns an error indicating that the operation is unsupported. In addition, NetworkInterface::getHardwareAddress is changed to always return null for the loopback interface.

Reviewed-by: alanb
This commit is contained in:
Daniel Fuchs 2020-03-12 18:31:49 +00:00
parent 3ee99ca1d7
commit 58337b12f8
3 changed files with 96 additions and 2 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -523,6 +523,9 @@ public final class NetworkInterface {
}
}
}
if (isLoopback0(name, index)) {
return null;
}
for (InetAddress addr : addrs) {
if (addr instanceof Inet4Address) {
return getMacAddr0(((Inet4Address)addr).getAddress(), name, index);