Subject: Re: routing cache related crashes with v6-mapped IPv4 addresses
To: None <tech-net@NetBSD.org>
From: Matthias Drochner <M.Drochner@fz-juelich.de>
List: tech-net
Date: 11/13/2007 16:09:43
This is a multipart MIME message.

--==_Exmh_9029164879350
Content-Type: text/plain; charset=us-ascii


M.Drochner@fz-juelich.de said:
> the case of an IPv4 route needs to be handled explicitely

The appended patch seems to dtrt. Not that clean yet, just
wanted to show what I mean.

best regards
Matthias





-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------
Forschungszentrum Juelich GmbH
52425 Juelich

Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzende des Aufsichtsrats: MinDirig'in Baerbel Brumme-Bothe
Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender), Dr. Ulrich Krafft (stellv. 
Vorsitzender)
-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------

--==_Exmh_9029164879350
Content-Type: text/plain ; name="rt6.txt"; charset=us-ascii
Content-Description: rt6.txt
Content-Disposition: attachment; filename="rt6.txt"

#
# old_revision [59f7530c4d8331941c3c311163aca3905463e4a6]
#
# patch "sys/netinet6/in6_pcb.c"
#  from [79113b7e49f05853e6eb05bb8b72abff9f00d3c4]
#    to [bc8982db6857980a87d1f36b4c87e5c06fa5ea64]
#
============================================================
--- sys/netinet6/in6_pcb.c	79113b7e49f05853e6eb05bb8b72abff9f00d3c4
+++ sys/netinet6/in6_pcb.c	bc8982db6857980a87d1f36b4c87e5c06fa5ea64
@@ -913,10 +913,19 @@ in6_pcbrtentry(struct in6pcb *in6p)
 	cdst = (const struct sockaddr_in6 *)rtcache_getdst(ro);
 	if (cdst == NULL)
 		;
-	else if (!IN6_ARE_ADDR_EQUAL(&cdst->sin6_addr, &in6p->in6p_faddr))
-		rtcache_free(ro);
-	else
-		rtcache_check(ro);
+	else if (cdst->sin6_family == AF_INET) {
+		KASSERT(IN6_IS_ADDR_V4MAPPED(&in6p->in6p_faddr));
+		if (bcmp(&((const struct sockaddr_in *)cdst)->sin_addr, 
+			 &in6p->in6p_faddr.s6_addr32[3], 4))
+			rtcache_free(ro);
+		else
+			rtcache_check(ro);
+	} else {
+		if (!IN6_ARE_ADDR_EQUAL(&cdst->sin6_addr, &in6p->in6p_faddr))
+			rtcache_free(ro);
+		else
+			rtcache_check(ro);
+	}
 #ifdef INET
 	if (ro->ro_rt == NULL && IN6_IS_ADDR_V4MAPPED(&in6p->in6p_faddr)) {
 		union {

--==_Exmh_9029164879350--