From owner-freebsd-net@FreeBSD.ORG Sat Jun 25 12:19:37 2011 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6FCDE106566B for ; Sat, 25 Jun 2011 12:19:37 +0000 (UTC) (envelope-from prvs=1157d11ea9=killing@multiplay.co.uk) Received: from mail1.multiplay.co.uk (mail1.multiplay.co.uk [85.236.96.23]) by mx1.freebsd.org (Postfix) with ESMTP id E9EBF8FC0A for ; Sat, 25 Jun 2011 12:19:36 +0000 (UTC) X-MDAV-Processed: mail1.multiplay.co.uk, Sat, 25 Jun 2011 13:18:54 +0100 X-Spam-Processed: mail1.multiplay.co.uk, Sat, 25 Jun 2011 13:18:53 +0100 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on mail1.multiplay.co.uk X-Spam-Level: X-Spam-Status: No, score=-5.0 required=6.0 tests=USER_IN_WHITELIST shortcircuit=ham autolearn=disabled version=3.2.5 Received: from r2d2 ([188.220.16.49]) by mail1.multiplay.co.uk (mail1.multiplay.co.uk [85.236.96.23]) (MDaemon PRO v10.0.4) with ESMTP id md50013865102.msg; Sat, 25 Jun 2011 13:18:53 +0100 X-MDRemoteIP: 188.220.16.49 X-Return-Path: prvs=1157d11ea9=killing@multiplay.co.uk X-Envelope-From: killing@multiplay.co.uk Message-ID: <05C71CCF2FEF492D9571F57261FA884F@multiplay.co.uk> From: "Steven Hartland" To: "Bjoern A. Zeeb" References: <9585F512F239475B8145C3D344F6EC62@multiplay.co.uk> <75860ED5-B60D-4EF2-90B6-F313BEFA36F7@FreeBSD.org> Date: Sat, 25 Jun 2011 13:19:13 +0100 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0057_01CC333A.7A3B2D00" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6090 Cc: freebsd-net@freebsd.org Subject: Re: IPv4 socket bind using IPv6 socket on openjdk6 breaks udp send X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Jun 2011 12:19:37 -0000 This is a multi-part message in MIME format. ------=_NextPart_000_0057_01CC333A.7A3B2D00 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit ----- Original Message ----- From: "Bjoern A. Zeeb" To: "Steven Hartland" Cc: Sent: Saturday, June 25, 2011 10:27 AM Subject: Re: IPv4 socket bind using IPv6 socket on openjdk6 breaks udp send On Jun 24, 2011, at 9:11 PM, Steven Hartland wrote: Hi, > We're trying to get our machines IPv6 enabled but in doing so this > seems to break java apps using openjdk6 for UDP sends. > > One of the clues I can give you is: > http://diario.behrens.de/2008/10/12/java_and_ipv6_on_bsd.html > > it's old(er) and I have lately been tolded that openjdk has a problem. Yer read that but it seems like the jdk7 patch is already in which should fix it:- http://www.freebsd.org/cgi/cvsweb.cgi/ports/java/openjdk6/files/patch-set > using truss we see the following:- > socket(PF_INET6,SOCK_DGRAM,0) = 20 (0x14) > setsockopt(0x14,0x29,0x1b,0x7ffffedf0318,0x4,0x0) = 0 (0x0) > setsockopt(0x14,0xffff,0x20,0x7ffffedf031c,0x4,0x0) = 0 (0x0) > bind(20,{ AF_INET6 [3800::10:0:0:0]:20736 },28) = 0 (0x0) > .. > recvfrom(20,0x7ffffeaeb580,1460,0x0,0x7ffffeaed580,0x7ffffeaed5ac) ERR#60 'Operation timed out' > .. > sendto(20,"\M^?\M^?\M^?\M^?I\aMultiplay :: "...,82,0x0,{ AF_INET6 [3800::10:0:0:0]:20736 },0x1c) ERR#22 'Invalid argument' > > So how much is really between these ...? If you want, can you send > me a full output in private email? Just a load of gettimeofday, clock_gettime, _umtx_op and mprotect calls nothing of interest. > Also which version of FreeBSD is this? 8.2-RELEASE > sockstat shows it binding correctly > root java 894 21 tcp4 85.236.109.212:25675 *:* > > That's unfortunately unreleated. Yer cut and paste error (wrong line) heres the correct line. root java 894 20 udp4 85.236.109.212:25675 *:* 21 is the tcp port created in the same manor (ipv6 socket) which works fine. > The following PR seems relevant but also seems to indicate it was > fixed back in 2006 > http://www.freebsd.org/cgi/query-pr.cgi?pr=92620 > This doesn't seen to be related to the above as 3800::10:0:0:0 is > not a v4-mapped-v6 address. Now there could be the problem really. > Do you know which address the code above was trying to talk with? I'm wondering if thats a decode error by truss, as it doesn't seem to corrispond to anything on the machine and is the same no matter what ip the socket is bound to. ifconfig output in my last reply if that helps. > Also do you have a very simple test program I could try to run if > I compile openjdk6? The attached java file demonstrates the behviour. java Main Then just send any udp packet to :25675 it should respond with pong but on a dual stack machine it just throws as exception:- WARNING: IO: Invalid argument java.io.IOException: Invalid argument at java.net.PlainDatagramSocketImpl.send(Native Method) at java.net.DatagramSocket.send(DatagramSocket.java:629) at Main.main(Main.java:34) Regards Steve ================================================ This e.mail is private and confidential between Multiplay (UK) Ltd. and the person or entity to whom it is addressed. In the event of misdirection, the recipient is prohibited from using, copying, printing or otherwise disseminating it or any information contained in it. In the event of misdirection, illegible or incomplete transmission please telephone +44 845 868 1337 or return the E.mail to postmaster@multiplay.co.uk. ------=_NextPart_000_0057_01CC333A.7A3B2D00 Content-Type: application/octet-stream; name="Main.java" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="Main.java" import java.io.IOException;=0A= import java.net.InetAddress;=0A= import java.net.DatagramSocket;=0A= import java.net.SocketException;=0A= import java.net.DatagramPacket;=0A= import java.util.logging.Logger;=0A= import java.util.logging.Level;=0A= =0A= public class Main {=0A= =0A= public static void main(String[] args) throws java.io.IOException {=0A= if (1 !=3D args.length) {=0A= System.err.println( "Missing bind IP" );=0A= System.exit(1);=0A= }=0A= int port =3D 25675;=0A= InetAddress ipv4Address =3D InetAddress.getByName(args[0]);=0A= DatagramSocket socket =3D new DatagramSocket(port, ipv4Address);=0A= Logger log =3D Logger.getLogger("MAIN");=0A= byte[] buffer =3D new byte[1460];=0A= =0A= log.info( "Running on: " + ipv4Address + ":" + port);=0A= DatagramPacket request =3D new DatagramPacket( buffer, = buffer.length );=0A= try=0A= {=0A= while (true)=0A= {=0A= try=0A= {=0A= socket.receive(request);=0A= log.info("Recieved " + request.getLength() + " bytes = from: " + request.getSocketAddress());=0A= String response =3D new String("pong");=0A= byte[] bytes =3D response.getBytes();=0A= socket.send(new DatagramPacket(bytes, bytes.length, = request.getSocketAddress()));=0A= log.info("Sent pong");=0A= }=0A= catch (SocketException e)=0A= {=0A= log.log(Level.WARNING, "Socket: " + e.getMessage(), = e);=0A= }=0A= catch (IOException e )=0A= {=0A= log.log(Level.WARNING, "IO: " + e.getMessage(), e);=0A= }=0A= }=0A= }=0A= finally=0A= {=0A= if (null !=3D socket)=0A= {=0A= socket.close();=0A= socket =3D null;=0A= }=0A= }=0A= }=0A= } ------=_NextPart_000_0057_01CC333A.7A3B2D00--