Source-Changes-HG archive

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

[src/trunk]: src/sys/netinet6 Add sysctl entry to enable/disable to use path ...



details:   https://anonhg.NetBSD.org/src/rev/f4b5e7a4a31f
branches:  trunk
changeset: 369584:f4b5e7a4a31f
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Mon Aug 22 09:25:55 2022 +0000

description:
Add sysctl entry to enable/disable to use path MTU discovery for icmpv6 reflecting.

If we want to use path MTU discovery for icmp reflecting set
net.inet6.icmp6.reflect_pmtu=1.  Default(=0) is the same as before, that is,
use IPV6_MINMTU.

diffstat:

 share/man/man7/sysctl.7 |   7 ++++++-
 sys/netinet/icmp6.h     |   3 ++-
 sys/netinet6/icmp6.c    |  18 +++++++++++++++---
 3 files changed, 23 insertions(+), 5 deletions(-)

diffs (110 lines):

diff -r da23e37f748b -r f4b5e7a4a31f share/man/man7/sysctl.7
--- a/share/man/man7/sysctl.7   Mon Aug 22 09:14:59 2022 +0000
+++ b/share/man/man7/sysctl.7   Mon Aug 22 09:25:55 2022 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: sysctl.7,v 1.159 2022/08/12 15:43:38 riastradh Exp $
+.\"    $NetBSD: sysctl.7,v 1.160 2022/08/22 09:25:55 knakahara Exp $
 .\"
 .\" Copyright (c) 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -1855,6 +1855,7 @@
 .It icmp6      nodeinfo        integer yes
 .It icmp6      rediraccept     integer yes
 .It icmp6      redirtimeout    integer yes
+.It icmp6      reflect_pmtu    boolean yes
 .It ip6        accept_rtadv    integer yes
 .It ip6        addctlpolicy    struct in6_addrpolicy   no
 .It ip6        anonportalgo.selected   string  yes
@@ -2116,6 +2117,10 @@
 .It Li icmp6.redirtimeout
 The variable specifies lifetime of routing entries generated by incoming
 ICMPv6 redirect.
+.It Li icmp6.reflect_pmtu
+A boolean that icmpv6 reflecting uses path MTU discovery or not.
+When not, icmpv6 reflecting uses IPV6_MINMTU.
+ICMPv6 redirect.
 .It Li udp6.do_loopback_cksum
 Perform UDP checksum on loopback.
 .It Li udp6.recvspace
diff -r da23e37f748b -r f4b5e7a4a31f sys/netinet/icmp6.h
--- a/sys/netinet/icmp6.h       Mon Aug 22 09:14:59 2022 +0000
+++ b/sys/netinet/icmp6.h       Mon Aug 22 09:25:55 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: icmp6.h,v 1.57 2020/07/27 14:52:55 roy Exp $   */
+/*     $NetBSD: icmp6.h,v 1.58 2022/08/22 09:25:55 knakahara Exp $     */
 /*     $KAME: icmp6.h,v 1.84 2003/04/23 10:26:51 itojun Exp $  */
 
 
@@ -640,6 +640,7 @@
 #define OICMPV6CTL_ND6_PRLIST  20
 #endif
 #define        ICMPV6CTL_ND6_MAXQLEN   24
+#define        ICMPV6CTL_REFLECT_PMTU  25
 
 #ifdef _KERNEL
 struct rtentry;
diff -r da23e37f748b -r f4b5e7a4a31f sys/netinet6/icmp6.c
--- a/sys/netinet6/icmp6.c      Mon Aug 22 09:14:59 2022 +0000
+++ b/sys/netinet6/icmp6.c      Mon Aug 22 09:25:55 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: icmp6.c,v 1.250 2021/02/19 14:52:00 christos Exp $     */
+/*     $NetBSD: icmp6.c,v 1.251 2022/08/22 09:25:55 knakahara Exp $    */
 /*     $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.250 2021/02/19 14:52:00 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.251 2022/08/22 09:25:55 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -181,6 +181,8 @@
 /* Protect mtudisc and redirect stuffs */
 static kmutex_t icmp6_mtx __cacheline_aligned;
 
+static bool icmp6_reflect_pmtu = false;
+
 static void icmp6_errcount(u_int, int, int);
 static int icmp6_rip6_input(struct mbuf **, int);
 static void icmp6_reflect(struct mbuf *, size_t);
@@ -2058,6 +2060,7 @@
        struct ifnet *rcvif;
        int s;
        bool ip6_src_filled = false;
+       int flags;
 
        /* too short to reflect */
        if (off < sizeof(struct ip6_hdr)) {
@@ -2202,12 +2205,14 @@
        m->m_flags &= ~(M_BCAST|M_MCAST);
 
        /*
+        * Note for icmp6_reflect_pmtu == false
         * To avoid a "too big" situation at an intermediate router
         * and the path MTU discovery process, specify the IPV6_MINMTU flag.
         * Note that only echo and node information replies are affected,
         * since the length of ICMP6 errors is limited to the minimum MTU.
         */
-       if (ip6_output(m, NULL, NULL, IPV6_MINMTU, NULL, NULL, &outif) != 0 &&
+       flags = icmp6_reflect_pmtu ? 0 : IPV6_MINMTU;
+       if (ip6_output(m, NULL, NULL, flags, NULL, NULL, &outif) != 0 &&
            outif)
                icmp6_ifstat_inc(outif, ifs6_out_error);
        if (outif)
@@ -3105,6 +3110,13 @@
                       CTL_NET, PF_INET6, IPPROTO_ICMPV6,
                       OICMPV6CTL_ND6_PRLIST, CTL_EOL);
 #endif
+       sysctl_createv(clog, 0, NULL, NULL,
+                      CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+                      CTLTYPE_BOOL, "reflect_pmtu",
+                      SYSCTL_DESCR("Use path MTU Discovery for icmpv6 reflect"),
+                      NULL, 0, &icmp6_reflect_pmtu, 0,
+                      CTL_NET, PF_INET6, IPPROTO_ICMPV6,
+                      ICMPV6CTL_REFLECT_PMTU, CTL_EOL);
 }
 
 void



Home | Main Index | Thread Index | Old Index