RFR: JDK-8057556: JDP should better handle non-active interfaces
Dmitry Samersoff
dmitry.samersoff at oracle.com
Mon Sep 8 15:48:02 UTC 2014
Jaroslav,
> L96-100 Do we still need these lines? Isn't
> `channel.setOption(StandardSocketOptions.IP_MULTICAST_IF, interf);`
> enough to listen on the interface?
Bind call is required to listen on particular address. So please, keep it.
-Dmitry
On 2014-09-08 14:12, Jaroslav Bachorik wrote:
> Hi Yasamusa,
>
> On 09/05/2014 12:28 PM, 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?
>
> Just a few nits ...
>
> L103 Please, move "else" to the previous line
> L96-100 Do we still need these lines? Isn't
> `channel.setOption(StandardSocketOptions.IP_MULTICAST_IF, interf);`
> enough to listen on the interface?
>
> -JB-
>
>>
>>
>> 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
>>>>>> +++что случилось с go contacts
>>>>>> 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
>>>>>
>>>>>
>
--
Dmitry Samersoff
Oracle Java development team, Saint Petersburg, Russia
* I would love to change the world, but they won't give me the sources.
More information about the serviceability-dev
mailing list