NetBSD-Bugs archive

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

Re: kern/57037: unncessary and unwarranted RTM_NEWADDR for IPv6 routing messages



The following reply was made to PR kern/57037; it has been noted by GNATS.

From: Kengo NAKAHARA <k-nakahara%iij.ad.jp@localhost>
To: gnats-bugs%netbsd.org@localhost, kern-bug-people%netbsd.org@localhost, gnats-admin%netbsd.org@localhost,
        netbsd-bugs%netbsd.org@localhost, kardel%netbsd.org@localhost
Cc: 
Subject: Re: kern/57037: unncessary and unwarranted RTM_NEWADDR for IPv6
 routing messages
Date: Mon, 3 Oct 2022 13:48:41 +0900

 Hi,
 
 Could you try the following patch and command?
 ====================
 # sysctl -w net.inet6.ip6.param_rt_msg=0
 ====================
 
 If the behavior is what you want, I will commit the patch.
 
 ========== patch from ==========
 diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c
 index 9200150c568..01bb9aeeb60 100644
 --- a/sys/netinet6/in6.c
 +++ b/sys/netinet6/in6.c
 @@ -1065,6 +1065,8 @@ 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;
 +	int saved_flags;
   
   	KASSERT((iap == NULL && psref == NULL) ||
   	    (iap != NULL && psref != NULL));
 @@ -1186,6 +1188,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 (!ip6_param_rt_msg) {
 +		if (ia != NULL &&
 +		    sin6eq(&dst6, &ia->ia_dstaddr) &&
 +		    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 +1308,17 @@ in6_update_ifa1(struct ifnet *ifp, struct in6_aliasreq *ifra,
   		ia->ia6_lifetime.ia6t_preferred = time_uptime;
   	}
   
 +	if (!ip6_param_rt_msg) {
 +		/*
 +		 * 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..8737b4a4f6f 100644
 --- a/sys/netinet6/in6_proto.c
 +++ b/sys/netinet6/in6_proto.c
 @@ -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 */
 +bool ip6_param_rt_msg = true; /* Send rtm for not only new addr but also parmeters */
   
   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..0d6d14f8763 100644
 --- a/sys/netinet6/ip6_input.c
 +++ b/sys/netinet6/ip6_input.c
 @@ -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_BOOL, "param_rt_msg",
 +		       SYSCTL_DESCR("Send routing message for not only"
 +			   " new address but also parmeters"),
 +		       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..1a0d144568c 100644
 --- a/sys/netinet6/ip6_var.h
 +++ b/sys/netinet6/ip6_var.h
 @@ -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 bool	ip6_param_rt_msg;  /* Send rtm for not only new addr but also parmeters */
   
   
   extern struct socket *ip6_mrouter; 	/* multicast routing daemon */
 ========== patch to ==========
 
 
 Thanks,
 
 On 2022/10/01 0:00, Frank Kardel wrote:
 > The following reply was made to PR kern/57037; it has been noted by GNATS.
 > 
 > From: Frank Kardel <kardel%netbsd.org@localhost>
 > To: gnats-bugs%netbsd.org@localhost
 > Cc:
 > Subject: Re: kern/57037: unncessary and unwarranted RTM_NEWADDR for IPv6
 >   routing messages
 > Date: Fri, 30 Sep 2022 16:57:39 +0200
 > 
 >   Looking at route.h we have:
 >   
 >   #define RTM_NEWADDR     0x16    /* address being added to iface */
 >   #define RTM_DELADDR     0x17    /* address being removed from iface */
 >   #define RTM_CHGADDR     0x18    /* address properties changed */
 >   
 >   Wouldn't RTM_CHGADDR be more appropriate for address parameter updates
 >   when new new address is being added?
 >   
 >   Frank
 >   
 >   
 >   On 09/30/22 13:35, Joerg Sonnenberger wrote:
 >   > The following reply was made to PR kern/57037; it has been noted by GNATS.
 >   >
 >   > From: Joerg Sonnenberger <joerg%bec.de@localhost>
 >   > To: gnats-bugs%netbsd.org@localhost
 >   > Cc: kern-bug-people%netbsd.org@localhost, gnats-admin%netbsd.org@localhost,
 >   > 	netbsd-bugs%netbsd.org@localhost
 >   > Subject: Re: kern/57037: unncessary and unwarranted RTM_NEWADDR for IPv6
 >   >   routing messages
 >   > Date: Fri, 30 Sep 2022 13:31:42 +0200
 >   >
 >   >   Am Fri, Sep 30, 2022 at 09:25:01AM +0000 schrieb kardel%netbsd.org@localhost:
 >   >   > >How-To-Repeat:
 >   >   > 	let NetBSD autoconfigure IPv6 and watch "route monitor".
 >   >   >
 >   >   > RTM_NEWADDR: address being added to iface: len 120, pid 1709, metric 0, addrflags: 0x40<AUTOCONF>
 >   >   > sockaddrs: 0x34<NETMASK,IFP,IFA>
 >   >   >  ffff:ffff:ffff:ffff:: aa:00:00:00:00:01 xxxx:yyyy:zzzz:rrrr:ssss:tttt:uuuu:vvvv
 >   >   > got message of size 112 on Fri Sep 30 08:24:57 2022
 >   >   > #12: len 112, got message of size 120 on Fri Sep 30 08:24:57 2022
 >   >   > RTM_NEWADDR: address being added to iface: len 120, pid 1709, metric 0, addrflags: 0x40<AUTOCONF>
 >   >   > sockaddrs: 0x34<NETMASK,IFP,IFA>
 >   >   >  ffff:ffff:ffff:ffff:: aa:00:00:00:00:01 xxxx:yyyy:zzzz:rrrr:ssss:tttt:uuuu:vvvv
 >   >   > got message of size 112 on Fri Sep 30 08:26:58 2022
 >   >
 >   >   So what is the life time of the addresses? Are you sure your network
 >   >   isn't forcing a renewal every minute?
 >   >
 >   >   Joerg
 >   >
 >   
 
 -- 
 //////////////////////////////////////////////////////////////////////
 Internet Initiative Japan Inc.
 
 Device Engineering Section,
 Product Division,
 Technology Unit
 
 Kengo NAKAHARA <k-nakahara%iij.ad.jp@localhost>
 
 


Home | Main Index | Thread Index | Old Index