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 control to send routing mes...
details: https://anonhg.NetBSD.org/src/rev/35450d46a067
branches: trunk
changeset: 369722:35450d46a067
user: knakahara <knakahara%NetBSD.org@localhost>
date: Mon Aug 29 09:14:02 2022 +0000
description:
Add sysctl entry to control to send routing message for RTM_DYNAMIC.
Some routing daemons require such routing message to keep coherency.
If we want to let kernel send such message, set net.inet.icmp.dynamic_rt_msg=1
for IPv4, net.inet6.icmp6.dynamic_rt_msg=1 for IPv6.
Default(=0) is the same as before, that is, not send such routing message.
diffstat:
share/man/man7/sysctl.7 | 13 ++++++++++---
sys/net/route.c | 45 +++++++++++++++++++++++++++++++++++++++++++--
sys/net/route.h | 3 ++-
sys/netinet/icmp6.h | 3 ++-
sys/netinet/icmp_var.h | 3 ++-
sys/netinet/in_pcb.c | 8 +++++---
sys/netinet/ip_icmp.c | 16 ++++++++++++++--
sys/netinet6/icmp6.c | 16 ++++++++++++++--
sys/netinet6/in6_pcb.c | 8 +++++---
9 files changed, 97 insertions(+), 18 deletions(-)
diffs (truncated from 369 to 300 lines):
diff -r 9131da79eb7a -r 35450d46a067 share/man/man7/sysctl.7
--- a/share/man/man7/sysctl.7 Mon Aug 29 09:04:27 2022 +0000
+++ b/share/man/man7/sysctl.7 Mon Aug 29 09:14:02 2022 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: sysctl.7,v 1.160 2022/08/22 09:25:55 knakahara Exp $
+.\" $NetBSD: sysctl.7,v 1.161 2022/08/29 09:14:02 knakahara Exp $
.\"
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
@@ -29,7 +29,7 @@
.\"
.\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95
.\"
-.Dd August 9, 2022
+.Dd August 29, 2022
.Dt SYSCTL 7
.Os
.Sh NAME
@@ -1457,6 +1457,7 @@
.It icmp rediraccept integer yes
.It icmp redirtimeout integer yes
.It icmp bmcastecho integer yes
+.It icmp dynamic_rt_msg boolean yes
.It ip allowsrcrt integer yes
.It ip anonportalgo.selected string yes
.It ip anonportalgo.available string yes
@@ -1703,6 +1704,9 @@
.It Li icmp.bmcastecho
If set to 1, enables responding to ICMP echo or timestamp request to the
broadcast address.
+.It Li icmp.dynamic_rt_msg
+A boolean that the kernel sends routing message for RTM_DYNAMIC or not.
+If set to true, sends such routing message.
.It Li tcp.ack_on_push
If set to 1, TCP is to immediately transmit an ACK upon reception of
a packet with PUSH set.
@@ -1856,6 +1860,7 @@
.It icmp6 rediraccept integer yes
.It icmp6 redirtimeout integer yes
.It icmp6 reflect_pmtu boolean yes
+.It icmp6 dynamic_rt_msg boolean yes
.It ip6 accept_rtadv integer yes
.It ip6 addctlpolicy struct in6_addrpolicy no
.It ip6 anonportalgo.selected string yes
@@ -2120,7 +2125,9 @@
.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 icmp6.dynamic_rt_msg
+A boolean that the kernel sends routing message for RTM_DYNAMIC or not.
+If set to true, sends such routing message.
.It Li udp6.do_loopback_cksum
Perform UDP checksum on loopback.
.It Li udp6.recvspace
diff -r 9131da79eb7a -r 35450d46a067 sys/net/route.c
--- a/sys/net/route.c Mon Aug 29 09:04:27 2022 +0000
+++ b/sys/net/route.c Mon Aug 29 09:14:02 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: route.c,v 1.231 2022/08/26 08:32:22 knakahara Exp $ */
+/* $NetBSD: route.c,v 1.232 2022/08/29 09:14:02 knakahara Exp $ */
/*-
* Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
#endif
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.231 2022/08/26 08:32:22 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.232 2022/08/29 09:14:02 knakahara Exp $");
#include <sys/param.h>
#ifdef RTFLUSH_DEBUG
@@ -884,6 +884,8 @@
error = rtrequest1(RTM_ADD, &info, &rt);
if (rt != NULL)
flags = rt->rt_flags;
+ if (error == 0)
+ rt_newmsg_dynamic(RTM_ADD, rt);
stat = &rtstat.rts_dynamic;
} else {
/*
@@ -1546,6 +1548,45 @@
}
/*
+ * Inform the routing socket of a route change for RTF_DYNAMIC.
+ */
+void
+rt_newmsg_dynamic(const int cmd, const struct rtentry *rt)
+{
+ extern bool icmp_dynamic_rt_msg;
+ extern bool icmp6_dynamic_rt_msg;
+ struct rt_addrinfo info;
+ struct sockaddr *gateway = rt->rt_gateway;
+
+ if (gateway == NULL)
+ return;
+
+ switch(gateway->sa_family){
+ case AF_INET:
+ if (!icmp_dynamic_rt_msg)
+ return;
+ break;
+ case AF_INET6:
+ if (!icmp6_dynamic_rt_msg)
+ return;
+ break;
+ default:
+ return;
+ }
+
+ memset((void *)&info, 0, sizeof(info));
+ info.rti_info[RTAX_DST] = rt_getkey(rt);
+ info.rti_info[RTAX_GATEWAY] = gateway;
+ info.rti_info[RTAX_NETMASK] = rt_mask(rt);
+ if (rt->rt_ifp) {
+ info.rti_info[RTAX_IFP] = rt->rt_ifp->if_dl->ifa_addr;
+ info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr;
+ }
+
+ rt_missmsg(cmd, &info, rt->rt_flags, 0);
+}
+
+/*
* Set up or tear down a routing table entry, normally
* for an interface.
*/
diff -r 9131da79eb7a -r 35450d46a067 sys/net/route.h
--- a/sys/net/route.h Mon Aug 29 09:04:27 2022 +0000
+++ b/sys/net/route.h Mon Aug 29 09:14:02 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: route.h,v 1.130 2022/08/26 08:32:22 knakahara Exp $ */
+/* $NetBSD: route.h,v 1.131 2022/08/29 09:14:02 knakahara Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@@ -437,6 +437,7 @@
void rt_update_finish(struct rtentry *);
void rt_newmsg(const int, const struct rtentry *);
+void rt_newmsg_dynamic(const int, const struct rtentry *);
struct rtentry *
rtalloc1(const struct sockaddr *, int);
int rtinit(struct ifaddr *, int, int);
diff -r 9131da79eb7a -r 35450d46a067 sys/netinet/icmp6.h
--- a/sys/netinet/icmp6.h Mon Aug 29 09:04:27 2022 +0000
+++ b/sys/netinet/icmp6.h Mon Aug 29 09:14:02 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: icmp6.h,v 1.58 2022/08/22 09:25:55 knakahara Exp $ */
+/* $NetBSD: icmp6.h,v 1.59 2022/08/29 09:14:02 knakahara Exp $ */
/* $KAME: icmp6.h,v 1.84 2003/04/23 10:26:51 itojun Exp $ */
@@ -641,6 +641,7 @@
#endif
#define ICMPV6CTL_ND6_MAXQLEN 24
#define ICMPV6CTL_REFLECT_PMTU 25
+#define ICMPV6CTL_DYNAMIC_RT_MSG 26
#ifdef _KERNEL
struct rtentry;
diff -r 9131da79eb7a -r 35450d46a067 sys/netinet/icmp_var.h
--- a/sys/netinet/icmp_var.h Mon Aug 29 09:04:27 2022 +0000
+++ b/sys/netinet/icmp_var.h Mon Aug 29 09:14:02 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: icmp_var.h,v 1.31 2018/08/22 01:05:24 msaitoh Exp $ */
+/* $NetBSD: icmp_var.h,v 1.32 2022/08/29 09:14:02 knakahara Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
@@ -72,6 +72,7 @@
#define ICMPCTL_REDIRTIMEOUT 6 /* Remove routes added via redirects */
#define ICMPCTL_STATS 7 /* ICMP statistics */
#define ICMPCTL_BMCASTECHO 8 /* allow broad/mult-cast echo */
+#define ICMPCTL_DYNAMIC_RT_MSG 9 /* send routing message for RTM_DYNAMIC */
#ifdef _KERNEL
diff -r 9131da79eb7a -r 35450d46a067 sys/netinet/in_pcb.c
--- a/sys/netinet/in_pcb.c Mon Aug 29 09:04:27 2022 +0000
+++ b/sys/netinet/in_pcb.c Mon Aug 29 09:14:02 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: in_pcb.c,v 1.189 2022/07/29 07:35:16 knakahara Exp $ */
+/* $NetBSD: in_pcb.c,v 1.190 2022/08/29 09:14:02 knakahara Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -93,7 +93,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.189 2022/07/29 07:35:16 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.190 2022/08/29 09:14:02 knakahara Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -841,8 +841,10 @@
error = rtrequest(RTM_DELETE, rt_getkey(rt),
rt->rt_gateway, rt_mask(rt), rt->rt_flags, &nrt);
rtcache_unref(rt, &inp->inp_route);
- if (error == 0)
+ if (error == 0) {
+ rt_newmsg_dynamic(RTM_DELETE, nrt);
rt_free(nrt);
+ }
} else
rtcache_unref(rt, &inp->inp_route);
/*
diff -r 9131da79eb7a -r 35450d46a067 sys/netinet/ip_icmp.c
--- a/sys/netinet/ip_icmp.c Mon Aug 29 09:04:27 2022 +0000
+++ b/sys/netinet/ip_icmp.c Mon Aug 29 09:14:02 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_icmp.c,v 1.177 2018/12/22 14:28:57 maxv Exp $ */
+/* $NetBSD: ip_icmp.c,v 1.178 2022/08/29 09:14:02 knakahara Exp $ */
/*
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -94,7 +94,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.177 2018/12/22 14:28:57 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_icmp.c,v 1.178 2022/08/29 09:14:02 knakahara Exp $");
#ifdef _KERNEL_OPT
#include "opt_ipsec.h"
@@ -158,6 +158,8 @@
/* unused... */
u_int ip_next_mtu(u_int, int);
+bool icmp_dynamic_rt_msg = false;
+
static int icmperrppslim = 100; /* 100pps */
static int icmperrpps_count = 0;
static struct timeval icmperrppslim_last;
@@ -1118,6 +1120,13 @@
NULL, 0, &icmpbmcastecho, 0,
CTL_NET, PF_INET, IPPROTO_ICMP, ICMPCTL_BMCASTECHO,
CTL_EOL);
+ sysctl_createv(clog, 0, NULL, NULL,
+ CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+ CTLTYPE_BOOL, "dynamic_rt_msg",
+ SYSCTL_DESCR("Send routing message for RTF_DYNAMIC"),
+ NULL, 0, &icmp_dynamic_rt_msg, 0,
+ CTL_NET, PF_INET, IPPROTO_ICMP, ICMPCTL_DYNAMIC_RT_MSG,
+ CTL_EOL);
}
void
@@ -1158,6 +1167,7 @@
return;
}
nrt->rt_rmx = rt->rt_rmx;
+ rt_newmsg_dynamic(RTM_ADD, nrt);
rt_unref(rt);
rt = nrt;
}
@@ -1271,6 +1281,7 @@
(RTF_DYNAMIC | RTF_HOST)) {
rtrequest(RTM_DELETE, rt_getkey(rt),
rt->rt_gateway, rt_mask(rt), rt->rt_flags, &retrt);
+ rt_newmsg_dynamic(RTM_DELETE, retrt);
rt_unref(rt);
rt_free(retrt);
} else {
@@ -1292,6 +1303,7 @@
(RTF_DYNAMIC | RTF_HOST)) {
rtrequest(RTM_DELETE, rt_getkey(rt),
rt->rt_gateway, rt_mask(rt), rt->rt_flags, &retrt);
+ rt_newmsg_dynamic(RTM_DELETE, retrt);
rt_unref(rt);
rt_free(retrt);
}
diff -r 9131da79eb7a -r 35450d46a067 sys/netinet6/icmp6.c
--- a/sys/netinet6/icmp6.c Mon Aug 29 09:04:27 2022 +0000
+++ b/sys/netinet6/icmp6.c Mon Aug 29 09:14:02 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: icmp6.c,v 1.251 2022/08/22 09:25:55 knakahara Exp $ */
+/* $NetBSD: icmp6.c,v 1.252 2022/08/29 09:14:02 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.251 2022/08/22 09:25:55 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.252 2022/08/29 09:14:02 knakahara Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -151,6 +151,8 @@
static struct timeval icmp6errppslim_last;
extern int icmp6_nodeinfo;
+bool icmp6_dynamic_rt_msg = false;
+
/*
* List of callbacks to notify when Path MTU changes are made.
Home |
Main Index |
Thread Index |
Old Index