Module Name: src Committed By: knakahara Date: Mon Aug 22 09:25:55 UTC 2022
Modified Files: src/share/man/man7: sysctl.7 src/sys/netinet: icmp6.h src/sys/netinet6: icmp6.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.159 -r1.160 src/share/man/man7/sysctl.7 cvs rdiff -u -r1.57 -r1.58 src/sys/netinet/icmp6.h cvs rdiff -u -r1.250 -r1.251 src/sys/netinet6/icmp6.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/share/man/man7/sysctl.7 diff -u src/share/man/man7/sysctl.7:1.159 src/share/man/man7/sysctl.7:1.160 --- src/share/man/man7/sysctl.7:1.159 Fri Aug 12 15:43:38 2022 +++ src/share/man/man7/sysctl.7 Mon Aug 22 09:25:55 2022 @@ -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 @@ The currently defined protocols and name .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 @@ only. .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 Index: src/sys/netinet/icmp6.h diff -u src/sys/netinet/icmp6.h:1.57 src/sys/netinet/icmp6.h:1.58 --- src/sys/netinet/icmp6.h:1.57 Mon Jul 27 14:52:55 2020 +++ src/sys/netinet/icmp6.h Mon Aug 22 09:25:55 2022 @@ -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 @@ struct icmp6_filter { #define OICMPV6CTL_ND6_PRLIST 20 #endif #define ICMPV6CTL_ND6_MAXQLEN 24 +#define ICMPV6CTL_REFLECT_PMTU 25 #ifdef _KERNEL struct rtentry; Index: src/sys/netinet6/icmp6.c diff -u src/sys/netinet6/icmp6.c:1.250 src/sys/netinet6/icmp6.c:1.251 --- src/sys/netinet6/icmp6.c:1.250 Fri Feb 19 14:52:00 2021 +++ src/sys/netinet6/icmp6.c Mon Aug 22 09:25:55 2022 @@ -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 @@ static int icmp6_redirect_lowat = -1; /* 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 @@ icmp6_reflect(struct mbuf *m, size_t off 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 @@ icmp6_reflect(struct mbuf *m, size_t off 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 @@ sysctl_net_inet6_icmp6_setup(struct sysc 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