RFR 8042581: Intermittent failure in java/net/DatagramSocket/InheritHandle.java
Hi all, please review the fix for 8042581. This failure was only observed on Windows, so it is most possibly because the socket.close() on Windows is processed asynchronously within the Windows API layer (TCP machine) . Add 5 times of tries to the test if BindException is encountered on Windows. Webrev: http://cr.openjdk.java.net/~xiaofeya/8042581/webrev.00/ Bug: https://bugs.openjdk.java.net/browse/JDK-8042581 Thanks! -Felix
Re: RFR 8042581: Intermittent failure in java/net/DatagramSocket/InheritHandle.java
Looks ok Felix. You could put the construction of the new DatagramSocket in a try-with-resources, so it will be closed always, even if the test fails. -Chris > On 29 Dec 2014, at 10:04, FELIX YANG wrote: > > Hi all, > please review the fix for 8042581. This failure was only observed on > Windows, so it is most possibly because the socket.close() on Windows is > processed asynchronously within the Windows API layer (TCP machine) . Add 5 > times of tries to the test if BindException is encountered on Windows. > > Webrev: > http://cr.openjdk.java.net/~xiaofeya/8042581/webrev.00/ > Bug: > https://bugs.openjdk.java.net/browse/JDK-8042581 > > Thanks! > -Felix > >
Re: RFR 8042581: Intermittent failure in java/net/DatagramSocket/InheritHandle.java
On 29/12/2014 15:46, Chris Hegarty wrote: Looks ok Felix. You could put the construction of the new DatagramSocket in a try-with-resources, so it will be closed always, even if the test fails. -Chris I agree with Chris' comment. One other thing is that testing if e instanceof BindException is not necessary as e will always be a BindException. -Alan
Re: java.net.NetworkInterfaces and Linux with multiple addresses on single interface
On 27 Dec 2014, at 15:53, Doychin Bondzhev wrote: > This is a copy of my email that I sent earlier to core-libs-dev. > --- > > Hi, > > I want to report for a problem that I see when I have more then one IP > addresses assigned to same interface. > > Here is an output from ip addr command on my linux box: > > 1: lo: mtu 65536 qdisc noqueue state UNKNOWN >link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 >inet 127.0.0.1/8 scope host lo >inet6 ::1/128 scope host > valid_lft forever preferred_lft forever > 2: eth0: mtu 1500 qdisc pfifo_fast state UP > qlen 1000 >link/ether 08:00:27:fc:25:9f brd ff:ff:ff:ff:ff:ff >inet 192.168.1.4/24 brd 192.168.1.255 scope global eth0 >inet6 fe80::a00:27ff:fefc:259f/64 scope link > valid_lft forever preferred_lft forever > 3: eth1: mtu 1500 qdisc pfifo_fast state UP > qlen 1000 >link/ether 08:00:27:b1:42:d0 brd ff:ff:ff:ff:ff:ff >inet 192.168.240.1/24 brd 192.168.240.255 scope global eth1 >inet 192.168.241.1/24 brd 192.168.241.255 scope global eth1 >inet 192.168.239.1/24 brd 192.168.239.255 scope global eth1 >inet 10.0.0.1/22 brd 10.0.3.255 scope global eth1 >inet6 fe80::a00:27ff:feb1:42d0/64 scope link > valid_lft forever preferred_lft forever > > And this is the output of a test java program that uses NetworkInterfaces > class to display all IP addresses and their corresponding settings: > > eth1:10.0.0.1/24 broadcast:192.168.240.255 > eth1:192.168.239.1/24 broadcast:192.168.240.255 > eth1:192.168.241.1/24 broadcast:192.168.240.255 > eth1:192.168.240.1/24 broadcast:192.168.240.255 > eth0:192.168.1.4/24 broadcast:192.168.1.255 > lo:127.0.0.1/8 > > As you can see there are 2 problems visible here: > > 1. On all eth1 lines same broadcast is displayed. The value is the broadcast > of the first IP address set on that interface > > 2. All addresses are with prefix length of 24 which is not correct. We have > 10.0.0.1/22 in the "ip addr" output. > > So the problem is in NetworkInterfaces native code for Unix. > > For IPv4 addresses that code uses 2 functions (getBordacast and getSubnet and > these 2 functions use ioctl with SIOCGIFNETMASK and SIOCGIFBRDADDR. Both of > these requests receive as parameter interface name. They are not prepared to > work in environments where you can specify more then one IP on the same > interface without using virtual interfaces. > > So using virutal interfaces is the only workaround of this problem for the > moment. > > I propose another method of reading ip address information for interfaces > that will use getifaddrs/freeifaddrs. > > getifaddrs knows how to handle this case properly. It returns all the > necessary information in an array of "struct ifaddrs" > > Any toughs on this proposition? This sounds reasonable. It is an implementation only issue, right? No impact on the public NetworkInterface API. -Chris. > -- > Doychin Bondzhev > dSoft-Bulgaria Ltd. > PowerPro - billing & provisioning solution for Service providers > PowerStor - Warehouse & POS > http://www.dsoft-bg.com/ > Mobile: +359888243116 >
Re: java.net.NetworkInterfaces and Linux with multiple addresses on single interface
Yes, It is only a matter of implementation in the native code. There will be no changes in the public API. To be honest I don't have much experience in C development and I'm not sure the function that I'm offering is supported on all UNIX platforms that OpenJDK targets. I can test only on Linux. On 29.12.2014 г. 22:21 ч., Chris Hegarty wrote: On 27 Dec 2014, at 15:53, Doychin Bondzhev wrote: This is a copy of my email that I sent earlier to core-libs-dev. --- Hi, I want to report for a problem that I see when I have more then one IP addresses assigned to same interface. Here is an output from ip addr command on my linux box: 1: lo: mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:fc:25:9f brd ff:ff:ff:ff:ff:ff inet 192.168.1.4/24 brd 192.168.1.255 scope global eth0 inet6 fe80::a00:27ff:fefc:259f/64 scope link valid_lft forever preferred_lft forever 3: eth1: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 08:00:27:b1:42:d0 brd ff:ff:ff:ff:ff:ff inet 192.168.240.1/24 brd 192.168.240.255 scope global eth1 inet 192.168.241.1/24 brd 192.168.241.255 scope global eth1 inet 192.168.239.1/24 brd 192.168.239.255 scope global eth1 inet 10.0.0.1/22 brd 10.0.3.255 scope global eth1 inet6 fe80::a00:27ff:feb1:42d0/64 scope link valid_lft forever preferred_lft forever And this is the output of a test java program that uses NetworkInterfaces class to display all IP addresses and their corresponding settings: eth1:10.0.0.1/24 broadcast:192.168.240.255 eth1:192.168.239.1/24 broadcast:192.168.240.255 eth1:192.168.241.1/24 broadcast:192.168.240.255 eth1:192.168.240.1/24 broadcast:192.168.240.255 eth0:192.168.1.4/24 broadcast:192.168.1.255 lo:127.0.0.1/8 As you can see there are 2 problems visible here: 1. On all eth1 lines same broadcast is displayed. The value is the broadcast of the first IP address set on that interface 2. All addresses are with prefix length of 24 which is not correct. We have 10.0.0.1/22 in the "ip addr" output. So the problem is in NetworkInterfaces native code for Unix. For IPv4 addresses that code uses 2 functions (getBordacast and getSubnet and these 2 functions use ioctl with SIOCGIFNETMASK and SIOCGIFBRDADDR. Both of these requests receive as parameter interface name. They are not prepared to work in environments where you can specify more then one IP on the same interface without using virtual interfaces. So using virutal interfaces is the only workaround of this problem for the moment. I propose another method of reading ip address information for interfaces that will use getifaddrs/freeifaddrs. getifaddrs knows how to handle this case properly. It returns all the necessary information in an array of "struct ifaddrs" Any toughs on this proposition? This sounds reasonable. It is an implementation only issue, right? No impact on the public NetworkInterface API. -Chris. -- Doychin Bondzhev dSoft-Bulgaria Ltd. PowerPro - billing & provisioning solution for Service providers PowerStor - Warehouse & POS http://www.dsoft-bg.com/ Mobile: +359888243116 -- Doychin Bondzhev dSoft-Bulgaria Ltd. PowerPro - billing & provisioning solution for Service providers PowerStor - Warehouse & POS http://www.dsoft-bg.com/ Mobile: +359888243116 <> smime.p7s Description: S/MIME Cryptographic Signature
Re: RFR 8042581: Intermittent failure in java/net/DatagramSocket/InheritHandle.java
Thanks for looking at this, Alan and Chris. Please check the updated webrev: http://cr.openjdk.java.net/~xiaofeya/8042581/webrev.01/ -Felix On 12/29/2014 11:51 PM, Alan Bateman wrote: On 29/12/2014 15:46, Chris Hegarty wrote: Looks ok Felix. You could put the construction of the new DatagramSocket in a try-with-resources, so it will be closed always, even if the test fails. -Chris I agree with Chris' comment. One other thing is that testing if e instanceof BindException is not necessary as e will always be a BindException. -Alan