Hi Arthur, Chris,
   just a note in passing, as you are well set on the changes, which is all  
good -- needs must, as they say.

The current implementation is an emulation of the gethostbyname and 
gethostbyaddr lookup on /etc/hosts.
The reverse lookup  issue is also solved by adding an additional entry in the 
hosts file
0:0:0:0:0:0:0:1 ip6-localhost ip6-loopback. Your reverse lookup will pass.

$ /cygdrive/c/Development/jdk-installs/jdk-12/bin/java 
InternalNameServiceWithHostsFileTest
############################  InetAddress == ip6-localhost/0:0:0:0:0:0:0:1​
retrieved address == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] equal to 
expected address == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]​
testReverseLookup: host addr ::1 : expected host name ip6-localhost​
testReverseLookup: host addr 0:0:0:0:0:0:0:1 : expected host name ip6-localhost​
testReverseLookup: host addr 0000:0000:0000:0000:0000:0000:0000:0001 : expected 
host name ip6-localhost​

That was the design -- the hosts file would contain whatever set of mapping are 
required for a particular context.
So the string comparison was sufficient.

IF your reverse lookup tests are run against the PlatformFormNameService,
which is the fall through to the native OS calls gethostbyname, getaddrinfo etc.
then you get the same set of failure afaik.

on windows using jdk12 test output shown below
so you could say there is some degree of consistent behaviour between the two 
services!!

regards
Mark



msheppard@MARKS-LAPTOP /cygdrive/c/Users/msheppard/eclipse-workspace/JDK-Tests
$ /cygdrive/c/Development/jdk-installs/jdk-12/bin/java  
-Djava.net.preferIPv6Addresses=true PlatformNameServiceTest​
############################  InetAddress == localhost/0:0:0:0:0:0:0:1​
retrieved address == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] equal to 
expected address == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]​
testReverseLookup: host addr ::1 : expected host name localhost​
Exception in thread "main" java.lang.RuntimeException: reverse lookup of "::1" 
is "0:0:0:0:0:0:0:1", should be "localhost"​
​
        at 
PlatformNameServiceTest.testReverseLookup(PlatformNameServiceTest.java:64)​
        at PlatformNameServiceTest.main(PlatformNameServiceTest.java:25)​
​
msheppard@MARKS-LAPTOP /cygdrive/c/Users/msheppard/eclipse-workspace/JDK-Tests​
$ /cygdrive/c/Development/jdk-installs/jdk-12/bin/java  
-Djava.net.preferIPv6Addresses=true PlatformNameServiceTest​
############################  InetAddress == localhost/0:0:0:0:0:0:0:1​
retrieved address == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] equal to 
expected address == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]​
testReverseLookup: host addr 0:0:0:0:0:0:0:1 : expected host name localhost​
Exception in thread "main" java.lang.RuntimeException: reverse lookup of 
"0:0:0:0:0:0:0:1" is "0:0:0:0:0:0:0:1", should be "localhost"​
​
        at 
PlatformNameServiceTest.testReverseLookup(PlatformNameServiceTest.java:64)​
        at PlatformNameServiceTest.main(PlatformNameServiceTest.java:26)​
​
msheppard@MARKS-LAPTOP /cygdrive/c/Users/msheppard/eclipse-workspace/JDK-Tests​
$ /cygdrive/c/Development/jdk-installs/jdk-12/bin/java  
-Djava.net.preferIPv6Addresses=true PlatformNameServiceTest​
############################  InetAddress == localhost/0:0:0:0:0:0:0:1​
retrieved address == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] equal to 
expected address == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]​
testReverseLookup: host addr 0000:0000:0000:0000:0000:0000:0000:0001 : expected 
host name localhost​
Exception in thread "main" java.lang.RuntimeException: reverse lookup of 
"0000:0000:0000:0000:0000:0000:0000:0001" is "0:0:0:0:0:0:0:1", should be 
"localhost"​
​
        at 
PlatformNameServiceTest.testReverseLookup(PlatformNameServiceTest.java:64)​
        at PlatformNameServiceTest.main(PlatformNameServiceTest.java:27)​


________________________________
From: net-dev <net-dev-boun...@openjdk.java.net> on behalf of Arthur Eubanks 
<aeuba...@google.com>
Sent: Monday 13 May 2019 17:59
To: Chris Hegarty
Cc: OpenJDK Network Dev list
Subject: Re: [ipv6] RFR: 8223737: HostsFileNameService doesn't handle IPv6 
literal addresses correctly



From: Chris Hegarty <chris.hega...@oracle.com<mailto:chris.hega...@oracle.com>>
Date: Mon, May 13, 2019 at 9:33 AM
To: Arthur Eubanks, OpenJDK Network Dev list

Arthur,

On 11/05/2019 01:17, Arthur Eubanks wrote:
> Bug: https://bugs.openjdk.java.net/browse/JDK-8223737
> Webrev: http://cr.openjdk.java.net/~aeubanks/8223737/webrev.00/index.html
>
> HostsFileNameService doesn't handle IPv6 literal addresses correctly.
> For example, ::1 and 0:0:0:0:0:0:0:1 should yield the same output.
>
> Rather than comparing address strings, compare the address byte arrays.

Comparison of byte arrays is much better. The changes look good.

Trivially, can I ask you to please include a number of other reverse
lookup's to fill out the test a little. Here's what I came up with:

     testReverseLookup("10.2.3.4", "testHost.testDomain");

     // ::1 and 0:0:0:0:0:0:0:1 should map to ip6-localhost
     testReverseLookup("::1", "ip6-localhost");
     testReverseLookup("0:0:0:0:0:0:0:1", "ip6-localhost");

testReverseLookup("0000:0000:0000:0000:0000:0000:0000:0001","ip6-localhost");

     testReverseLookup("fe00::0", "ip6-localnet");
     testReverseLookup("fe00:0:0:0:0:0:0:0", "ip6-localnet");
     testReverseLookup("fe00:0000:0000:0000:0000:0000:0000:0000",
"ip6-localnet");

     testReverseLookup("fe80::1", "link-local-host");
     testReverseLookup("fe80:000:0:00:0:000:00:1", "link-local-host");
     testReverseLookup("fe80:0000:0000:0000:0000:0000:0000:0001",
"link-local-host");

Thanks,
-Chris.
Added the extra reverse lookups.

I also noticed that the test is catching UnknownHostException and not 
rethrowing it, so I removed the try/catch.

Updated webrev: 
http://cr.openjdk.java.net/~aeubanks/8223737/webrev.01/index.html

Reply via email to