From owner-freebsd-net Tue Mar 26 23:23:29 2002 Delivered-To: freebsd-net@freebsd.org Received: from mgo.iij.ad.jp (mgo.iij.ad.jp [202.232.15.6]) by hub.freebsd.org (Postfix) with ESMTP id EFB2237B405 for ; Tue, 26 Mar 2002 23:23:22 -0800 (PST) Received: from ns.iij.ad.jp (ns.iij.ad.jp [192.168.2.8]) by mgo.iij.ad.jp (8.8.8/MGO1.0) with ESMTP id QAA00217 for ; Wed, 27 Mar 2002 16:23:21 +0900 (JST) Received: from localhost (h123n005.iij.ad.jp [192.168.5.123]) by ns.iij.ad.jp (8.8.5/3.5Wpl7) with ESMTP id QAA10756 for ; Wed, 27 Mar 2002 16:23:21 +0900 (JST) Date: Wed, 27 Mar 2002 16:23:20 +0900 (JST) Message-Id: <20020327.162320.922733592.keiichi@iij.ad.jp> To: freebsd-net@FreeBSD.ORG Subject: Re: problems with udp46 sockets From: Keiichi SHIMA / =?iso-2022-jp?B?GyRCRWc3RDBsGyhC?= In-Reply-To: <20020326231734.H58573@Space.Net> References: <20020326231734.H58573@Space.Net> X-Mailer: Mew version 3.0.55 on XEmacs 21.1.14 (Cuyahoga Valley) Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Wed_Mar_27_16:23:20_2002_428)--" Content-Transfer-Encoding: 7bit Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org ----Next_Part(Wed_Mar_27_16:23:20_2002_428)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, From: Markus Stumpf > I am trying to get dnscache running with IPv6 patches. > dnscache binds to the IPv6 unqualified address "::". This works fine > and I get (from netstat) > udp46 0 0 *.53 *.* > As the sending address the IPv6 unqualified address "::" is used, also. > > As long as I only send queries via either IPv6 or IPv4 all works well, but > all subsequent queries via IPv6 after one or more queries via > IPv4 fail. The queries arrive properly, but sending the answer fails. > > >From truss I can see for that IPv6 answers: > sendto(0x3,0x80f34e0,0x55,0x0,0xbfbffbd0,0x1c) ERR#65 'No route to host' > for all queries via IPv6, queries via IPv4 still work without problems. > It doesn't matter if I use different source hosts for the queries via IPv6, > it fails for all of them. This is a cached route problem. struct inpcb has a route entry for cached route. Since inpcb is shared by both IPv4 and IPv6, the cached route entry is also shared by them. 4.5-STABLE doesn't check the protocol family of the cached route when using it. Therefore, once a IPv4 route is cached, ip6_output mistakingly use it as a cached route for IPv6 destination. Please try attached patches. --- Keiichi SHIMA IIJ Research Laboratory KAME Project ----Next_Part(Wed_Mar_27_16:23:20_2002_428)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ip_output.c.diff" --- ip_output.c.orig Wed Mar 27 14:29:43 2002 +++ ip_output.c Wed Mar 27 13:54:40 2002 @@ -219,6 +219,7 @@ * and is still up. If not, free it and try again. */ if (ro->ro_rt && ((ro->ro_rt->rt_flags & RTF_UP) == 0 || + dst->sin_family != AF_INET || dst->sin_addr.s_addr != ip->ip_dst.s_addr)) { RTFREE(ro->ro_rt); ro->ro_rt = (struct rtentry *)0; ----Next_Part(Wed_Mar_27_16:23:20_2002_428)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ip6_output.c.diff" --- ip6_output.c.orig Wed Mar 27 14:23:54 2002 +++ ip6_output.c Wed Mar 27 14:08:22 2002 @@ -461,6 +461,7 @@ * and is still up. If not, free it and try again. */ if (ro->ro_rt && ((ro->ro_rt->rt_flags & RTF_UP) == 0 || + dst->sin6_family != AF_INET6 || !IN6_ARE_ADDR_EQUAL(&dst->sin6_addr, &ip6->ip6_dst))) { RTFREE(ro->ro_rt); ro->ro_rt = (struct rtentry *)0; ----Next_Part(Wed_Mar_27_16:23:20_2002_428)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="in6_src.c.diff" --- in6_src.c.orig Wed Mar 27 14:24:28 2002 +++ in6_src.c Wed Mar 27 14:47:31 2002 @@ -239,7 +239,9 @@ */ if (ro) { if (ro->ro_rt && - !IN6_ARE_ADDR_EQUAL(&satosin6(&ro->ro_dst)->sin6_addr, dst)) { + (!(ro->ro_rt->rt_flags & RTF_UP) || + ro->ro_dst.sin6_family != AF_INET6 || + !IN6_ARE_ADDR_EQUAL(&satosin6(&ro->ro_dst)->sin6_addr, dst))) { RTFREE(ro->ro_rt); ro->ro_rt = (struct rtentry *)0; } ----Next_Part(Wed_Mar_27_16:23:20_2002_428)---- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message