From owner-freebsd-java@FreeBSD.ORG Sat Aug 20 23:18:23 2011 Return-Path: Delivered-To: java@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F41D4106566B for ; Sat, 20 Aug 2011 23:18:22 +0000 (UTC) (envelope-from wollman@khavrinen.csail.mit.edu) Received: from khavrinen.csail.mit.edu (khavrinen.csail.mit.edu [128.30.28.20]) by mx1.freebsd.org (Postfix) with ESMTP id ABB2C8FC08; Sat, 20 Aug 2011 23:18:22 +0000 (UTC) Received: from khavrinen.csail.mit.edu (localhost [127.0.0.1]) by khavrinen.csail.mit.edu (8.14.4/8.14.4) with ESMTP id p7KN6u5D054628 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL CN=khavrinen.csail.mit.edu issuer=Client+20CA); Sat, 20 Aug 2011 19:06:56 -0400 (EDT) (envelope-from wollman@khavrinen.csail.mit.edu) Received: (from wollman@localhost) by khavrinen.csail.mit.edu (8.14.4/8.14.4/Submit) id p7KN6uvL054625; Sat, 20 Aug 2011 19:06:56 -0400 (EDT) (envelope-from wollman) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <20048.15888.402674.836232@khavrinen.csail.mit.edu> Date: Sat, 20 Aug 2011 19:06:56 -0400 From: Garrett Wollman To: java@freebsd.org, network@freebsd.org X-Mailer: VM 7.17 under 21.4 (patch 22) "Instant Classic" XEmacs Lucid X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.2.7 (khavrinen.csail.mit.edu [127.0.0.1]); Sat, 20 Aug 2011 19:06:56 -0400 (EDT) Cc: Subject: Why doesn't UDP work for ICSI Netalyzr in INET6 kernels? X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Aug 2011 23:18:23 -0000 The ICSI Netalyzr tool (netalyzr.icsi.berkeley.edu) is a Java applet and standalone Java program that checks for various issues with network connections. It attempts to use java.net.DatagramSocket.send to send UDP packets to various destinations it's testing, and fails with java.io.IOException: 002.097 main| Running test 3: checkUDP 002.097 main| ---------------------------- 002.098 test-3| Sending UDP request to n4.netalyzr.icsi.berkeley.edu on port 1947 002.100 test-3| Test aborted due to IO exception: 002.102 test-3| java.io.IOException: Invalid argument 002.102 test-3| at java.net.PlainDatagramSocketImpl.send(Native Method) 002.102 test-3| at java.net.DatagramSocket.send(DatagramSocket.java:675) 002.102 test-3| at Netalyzr.checkUDP(Netalyzr.java:7509) 002.102 test-3| at Netalyzr$5.runImpl(Netalyzr.java:1701) 002.102 test-3| at Netalyzr$Test.run(Netalyzr.java:810) 002.102 test-3| at java.lang.Thread.run(Thread.java:722) (excerpt from the Netalyzr client log). I currently have openjdk-7.0.147_1 installed, but I've seen this problem with recent openjdk6 as well. Near as I can tell, the relevant system calls are as follows: 54253 java CALL socket(PF_INET6,SOCK_DGRAM,IPPROTO_IP) 54253 java RET socket 10/0xa 54253 java CALL setsockopt(0xa,0x29,0x1b,0x7ffffe7ea4f8,0x4) 54253 java RET setsockopt 0 54253 java CALL setsockopt(0xa,SOL_SOCKET,SO_BROADCAST,0x7ffffe7ea4fc,0x4) 54253 java RET setsockopt 0 54253 java CALL bind(0xa,0x7ffffe7ea460,0x1c) 54253 java STRU struct sockaddr { AF_INET6, [::]:0 } 54253 java RET bind 0 54253 java CALL getsockname(0xa,0x7ffffe7ea460,0x7ffffe7ea47c) 54253 java STRU struct sockaddr { AF_INET6, [::]:49501 } 54253 java RET getsockname 0 54253 java CALL connect(0xa,0x7ffffe7ea490,0x1c) 54253 java STRU struct sockaddr { AF_INET6, [::ffff:67.202.32.138]:1947 } 54253 java RET connect 0 54253 java CALL clock_gettime(0x4,0x7ffffe7e9b30) 54253 java RET clock_gettime 0 54253 java CALL clock_gettime(0x4,0x7ffffe7e9a80) 54253 java RET clock_gettime 0 54253 java CALL stat(0x83f85b460,0x7ffffe7e9090) 54253 java NAMI "/usr/local/openjdk7/jre/lib/amd64/libnet.so" 54253 java STRU struct stat {dev=1265533522, ino=31267, mode=-r--r--r-- , nlink=1, uid=0, gid=0, rdev=0, atime=1313879682.657870435, stime=1311142325.460426000, ctime=1311142337.955051534, birthtime=1311142337.333960566, size=99277, blksize=99328, blocks=195, flags=0x0 } 54253 java RET stat 0 54253 java CALL sendto(0xa,0x7ffffe7da570,0x25,0,0,0) 54253 java RET sendto -1 errno 22 Invalid argument At this point Netalyzr goes on to try the next thing on its list. I am unable to figure out which EINVAL return in the kernel it is hitting. It is not the one related to net.inet6.ip6.v6only -- the same error happens with it either on or off. Netalyzr works just fine if the kernel is compiled without options INET6 (so the Java libraries seem to be correctly detecting the complete lack of IPv6 support, and when they try to use only PF_INET sockets for IPv4 UDP traffic, it does work). The jar file can be downloaded at: -GAWollman