Module Name:    src
Committed By:   bouyer
Date:           Sun Nov 15 17:49:31 UTC 2015

Modified Files:
        src/sys/netinet6 [netbsd-6]: icmp6.c

Log Message:
Pull up following revision(s) (requested by ozaki-r in ticket #1327):
        sys/netinet6/icmp6.c: revision 1.177
Update icmp6_redirect_timeout_q when changing net.inet6.icmp6.redirtimeout
We have to update icmp6_redirect_timeout_q as well as icmp6_redirtimeout
when changing net.inet6.icmp6.redirtimeout via sysctl. The updating logic
is copied from sysctl_net_inet_icmp_redirtimeout.
This change is from s-yamaguchi@IIJ (with KNF by ozaki-r) and fixes
PR kern/50240.


To generate a diff of this commit:
cvs rdiff -u -r1.159.2.1 -r1.159.2.2 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/sys/netinet6/icmp6.c
diff -u src/sys/netinet6/icmp6.c:1.159.2.1 src/sys/netinet6/icmp6.c:1.159.2.2
--- src/sys/netinet6/icmp6.c:1.159.2.1	Mon Jul  8 07:40:07 2013
+++ src/sys/netinet6/icmp6.c	Sun Nov 15 17:49:31 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: icmp6.c,v 1.159.2.1 2013/07/08 07:40:07 jdc Exp $	*/
+/*	$NetBSD: icmp6.c,v 1.159.2.2 2015/11/15 17:49:31 bouyer 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.159.2.1 2013/07/08 07:40:07 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.159.2.2 2015/11/15 17:49:31 bouyer Exp $");
 
 #include "opt_inet.h"
 #include "opt_ipsec.h"
@@ -2761,6 +2761,38 @@ sysctl_net_inet6_icmp6_stats(SYSCTLFN_AR
 	return (NETSTAT_SYSCTL(icmp6stat_percpu, ICMP6_NSTATS));
 }
 
+static int
+sysctl_net_inet6_icmp6_redirtimeout(SYSCTLFN_ARGS)
+{
+	int error, tmp;
+	struct sysctlnode node;
+
+	node = *rnode;
+	node.sysctl_data = &tmp;
+	tmp = icmp6_redirtimeout;
+	error = sysctl_lookup(SYSCTLFN_CALL(&node));
+	if (error || newp == NULL)
+		return error;
+	if (tmp < 0)
+		return EINVAL;
+	icmp6_redirtimeout = tmp;
+
+	if (icmp6_redirect_timeout_q != NULL) {
+		if (icmp6_redirtimeout == 0) {
+			rt_timer_queue_destroy(icmp6_redirect_timeout_q,
+			    true);
+		} else {
+			rt_timer_queue_change(icmp6_redirect_timeout_q,
+			    icmp6_redirtimeout);
+		}
+	} else if (icmp6_redirtimeout > 0) {
+		icmp6_redirect_timeout_q =
+		    rt_timer_queue_create(icmp6_redirtimeout);
+	}
+
+	return 0;
+}
+
 static void
 sysctl_net_inet6_icmp6_setup(struct sysctllog **clog)
 {
@@ -2801,7 +2833,8 @@ sysctl_net_inet6_icmp6_setup(struct sysc
 		       CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
 		       CTLTYPE_INT, "redirtimeout",
 		       SYSCTL_DESCR("Redirect generated route lifetime"),
-		       NULL, 0, &icmp6_redirtimeout, 0,
+		       sysctl_net_inet6_icmp6_redirtimeout, 0,
+		       &icmp6_redirtimeout, 0,
 		       CTL_NET, PF_INET6, IPPROTO_ICMPV6,
 		       ICMPV6CTL_REDIRTIMEOUT, CTL_EOL);
 #if 0 /* obsoleted */

Reply via email to