RFR: 8354576: InetAddress.getLocalHost() on macos may return address of an interface which is not UP - leading to "Network is down" error
Volkan Yazici
vyazici at openjdk.org
Tue Apr 15 18:51:46 UTC 2025
On Tue, 15 Apr 2025 08:58:21 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:
> Can I please get a review of this change which proposes to address the issue noted in https://bugs.openjdk.org/browse/JDK-8354576?
>
> As noted in that issue, the current code in the `lookupAllHostAddr()` function of `Inet4AddressImpl.c` and `Inet6AddressImpl.c` has a macos specific implementation, where we call `getifaddrs()` and iterate over the returned addresses. In its current form this code doesn't check to see if the interface is UP or not. This can result in returing an address belonging to an interface which is not UP. That can cause subsequent usage of the address for networking operations to result in a "Network is down" error.
>
> The commit in this PR skips interfaces that are not UP. The change only impacts the result of `getLocalHost()` call and that too only on macos. Given the nature of this change no new regression test has been introduced. Existing tests in tier1, tier2 and tier3 continue to pass with this change.
@jaikiran, maybe asking the obvious but... We don't need this `IFF_UP` check for the below methods in `NetworkInterface.c`, right?
- `enumIPv4Interfaces`
- `enumIPv6Interfaces`
- `getMacAddress`
-------------
Marked as reviewed by vyazici (Author).
PR Review: https://git.openjdk.org/jdk/pull/24653#pullrequestreview-2769434020
More information about the net-dev
mailing list