[openjdk-x] Bind to a multicast address fails
Decke, Hendrik (K-GERFA/A)
hendrik.decke at volkswagen.de
Fri Sep 7 09:49:14 UTC 2018
Hello,
it seems one of our external developers (Andre Naujoks, CC) found a bug while binding a IPv6 multicast UDP-socket for one of our projects.
Since this seems to be a fundamental bug (from our perspective), we address this directly to this mailing list.
(reproducible in OpenJDK 8-11, Windows and Linux)
Following is the bug description from Andre:
This bugs affects all currently available Java versions in Debian (7, 8, 10 and 11).
If a java program tries to bind a datagram/UDP socket to a link- or node-local multicast
address and also sets the needed interface index, the bind operation on the socket
fails with "java.net.SocketException: Invalid argument".
This is because the JVM only transfers the interface index to the scope_id field in the struct sockaddr_in6,
if the address to bind to is a link local address (IN6_IS_ADDR_LINKLOCAL()).
A bind to a multicast address of link- or node-local scope needs the scope_id field as well.
(There might be an additional problem here, when binding to a higher scoped multicast address and trying to use
the non-default-route interface)
The attached patch fixes/adds this in the jvm.
[Edit HDecke: Since I am not sure if attachments are allowed on this mailing list, I put the link to the
corresponding debian bug log with the example and patch file at the end of the mail.]
I applied the patch by copying it to an "apt-get source"d openjdk-8 packages debian/patches dir and including it
in the debian/rules file in the COMMON_PATCHES variable. The resulting debian packages work as expected.
Additionally attached is a very small test program that wrongly throws the mentioned exception.
When run with the patched VM it works.
You might have to edit the interface name in line 33 when trying this out.
Regards,
Andre
This issue has also been reported to the debian bug logs: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=907541
Best regards,
Hendrik Decke
Volkswagen group research
Volkswagen Aktiengesellschaft
Brieffach 17770
38436 Wolfsburg
Tel. +49 5361 9-38363
Mobil +49-152-5-888874
www.volkswagen-ag.com
Volkswagen Aktiengesellschaft
Registered Seat: Wolfsburg I Registration Court: Amtsgericht Braunschweig
Commercial Register No.: 100484
Chairman of the Supervisory Board: Hans Dieter Pötsch
Board of Management: Herbert Diess (Chairman), Oliver Blume, Jochem Heizmann, Gunnar Kilian, Andreas Renschler, Stefan Sommer, Rupert Stadler, Hiltrud D. Werner, Frank Witter
Important Notice: The above information is automatically added to this e-mail. This addition does not constitute a representation that the content of this e-mail is legally relevant and/or is intended to be legally binding upon Volkswagen Aktiengesellschaft.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/net-dev/attachments/20180907/5c7b761a/attachment.html>
More information about the net-dev
mailing list