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.
This commit is contained in:
parent
ea450ca61b
commit
b54270a1ae
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: sysctl.7,v 1.161 2022/08/29 09:14:02 knakahara Exp $
|
||||
.\" $NetBSD: sysctl.7,v 1.162 2022/10/24 01:54:19 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 29, 2022
|
||||
.Dd October 24, 2022
|
||||
.Dt SYSCTL 7
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -1888,6 +1888,7 @@ The currently defined protocols and names are:
|
|||
.It ip6 maxfragpackets integer yes
|
||||
.It ip6 maxfrags integer yes
|
||||
.It ip6 neighborgcthresh integer yes
|
||||
.It ip6 param_rt_msg integer yes
|
||||
.It ip6 redirect integer yes
|
||||
.It ip6 rr_prune integer yes
|
||||
.It ip6 use_deprecated integer yes
|
||||
|
@ -2023,6 +2024,10 @@ The flag is provided basically for avoiding possible DoS attacks.
|
|||
Maximum number of entries in neighbor cache per interface.
|
||||
Set to negative to disable.
|
||||
The default value is 2048.
|
||||
.It Li ip6.param_rt_msg
|
||||
If set to 0, parameter changing routing message is suppressed.
|
||||
If set to 1, parameter changing routing message is sent by RTM_NEWADDR.
|
||||
Other values are undefined yet.
|
||||
.It Li ip6.redirect
|
||||
If set to 1, ICMPv6 redirects may be sent by the node.
|
||||
This option is ignored unless the node is routing IP packets,
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue