On Thu, 16 Feb 2023 20:22:17 GMT, Rich DiCroce <d...@openjdk.org> wrote:
>> ok so here goes: your patch changes the order in which the interfaces are >> returned; the original code returned them in order of increasing indexes, >> the new code appears to sort interfaces by LUID. >> The failing test uses the first interface for which supportsMulticast >> returns true. I get `supportsMulticast` = `true` on all interfaces even with >> the old code. >> >> The interface that happened to be on the first position of my list was: >> >> 67 name:ethernet_0 (Hyper-V Virtual Switch Extension Adapter-Hyper-V Virtual >> Switch Extension Filter-0000) >> ifup: true isP2P: false isLoopback: false macAddr: null MTU: 1500 >> supportsMulticast: true >> >> it has no associated IP addresses, and is not usable with IP_MULTICAST_IF. >> (Also it's a filter interface, which means that the old code returned ifUp = >> false). >> >> Well that would explain how `supportsMulticast` is meant to be used; now we >> just need to figure out which interfaces can be used for multicasting. > > Note that the new code doesn't attempt to sort anything. If it happens to be > sorted by LUID, that's the underlying API at work. The MS docs don't say > anything about ordering, so this is probably an implementation detail and I > wouldn't assume it will always be true. > > I'm still running jdk_net, but I can already see that test failing on my > machine. Though it has a different error: > > > java.io.IOException: Network interface not configured for IPv4 > at > java.base/sun.nio.ch.DatagramChannelImpl.setOption(DatagramChannelImpl.java:389) > at > java.base/sun.nio.ch.DatagramSocketAdaptor.setOption(DatagramSocketAdaptor.java:431) > at java.base/java.net.DatagramSocket.setOption(DatagramSocket.java:1207) > at OptionsTest.test(OptionsTest.java:155) > at OptionsTest.doMulticastSocketTests(OptionsTest.java:235) > at OptionsTest.main(OptionsTest.java:337) > at > java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) > at java.base/java.lang.reflect.Method.invoke(Method.java:578) > at > com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:125) > at java.base/java.lang.Thread.run(Thread.java:1623) > > > So I think when picking the interface to use for the test, we need to also > check that isUp = true and that the list of IP addresses contains at least > one IPv4 address. Though it's more complicated than that. Some machines may have both IPv6 and IPv4, some machine may only have IPv4, and some machine may only have IPv6. I haven't looked at the test yet, but picking up the right interface on the various platforms has always been an issue for our tests. ------------- PR: https://git.openjdk.org/jdk/pull/12593