Source-Changes-HG archive

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

[src/trunk]: src/sys/netinet6 Update icmp6_redirect_timeout_q when changing n...



details:   https://anonhg.NetBSD.org/src/rev/26e6118a6e4a
branches:  trunk
changeset: 810715:26e6118a6e4a
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Mon Sep 14 05:34:28 2015 +0000

description:
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.

diffstat:

 sys/netinet6/icmp6.c |  39 ++++++++++++++++++++++++++++++++++++---
 1 files changed, 36 insertions(+), 3 deletions(-)

diffs (67 lines):

diff -r 45008d585394 -r 26e6118a6e4a sys/netinet6/icmp6.c
--- a/sys/netinet6/icmp6.c      Mon Sep 14 05:22:56 2015 +0000
+++ b/sys/netinet6/icmp6.c      Mon Sep 14 05:34:28 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: icmp6.c,v 1.176 2015/08/31 06:25:15 ozaki-r Exp $      */
+/*     $NetBSD: icmp6.c,v 1.177 2015/09/14 05:34:28 ozaki-r 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.176 2015/08/31 06:25:15 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.177 2015/09/14 05:34:28 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -2767,6 +2767,38 @@
        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)
 {
@@ -2802,7 +2834,8 @@
                       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 */



Home | Main Index | Thread Index | Old Index