RFR 8168840: InetAddress.getByName() throws java.net.UnknownHostException no such interface when used with virtual interfaces on Solaris
Vyom Tewari
vyom.tewari at oracle.com
Wed Dec 21 13:41:02 UTC 2016
Hi Chris,
If you create the Inet6Address using the following constructor
"Inet6Address (String , byte[], String )" then it will call the
following private method " initstr (hostName, addr, ifname);" and it you
see the implementation of this method then you will see the below code.
#######################################
try {
NetworkInterface nif = NetworkInterface.getByName (ifname);
if (nif == null) {
throw new UnknownHostException ("no such interface " +
ifname);
}
initif (hostName, addr, nif);
########################################
So this is the connection between Inet6Address and
NetworkInterface.getByName but same is not the case for ipv4 address.
As we added the scope name recently(not very recent but after
jdk1.7.0_79) so if you pass the virtual sub interface interface
like(2001:7a8:b0cd:1:0:0:0:17%net0:1) then it will fail to get the sub
interface and UHE will be thrown.
to handle this i did the code change.
Thanks,
Vyom
On 12/21/2016 5:04 PM, Chris Hegarty wrote:
> Hi Vyom,
>
> Sorry, I'm missing the connection between Inet6Address and
> NetworkInterface.getByName, how do these interact?
>
> -Chris.
>
> On 21/12/16 10:20, Vyom Tewari wrote:
>> incorporated the
>> comments(http://cr.openjdk.java.net/~vtewari/8168840/webrev0.2/index.html
>> <http://cr.openjdk.java.net/%7Evtewari/8168840/webrev0.2/index.html>).
>>
>>
>> Thanks,
>>
>> Vyom
>>
>>
>> On Wednesday 21 December 2016 02:58 PM, Langer, Christoph wrote:
>>> Hi Vyom,
>>>
>>> looks good, thanks for the update.
>>>
>>> Minor formatting:
>>> - Add a blank line between line 258/259 and 268/269 in the new file
>>> version.
>>> - line 259 //search the child list - add a space between "//" and
>>> "search..."
>>>
>>> Disclaimer: I'm not an official reviewer.
>>>
>>> Best regards
>>> Christoph
>>>
>>>> -----Original Message-----
>>>> From: net-dev [mailto:net-dev-bounces at openjdk.java.net] On Behalf Of
>>>> Vyom
>>>> Tewari
>>>> Sent: Mittwoch, 21. Dezember 2016 09:51
>>>> Cc: net-dev <net-dev at openjdk.java.net>
>>>> Subject: Re: RFR 8168840: InetAddress.getByName() throws
>>>> java.net.UnknownHostException no such interface when used with virtual
>>>> interfaces on Solaris
>>>>
>>>> Hi All,
>>>>
>>>> Please find the latest
>>>> webrev(http://cr.openjdk.java.net/~vtewari/8168840/webrev0.1/index.html
>>>>
>>>> <http://cr.openjdk.java.net/%7Evtewari/8168840/webrev0.1/index.html>).
>>>>
>>>> Thanks,
>>>>
>>>> Vyom
>>>>
>>>>
>>>> On Tuesday 13 December 2016 01:38 PM, Langer, Christoph wrote:
>>>>> Hi Vyom,
>>>>>
>>>>> thanks for looking at this. Overall your fix and test look good to
>>>>> me.
>>>>>
>>>>> The coding to do the parent search and if required a child search in
>>>> Java_java_net_NetworkInterface_getByName0 could be done a bit more
>>>> straightforward, e.g. like this:
>>>>> // search the list of interfaces by name
>>>>> // for virtual interfaces we need to find the parent first
>>>>> colonp = strchr(name_utf, ':');
>>>>> if (colonp == NULL) {
>>>>> searchName = name_utf;
>>>>> } else {
>>>>> jio_snprintf(pname, IFNAMESIZE, "%.*s", colonp - name_utf);
>>>>> searchName = pname;
>>>>> }
>>>>> curr = ifs;
>>>>> while (curr != NULL) {
>>>>> if (strcmp(searchName, curr->name) == 0) {
>>>>> break;
>>>>> }
>>>>> curr = curr->next;
>>>>> }
>>>>>
>>>>> // search the child list
>>>>> if (curr != NULL && colonp != NULL) {
>>>>> curr = curr->childs;
>>>>> while (curr != NULL) {
>>>>> if (strcmp(name_utf, curr->name) == 0) {
>>>>> break;
>>>>> }
>>>>> curr = curr->next;
>>>>> }
>>>>> }
>>>>>
>>>>> Best regards
>>>>> Christoph
>>>>>
>>>>>> -----Original Message-----
>>>>>> From: net-dev [mailto:net-dev-bounces at openjdk.java.net] On Behalf Of
>>>> Vyom
>>>>>> Tewari
>>>>>> Sent: Dienstag, 13. Dezember 2016 04:47
>>>>>> To: net-dev <net-dev at openjdk.java.net>
>>>>>> Subject: RFR 8168840: InetAddress.getByName() throws
>>>>>> java.net.UnknownHostException no such interface when used with
>>>>>> virtual
>>>>>> interfaces on Solaris
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> Please review the code changes for below issue.
>>>>>>
>>>>>> BugId : https://bugs.openjdk.java.net/browse/JDK-8168840
>>>>>>
>>>>>> webrev :
>>>>>> http://cr.openjdk.java.net/~vtewari/8168840/webrev0.0/index.html
>>>>>> <http://cr.openjdk.java.net/%7Evtewari/8168840/webrev0.0/index.html>
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> Vyom
>>
More information about the net-dev
mailing list