RFR 7107883: getNetworkPrefixLength() does not return correct prefix length

Chris Hegarty chris.hegarty at oracle.com
Thu May 30 08:33:03 PDT 2013


On 05/30/2013 02:54 PM, Michael McMahon wrote:
> The change looks fine. Do you think it would be possible to make a
> test case by using the loopback interface, when it's available and
> when it doesn't have a broadcast address, which is probably a very common
> situation?

I think the IPv4 loopback address should always have a prefix of 8. So 
the test would look like :

http://cr.openjdk.java.net/~chegar/7107883/webrev.01/webrev/test/java/net/InterfaceAddress/NetworkPrefixLength.java.udiff.html

-Chris.

>
> Michael
>
> On 30/05/13 12:53, Chris Hegarty wrote:
>> The Unix native implementation that determines the network interface's
>> broadcast address and network prefix/subnet mask, incorrectly ties the
>> mask to the existence of a broadcast address. This should be changed
>> so that the network prefix/subnet mask, if available, is exposed
>> through the Java API, getNetworkPrefixLength, regardless of the
>> broadcast address.
>>
>> http://cr.openjdk.java.net/~chegar/7107883/webrev.00/webrev/
>>
>> Creating a reliable automatic regression test for this be problematic.
>> Also, there is already an existing test that verify that
>> getNetworkPrefixLength returns values within specified bounds.
>>
>> This issue can be easily seen with the loopback interface:
>>
>>   >: ifconfig lo
>>   lo        Link encap:Local Loopback
>>             inet addr:127.0.0.1  Mask:255.0.0.0
>>             inet6 addr: ::1/128 Scope:Host
>>             UP LOOPBACK RUNNING  MTU:16436  Metric:1
>>             RX packets:722 errors:0 dropped:0 overruns:0 frame:0
>>             TX packets:722 errors:0 dropped:0 overruns:0 carrier:0
>>             collisions:0 txqueuelen:0
>>             RX bytes:102346 (102.3 KB)  TX bytes:102346 (102.3 KB)
>>
>>   >: binaries/jdk1.7.0_07/bin/java Test lo
>>     <0:0:0:0:0:0:0:1%1>
>>     getBroadcast():null
>>     getNetworkPrefixLength():128
>>     <127.0.0.1>
>>     getBroadcast():null
>>     getNetworkPrefixLength():0
>>
>> -Chris.
>



More information about the net-dev mailing list