Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet6 PR kern/56348



details:   https://anonhg.NetBSD.org/src/rev/e4365251df54
branches:  trunk
changeset: 985160:e4365251df54
user:      kardel <kardel%NetBSD.org@localhost>
date:      Tue Aug 10 06:29:56 2021 +0000

description:
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.

diffstat:

 sys/netinet6/in6_src.c |  17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diffs (46 lines):

diff -r b3dc001323b6 -r e4365251df54 sys/netinet6/in6_src.c
--- a/sys/netinet6/in6_src.c    Mon Aug 09 21:38:04 2021 +0000
+++ b/sys/netinet6/in6_src.c    Tue Aug 10 06:29:56 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in6_src.c,v 1.87 2020/08/28 06:32:24 ozaki-r Exp $     */
+/*     $NetBSD: in6_src.c,v 1.88 2021/08/10 06:29:56 kardel 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.87 2020/08/28 06:32:24 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_src.c,v 1.88 2021/08/10 06:29:56 kardel Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -612,6 +612,7 @@
        struct rtentry *rt = NULL;
        union {
                struct sockaddr         dst;
+               struct sockaddr_in      dst4;
                struct sockaddr_in6     dst6;
        } u;
 
@@ -679,9 +680,17 @@
         * 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)



Home | Main Index | Thread Index | Old Index