NetworkInterface problem (Re: [kaffe] freebsd 5.3 failed regression)

Ito Kazumitsu kaz at maczuka.gcd.org
Sun Apr 24 07:07:48 PDT 2005


> From: Riccardo <zuse at libero.it>
> Subject: [kaffe] freebsd 5.3 failed regression
> Date: Fri, 22 Apr 2005 11:38:06 +0000 (UTC)
> 
> > on 18 april, freebsd 5.3 passed all tests, today it fails one:
> 
> In my case, also on FreeBSD 5.3-RELEASE, compilation failes
> before going to the regression test.

Now Kaffe's CVS version compiles fine, and I am experiencing
the same problem reported by Riccardo.

The problem seems to appear when a network interface has more than
one addresses.

Attached is a program copied from test/regression/NetworkInterfaceTest.java.
According to this,

  (1) NetworkInterface returned by NetworkInterface.getNetworkInterfaces()
      contains all addresses of that interface.

  (2) NetworkInterface returned by NetworkInterface.getByName(name) or
      NetworkInterface.getByInetAddress(addr) contains only one of the
      addresses of that interface.

Test program:
import java.util.Enumeration;

import java.net.InetAddress;
import java.net.SocketException;
import java.net.NetworkInterface;

public class TestNetworkInterface
{

    private static void showNetworkInterface(NetworkInterface ni)
    {
	System.out.println("  showNetworkInterface: " + ni + "{");
	System.out.println("  Name: " + ni.getName());
	System.out.println("  Display Name: "
			       + ni.getDisplayName());
	Enumeration ips = ni.getInetAddresses();
	while( ips.hasMoreElements() )
	{
	    InetAddress ia;
	    ia = (InetAddress)ips.nextElement();
	    System.out.println("  Address: " + ia);
	}
	System.out.println("  }");
    }

    
    public static void main(String args[])
    {
	try
	{
	    Enumeration enum;
	    int lpc;
	    
	    enum = NetworkInterface.getNetworkInterfaces();
	    for( lpc = 0; enum.hasMoreElements(); lpc++ )
	    {
		NetworkInterface ni, ni2;
		Enumeration ips;
		
		ni = (NetworkInterface)enum.nextElement();
		System.out.println("Detected interface #" + lpc);
		showNetworkInterface(ni);

		ni2 = NetworkInterface.getByName(ni.getName());
                System.out.println("getByName(" + ni.getName() + ")");
		showNetworkInterface(ni2);

		ips = ni.getInetAddresses();
		while( ips.hasMoreElements() )
		{
		    InetAddress ia;

		    ia = (InetAddress)ips.nextElement();
		    System.out.println("getByInetAddress(" + ia + ")");
		    ni2 = NetworkInterface.getByInetAddress(ia);
		    showNetworkInterface(ni2);
		}
	    }
	}
	catch(SocketException e)
	{
	    e.printStackTrace();
	    System.exit(77);
	}
	catch(kaffe.util.NotImplemented e)
	{
	    e.printStackTrace();
	    System.exit(77);
	}
    }
}

Result:
Detected interface #0
  showNetworkInterface: name: lo0 (lo0) addresses:
127.0.0.1/127.0.0.1;
::1/0:0:0:0:0:0:0:1;
fe80:3::1/fe80:3:0:0:0:0:0:1;
{
  Name: lo0
  Display Name: lo0
  Address: 127.0.0.1/127.0.0.1
  Address: ::1/0:0:0:0:0:0:0:1
  Address: fe80:3::1/fe80:3:0:0:0:0:0:1
  }
getByName(lo0)
  showNetworkInterface: name: lo0 (lo0) addresses:
127.0.0.1/127.0.0.1;
{
  Name: lo0
  Display Name: lo0
  Address: 127.0.0.1/127.0.0.1
  }
getByInetAddress(127.0.0.1/127.0.0.1)
  showNetworkInterface: name: lo0 (lo0) addresses:
127.0.0.1/127.0.0.1;
{
  Name: lo0
  Display Name: lo0
  Address: 127.0.0.1/127.0.0.1
  }
getByInetAddress(::1/0:0:0:0:0:0:0:1)
  showNetworkInterface: name: lo0 (lo0) addresses:
::1/0:0:0:0:0:0:0:1;
{
  Name: lo0
  Display Name: lo0
  Address: ::1/0:0:0:0:0:0:0:1
  }
getByInetAddress(fe80:3::1/fe80:3:0:0:0:0:0:1)
  showNetworkInterface: name: lo0 (lo0) addresses:
fe80:3::1/fe80:3:0:0:0:0:0:1;
{
  Name: lo0
  Display Name: lo0
  Address: fe80:3::1/fe80:3:0:0:0:0:0:1
  }
Detected interface #1
  showNetworkInterface: name: fxp0 (fxp0) addresses:
192.168.0.3/192.168.0.3;
fe80:1::202:55ff:feec:ab05/fe80:1:0:0:202:55ff:feec:ab05;
{
  Name: fxp0
  Display Name: fxp0
  Address: 192.168.0.3/192.168.0.3
  Address: fe80:1::202:55ff:feec:ab05/fe80:1:0:0:202:55ff:feec:ab05
  }
getByName(fxp0)
  showNetworkInterface: name: fxp0 (fxp0) addresses:
192.168.0.3/192.168.0.3;
{
  Name: fxp0
  Display Name: fxp0
  Address: 192.168.0.3/192.168.0.3
  }
getByInetAddress(192.168.0.3/192.168.0.3)
  showNetworkInterface: name: fxp0 (fxp0) addresses:
192.168.0.3/192.168.0.3;
{
  Name: fxp0
  Display Name: fxp0
  Address: 192.168.0.3/192.168.0.3
  }
getByInetAddress(fe80:1::202:55ff:feec:ab05/fe80:1:0:0:202:55ff:feec:ab05)
  showNetworkInterface: name: fxp0 (fxp0) addresses:
fe80:1::202:55ff:feec:ab05/fe80:1:0:0:202:55ff:feec:ab05;
{
  Name: fxp0
  Display Name: fxp0
  Address: fe80:1::202:55ff:feec:ab05/fe80:1:0:0:202:55ff:feec:ab05
  }




More information about the kaffe mailing list