kern/127057: [udp] Unable to send UDP packet via IPv6 socket
to IPv4 mapped address
Alexander V. Chernikov
melifaro at ipfw.ru
Thu Jun 24 16:00:14 UTC 2010
The following reply was made to PR kern/127057; it has been noted by GNATS.
From: "Alexander V. Chernikov" <melifaro at ipfw.ru>
To: bug-followup at FreeBSD.org, saper at SYSTEM.PL
Cc:
Subject: Re: kern/127057: [udp] Unable to send UDP packet via IPv6 socket
to IPv4 mapped address
Date: Thu, 24 Jun 2010 19:54:02 +0400
Problem can be more easily reproduced with nc:
echo | ktrace nc -nu6 ::ffff:127.0.0.1 53 ; kdump | grep socket -A 15
1682 nc CALL socket(PF_INET6,SOCK_DGRAM,IPPROTO_UDP)
1682 nc RET socket 3
1682 nc CALL connect(0x3,0x800a050e0,0x1c)
1682 nc STRU struct sockaddr { AF_INET6, [::ffff:127.0.0.1]:53 }
1682 nc RET connect 0
1682 nc CALL poll(0x7fffffffa6b0,0x2,0xffffffff)
1682 nc RET poll 1
1682 nc CALL read(0,0x7fffffffa6c0,0x400)
1682 nc GIO fd 0 read 1 byte
"
"
1682 nc RET read 1
1682 nc CALL write(0x3,0x7fffffffa6c0,0x1)
1682 nc RET write -1 errno 22 Invalid argument
1682 nc CALL close(0x3)
1682 nc RET close 0
1682 nc CALL sigprocmask(SIG_BLOCK,0x80063e140,0x7fffffffc640)
Problem is related with an [implicit] IPv4 bind() done in in_pcbconnect
(or in_pcbbind_setup for explicit bind ).
bind results in selected IPv4 address written in
inp_inc.inc_ie.ie_dependladdr.ie46_local.ia46_addr4
According to struct in_addr_4in6, interpreting witten value as IPv6
address results in ::127.0.0.1 v6 address for 127.0.0.1 which is not
IPv4-mapped address (it is deprecated IPv4-compatible adddress, actually).
This address causes udp6_send() returning EINVAL (immediately after
IN6_IS_ADDR_V4MAPPED(&inp->in6p_laddr) check)
Proposed solution is to add missing :ffff: immediately after successful
v4 layer connect, e.g.
--- sys/netinet6/udp6_usrreq.c.orig 2010-06-24 12:32:10.813316692 +0000
+++ sys/netinet6/udp6_usrreq.c 2010-06-24 12:33:02.977455989 +0000
@@ -923,6 +923,8 @@
if (error == 0) {
inp->inp_vflag |= INP_IPV4;
inp->inp_vflag &= ~INP_IPV6;
+ /* Make v6 addr v4-mapped */
+
inp->inp_inc.inc_ie.ie_dependladdr.ie46_local.ia46_pad32[2] =
IPV6_ADDR_INT32_SMP;
soisconnected(so);
}
goto out;
This tiny patch fixes java DNS resolution for me
More information about the freebsd-net
mailing list