summaryrefslogtreecommitdiff
path: root/sys/netinet6
diff options
context:
space:
mode:
authorknakahara <knakahara@NetBSD.org>2022-10-24 01:54:19 +0000
committerknakahara <knakahara@NetBSD.org>2022-10-24 01:54:19 +0000
commit6ea0d486db60ccb3673766660608d26d1287a5a9 (patch)
treef59f1f06cd4ae70718e0494f3ce6b82cbc71ca7f /sys/netinet6
parent0b8a8645768f4d367014312098e786b2934bdf18 (diff)
Fix PR kern/57037
Be able to change the behavior sending parameter changing routing messages. When set net.inet6.ip6.param_rt_msg=0, don't send parameter changing routing messages. When set net.inet6.ip6.param_rt_msg=1(default), send parameter changing routing messages by RTM_NEWADDR.
Diffstat (limited to 'sys/netinet6')
-rw-r--r--sys/netinet6/in6.c33
-rw-r--r--sys/netinet6/in6_proto.c5
-rw-r--r--sys/netinet6/ip6_input.c12
-rw-r--r--sys/netinet6/ip6_var.h3
4 files changed, 46 insertions, 7 deletions
diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c
index 9200150c568..562a882cf26 100644
--- a/sys/netinet6/in6.c
+++ b/sys/netinet6/in6.c
@@ -1,4 +1,4 @@
-/* $NetBSD: in6.c,v 1.286 2022/09/20 02:23:37 knakahara Exp $ */
+/* $NetBSD: in6.c,v 1.287 2022/10/24 01:54:19 knakahara Exp $ */
/* $KAME: in6.c,v 1.198 2001/07/18 09:12:38 itojun Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.286 2022/09/20 02:23:37 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6.c,v 1.287 2022/10/24 01:54:19 knakahara Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@@ -1065,6 +1065,9 @@ in6_update_ifa1(struct ifnet *ifp, struct in6_aliasreq *ifra,
int dad_delay, was_tentative;
struct in6_ifaddr *ia = iap ? *iap : NULL;
char ip6buf[INET6_ADDRSTRLEN];
+ bool addrmaskNotChanged = false;
+ bool send_rtm_newaddr = (ip6_param_rt_msg == 1);
+ int saved_flags;
KASSERT((iap == NULL && psref == NULL) ||
(iap != NULL && psref != NULL));
@@ -1186,6 +1189,21 @@ in6_update_ifa1(struct ifnet *ifp, struct in6_aliasreq *ifra,
return 0; /* there's nothing to do */
}
+#define sin6eq(a, b) \
+ ((a)->sin6_len == sizeof(struct sockaddr_in6) && \
+ (b)->sin6_len == sizeof(struct sockaddr_in6) && \
+ IN6_ARE_ADDR_EQUAL(&(a)->sin6_addr, &(b)->sin6_addr))
+
+ if (!send_rtm_newaddr) {
+ if (ia != NULL &&
+ sin6eq(&ifra->ifra_addr, &ia->ia_addr) &&
+ sin6eq(&ifra->ifra_prefixmask, &ia->ia_prefixmask)) {
+ addrmaskNotChanged = true;
+ saved_flags = ia->ia6_flags; /* check it later */
+ }
+ }
+#undef sin6eq
+
/*
* If this is a new address, allocate a new ifaddr and link it
* into chains.
@@ -1291,6 +1309,17 @@ in6_update_ifa1(struct ifnet *ifp, struct in6_aliasreq *ifra,
ia->ia6_lifetime.ia6t_preferred = time_uptime;
}
+ if (!send_rtm_newaddr) {
+ /*
+ * We will not send RTM_NEWADDR if the only difference between
+ * ia and ifra is preferred/valid lifetimes, because it is not
+ * very useful for userland programs to be notified of that
+ * changes.
+ */
+ if (addrmaskNotChanged && ia->ia6_flags == saved_flags)
+ return 0;
+ }
+
if (hostIsNew) {
/*
* We need a reference to ia before calling in6_ifinit.
diff --git a/sys/netinet6/in6_proto.c b/sys/netinet6/in6_proto.c
index da6dc661851..3bb8adbdb4b 100644
--- a/sys/netinet6/in6_proto.c
+++ b/sys/netinet6/in6_proto.c
@@ -1,4 +1,4 @@
-/* $NetBSD: in6_proto.c,v 1.129 2022/09/03 02:53:18 thorpej Exp $ */
+/* $NetBSD: in6_proto.c,v 1.130 2022/10/24 01:54:19 knakahara Exp $ */
/* $KAME: in6_proto.c,v 1.66 2000/10/10 15:35:47 itojun Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6_proto.c,v 1.129 2022/09/03 02:53:18 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_proto.c,v 1.130 2022/10/24 01:54:19 knakahara Exp $");
#ifdef _KERNEL_OPT
#include "opt_gateway.h"
@@ -551,6 +551,7 @@ int ip6_mcast_pmtu = 0; /* enable pMTU discovery for multicast? */
int ip6_v6only = 1;
int ip6_neighborgcthresh = 2048; /* Threshold # of NDP entries for GC */
int ip6_maxdynroutes = 4096; /* Max # of routes created via redirect */
+int ip6_param_rt_msg = 1; /* How to send parmeter changing rtm */
int ip6_keepfaith = 0;
time_t ip6_log_time = 0;
diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c
index e0db6596f89..64ffd8d6877 100644
--- a/sys/netinet6/ip6_input.c
+++ b/sys/netinet6/ip6_input.c
@@ -1,4 +1,4 @@
-/* $NetBSD: ip6_input.c,v 1.225 2022/09/02 03:50:00 thorpej Exp $ */
+/* $NetBSD: ip6_input.c,v 1.226 2022/10/24 01:54:19 knakahara Exp $ */
/* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */
/*
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.225 2022/09/02 03:50:00 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.226 2022/10/24 01:54:19 knakahara Exp $");
#ifdef _KERNEL_OPT
#include "opt_gateway.h"
@@ -1803,6 +1803,14 @@ sysctl_net_inet6_ip6_setup(struct sysctllog **clog)
NULL, 1, &ip6_maxdynroutes, 0,
CTL_NET, PF_INET6, IPPROTO_IPV6,
CTL_CREATE, CTL_EOL);
+ sysctl_createv(clog, 0, NULL, NULL,
+ CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+ CTLTYPE_INT, "param_rt_msg",
+ SYSCTL_DESCR("How to send parameter changing"
+ " routing message"),
+ NULL, 0, &ip6_param_rt_msg, 0,
+ CTL_NET, PF_INET6, IPPROTO_IPV6,
+ CTL_CREATE, CTL_EOL);
}
void
diff --git a/sys/netinet6/ip6_var.h b/sys/netinet6/ip6_var.h
index 6508e67e8f0..920055c4759 100644
--- a/sys/netinet6/ip6_var.h
+++ b/sys/netinet6/ip6_var.h
@@ -1,4 +1,4 @@
-/* $NetBSD: ip6_var.h,v 1.91 2021/08/17 22:00:32 andvar Exp $ */
+/* $NetBSD: ip6_var.h,v 1.92 2022/10/24 01:54:19 knakahara Exp $ */
/* $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $ */
/*
@@ -257,6 +257,7 @@ extern int ip6_mcast_pmtu; /* enable pMTU discovery for multicast? */
extern int ip6_v6only;
extern int ip6_neighborgcthresh; /* Threshold # of NDP entries for GC */
extern int ip6_maxdynroutes; /* Max # of routes created via redirect */
+extern int ip6_param_rt_msg; /* How to send parmeter changing rtm */
extern struct socket *ip6_mrouter; /* multicast routing daemon */