RFR: JDK-8057556: JDP should better handle non-active interfaces
Yasumasa Suenaga
yasuenag at gmail.com
Mon Sep 8 15:40:08 UTC 2014
Hi Jaroslav,
I could not receive your email.
So I reply from another email.
> L103 Please, move "else" to the previous line
I will fix it.
> L96-100 Do we still need these lines? Isn't
> `channel.setOption(StandardSocketOptions.IP_MULTICAST_IF, interf);`
> enough to listen on the interface?
I think we should remove bind() call.
If we run multiple VM with same com.sun.management.jdp.source_addr value
and on same OS, we may encounter BindException in current implementation
as following:
----------
Error: Exception thrown by the agent : java.rmi.server.ExportException: Port already in use: 7091; nested exception is:
java.net.BindException: Address already in use
----------
If it should be treated as another issue, I will file it to JBS and
create a new patch.
I will upload new webrev for JDK-8057556 after this discussion.
Thanks,
Yasumasa
(2014/09/05 19:28), Yasumasa Suenaga wrote:
> Hi Peter,
>
> I fixed it and created new webrev.
> http://cr.openjdk.java.net/~ysuenaga/JDK-8057556/webrev.1/
>
> Could you review it again?
>
>
> Thanks,
>
> Yasumasa
>
>
> (2014/09/05 17:20), Peter Allwin wrote:
>> Looks like only the first Interface will be considered if no srcAddress is provided (succeeded will be false and we will throw to exit the while loop). Is this intended?
>>
>> Thanks!
>> /peter
>>
>>> On 4 sep 2014, at 17:59, Yasumasa Suenaga <yasuenag at gmail.com> wrote:
>>>
>>> Hi all,
>>>
>>> Thank you so much, Dmitry!
>>>
>>> I've created webrev for it.
>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8057556/webrev.0/
>>>
>>> Please review.
>>>
>>>
>>> Thanks,
>>>
>>> Yasumasa
>>>
>>>
>>> (2014/09/04 21:26), Dmitry Samersoff wrote:
>>>> Yasumasa,
>>>>
>>>> The CR number is JDK-8057556
>>>>
>>>> I'll care about it's integration.
>>>>
>>>> -Dmitry
>>>>
>>>>> On 2014-09-02 18:52, Yasumasa Suenaga wrote:
>>>>> Hi all,
>>>>>
>>>>> I'm trying to use JDP on my Fedora20 machine.
>>>>> My machine has two NICs and only one NIC is up.
>>>>>
>>>>> I passed system properties as below, however JDP broadcaster
>>>>> thread was not started:
>>>>>
>>>>> -Dcom.sun.management.jmxremote.port=7091
>>>>> -Dcom.sun.management.jmxremote.authenticate=false
>>>>> -Dcom.sun.management.jmxremote.ssl=false
>>>>> -Dcom.sun.management.jmxremote.autodiscovery=true
>>>>> -Dcom.sun.management.jdp.name=TEST
>>>>>
>>>>> I checked exceptions with jdb, SocketException was occurred in
>>>>> JDPControllerRunner#run(), and it was caused by another NIC
>>>>> is down.
>>>>>
>>>>> Currently, DiagramChannel which is used in JDPBroadcaster
>>>>> tries to send JDP packet through all "UP" NICs.
>>>>> However, NIC which is controlled by NetworkManager seems to
>>>>> be still "UP" when ifdown command is executed.
>>>>> (It seems to be removed IP address from NIC only.)
>>>>>
>>>>>
>>>>> This problem may be Fedora, however I think it should be
>>>>> improved in JDK.
>>>>> I've created a patch as below, and it works fine in my environment.
>>>>> (jdk9/dev/jdk)
>>>>>
>>>>> If this patch may be accepted, I will file this to JBS.
>>>>>
>>>>> --------------------
>>>>> diff -r 68a6bb51cb26 src/java.management/share/classes/sun/management/jdp/JdpBroadcaster.java
>>>>> --- a/src/java.management/share/classes/sun/management/jdp/JdpBroadcaster.java Mon Sep 01 13:33:28 2014 +0200
>>>>> +++ b/src/java.management/share/classes/sun/management/jdp/JdpBroadcaster.java Tue Sep 02 23:25:50 2014 +0900
>>>>> @@ -35,6 +35,7 @@
>>>>> import java.nio.ByteBuffer;
>>>>> import java.nio.channels.DatagramChannel;
>>>>> import java.nio.channels.UnsupportedAddressTypeException;
>>>>> +import java.util.Enumeration;
>>>>>
>>>>> /**
>>>>> * JdpBroadcaster is responsible for sending pre-built JDP packet across a Net
>>>>> @@ -79,6 +80,15 @@
>>>>> if (srcAddress != null) {
>>>>> // User requests particular interface to bind to
>>>>> NetworkInterface interf = NetworkInterface.getByInetAddress(srcAddress);
>>>>> +
>>>>> + if (interf == null) {
>>>>> + throw new JdpException("Unable to get network interface for " + srcAddress.toString());
>>>>> + }
>>>>> +
>>>>> + if (!interf.isUp() || !interf.supportsMulticast()) {
>>>>> + throw new JdpException(interf.getName() + " does not support multicast.");
>>>>> + }
>>>>> +
>>>>> try {
>>>>> channel.bind(new InetSocketAddress(srcAddress, 0));
>>>>> } catch (UnsupportedAddressTypeException ex) {
>>>>> @@ -86,6 +96,23 @@
>>>>> }
>>>>> channel.setOption(StandardSocketOptions.IP_MULTICAST_IF, interf);
>>>>> }
>>>>> + else {
>>>>> + Enumeration<NetworkInterface> nics = NetworkInterface.getNetworkInterfaces();
>>>>> + while (nics.hasMoreElements()) {
>>>>> + NetworkInterface nic = nics.nextElement();
>>>>> +
>>>>> + if (nic.isUp() && nic.supportsMulticast()) {
>>>>> + try {
>>>>> + channel.setOption(StandardSocketOptions.IP_MULTICAST_IF, nic);
>>>>> + } catch (IOException ex) {
>>>>> + System.err.println("WARNING: JDP broadcaster cannot use " + nic.getName() + ": " + ex.getMessage());
>>>>> + }
>>>>> + }
>>>>> +
>>>>> + }
>>>>> +
>>>>> + }
>>>>> +
>>>>> }
>>>>>
>>>>> /**
>>>>> --------------------
>>>>>
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Yasumasa
>>>>
>>>>
More information about the serviceability-dev
mailing list