Module Name: src Committed By: martin Date: Wed Aug 11 17:24:43 UTC 2021
Modified Files: src/sys/netinet6 [netbsd-8]: in6_src.c Log Message: Pull up following revision(s) (requested by kardel in ticket #1690): sys/netinet6/in6_src.c: revision 1.88 PR kern/56348 MTU discovery fails with IPv6 sockets bound to IPv4 mapped address pick up the IPv4 route for IPv4 mapped IPv6 address to get the correct MTU and not any unrelated/inappropriate MTU from IPv6 routes. IPv4 mapped IPv6 addresses are always handled by the IPv4 stack and MTU discovery is solely handled with the IPv4 routing table. To generate a diff of this commit: cvs rdiff -u -r1.79.6.2 -r1.79.6.3 src/sys/netinet6/in6_src.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/netinet6/in6_src.c diff -u src/sys/netinet6/in6_src.c:1.79.6.2 src/sys/netinet6/in6_src.c:1.79.6.3 --- src/sys/netinet6/in6_src.c:1.79.6.2 Sun Dec 10 09:24:30 2017 +++ src/sys/netinet6/in6_src.c Wed Aug 11 17:24:42 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: in6_src.c,v 1.79.6.2 2017/12/10 09:24:30 snj Exp $ */ +/* $NetBSD: in6_src.c,v 1.79.6.3 2021/08/11 17:24:42 martin Exp $ */ /* $KAME: in6_src.c,v 1.159 2005/10/19 01:40:32 t-momose Exp $ */ /* @@ -66,7 +66,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: in6_src.c,v 1.79.6.2 2017/12/10 09:24:30 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: in6_src.c,v 1.79.6.3 2021/08/11 17:24:42 martin Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -608,6 +608,7 @@ in6_selectroute(struct sockaddr_in6 *dst struct rtentry *rt = NULL; union { struct sockaddr dst; + struct sockaddr_in dst4; struct sockaddr_in6 dst6; } u; @@ -674,9 +675,17 @@ in6_selectroute(struct sockaddr_in6 *dst * Use a cached route if it exists and is valid, else try to allocate * a new one. Note that we should check the address family of the * cached destination, in case of sharing the cache with IPv4. + * + * for V4 mapped addresses we want to pick up the v4 route + * see PR kern/56348 */ - u.dst6 = *dstsock; - u.dst6.sin6_scope_id = 0; + if (IN6_IS_ADDR_V4MAPPED(&dstsock->sin6_addr)) { + in6_sin6_2_sin(&u.dst4, dstsock); + } else { + u.dst6 = *dstsock; + u.dst6.sin6_scope_id = 0; + } + rt = rtcache_lookup1(*ro, &u.dst, 1); if (rt == NULL)