[jboss-jira] [JBoss JIRA] Commented: (JGRP-956) Binding to mcast address in UDP.java is not working on Linux with IPv6

Richard Achmatowicz (JIRA) jira-events at lists.jboss.org
Thu Jul 16 12:14:29 EDT 2009


    [ https://jira.jboss.org/jira/browse/JGRP-956?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12476578#action_12476578 ] 

Richard Achmatowicz commented on JGRP-956:
------------------------------------------

Well, it turns out that it is possible to bind to IPv6 multicast addresses, that it does not lead to crosstalk when we do so, and that this jira issue was the result of incorrect coding of the Java system property java.net.preferIPv6Stack.

I modified Brian's promiscuous.jar so that it took an additional boolean parameter: true -> bind to multicast socket; false -> bind to multicast port only.

So, in the case of IPv4 addresses, we can bind to port only:
$ java -jar promiscuoustraffic.jar 192.168.2.12 192.168.2.12 230.10.11.12 230.10.11.13 64000 1 false
setting up sender socket with address /192.168.2.12
setting up good receiver socket with address /230.10.11.12
binding mcast socket to port:64000
setting up bad receiver socket with address /230.10.11.13
binding mcast socket to port:64000
Listening on address /230.10.11.12
Listening on address /230.10.11.13
Sending 'Hello' on /230.10.11.12:64000
/230.10.11.13:64000 -- Received Hello
/230.10.11.12:64000 -- Received Hello
Bad news. Detected the Promiscuous Traffic problem. Received Hello on undesired address /230.10.11.13

Or we can bind to multicast address:
$ java -Djava.net.preferIPv4Stack=true -jar promiscuoustraffic.jar 192.168.2.12 192.168.2.12 230.10.11.12 230.10.11.13 64000 1 true
setting up sender socket with address /192.168.2.12
setting up good receiver socket with address /230.10.11.12
binding mcast socket to address:/230.10.11.12:64000
setting up bad receiver socket with address /230.10.11.13
binding mcast socket to address:/230.10.11.13:64000
Listening on address /230.10.11.12
Listening on address /230.10.11.13
Sending 'Hello' on /230.10.11.12:64000
/230.10.11.12:64000 -- Received Hello
Good news. Did not detect the Promiscuous Traffic problem.


We can now show that promiscuous traffic does not occur when binding to multicast address on Fedora 8 with JDK 5:

$ java -jar promiscuoustraffic.jar 3ffe:ffff:100:f101::1 3ffe:ffff:100:f101::1 ff0e::1:2:2 ff0e::1:2:3 64000 1 true
setting up sender socket with address /3ffe:ffff:100:f101:0:0:0:1
setting up good receiver socket with address /ff0e:0:0:0:0:1:2:2
binding mcast socket to address:/ff0e:0:0:0:0:1:2:2:64000
setting up bad receiver socket with address /ff0e:0:0:0:0:1:2:3
binding mcast socket to address:/ff0e:0:0:0:0:1:2:3:64000
Listening on address /ff0e:0:0:0:0:1:2:2
Listening on address /ff0e:0:0:0:0:1:2:3
Sending 'Hello' on /ff0e:0:0:0:0:1:2:2:64000
/ff0e:0:0:0:0:1:2:2:64000 -- Received Hello
Good news. Did not detect the Promiscuous Traffic problem.

and that if we prefer the IPv4 stack with an IPv6 mcast address, we get the exception above:

$ java -Djava.net.preferIPv4Stack=true -jar promiscuoustraffic.jar 3ffe:ffff:100:f101::1 3ffe:ffff:100:f101::1 ff0e::1:2:3 ff0e::1:2:4 64000 0
setting up sender socket with address /3ffe:ffff:100:f101:0:0:0:1
setting up good receiver socket with address /ff0e:0:0:0:0:1:2:3
binding mcast socket to port:64000
java.net.SocketException: Invalid argument
        at java.net.PlainDatagramSocketImpl.join(Native Method)
        at java.net.PlainDatagramSocketImpl.join(PlainDatagramSocketImpl.java:172)
        at java.net.MulticastSocket.joinGroup(MulticastSocket.java:276)
        at org.jboss.test.cluster.test.PromiscuousTrafficTester$MulticastReceiver.<init>(PromiscuousTrafficTester.java:222)
        at org.jboss.test.cluster.test.PromiscuousTrafficTester.setUpSockets(PromiscuousTrafficTester.java:144)
        at org.jboss.test.cluster.test.PromiscuousTrafficTester.<init>(PromiscuousTrafficTester.java:67)
        at org.jboss.test.cluster.test.PromiscuousTrafficTester.main(PromiscuousTrafficTester.java:191)

Promiscuous traffic does occur if we bind to multicast port only:
$ java -jar promiscuoustraffic.jar 3ffe:ffff:100:f101::1 3ffe:ffff:100:f101::1 ff0e::1:2:3 ff0e::1:2:4 64000 0setting up sender socket with address /3ffe:ffff:100:f101:0:0:0:1
setting up good receiver socket with address /ff0e:0:0:0:0:1:2:3
binding mcast socket to port:64000
setting up bad receiver socket with address /ff0e:0:0:0:0:1:2:4
binding mcast socket to port:64000
Listening on address /ff0e:0:0:0:0:1:2:3
Listening on address /ff0e:0:0:0:0:1:2:4
Sending 'Hello' on /ff0e:0:0:0:0:1:2:3:64000
/ff0e:0:0:0:0:1:2:4:64000 -- Received Hello
/ff0e:0:0:0:0:1:2:3:64000 -- Received Hello
Bad news. Detected the Promiscuous Traffic problem. Received Hello on undesired address /ff0e:0:0:0:0:1:2:4


> Binding to mcast address in UDP.java is not working on Linux with IPv6
> ----------------------------------------------------------------------
>
>                 Key: JGRP-956
>                 URL: https://jira.jboss.org/jira/browse/JGRP-956
>             Project: JGroups
>          Issue Type: Bug
>            Reporter: Richard Achmatowicz
>            Assignee: Bela Ban
>            Priority: Minor
>             Fix For: 2.8
>
>
> On Linux and Solaris platforms, when setting up the main multicast receiver socket, Bela allows binding the socket to its multicast address, like this:
> InetAddress group_addr = ...
> InetAddress bind_addr = ...
> SocketAddress group_sock_addr = new InetSocketAddress(group_addr, port) ;
> MulticastSocket s = new MulticastSocket(group_sock_addr) ;    // funny
> s.joinGroup(group_addr) ;
> Binding to the multicast address on Linux and Solaris was done in order to avoid the promiscuous traffic problem. A detailed discussion on the matter can be found in the bugzilla report:https://bugzilla.redhat.com/show_bug.cgi?id=231899. 
> This works on Linux with IPv4 but is not working on Linux with IPv6 for the multicast-address ff02::1 - an error message is being generated (SocketException, invalid argument) and  the code then tries to create the same multicast address in the usual way:
> InetAddress group_addr = ...
> InetAddress bind_addr = ...
> MulticastSocket s = new MulticastSocket(port) ;
> s.setInterface(bind_addr) ;
> s.joinGroup(group_addr) ;
> This is only a problem in that it generates a confusing error message about using mixed IPv4 / IPv6 stacks, but the socket continues to work correctly as far as I can tell.
> Haven't confirmed this, but I believe the promiscuous traffic issue does not arise with IPv6 multicast sockets.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list