Thu Nov 5 20:36:03 2015 UTC ()
Pull up following revision(s) (requested by ozaki-r in ticket #982):
	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.


(riz)
diff -r1.169 -r1.169.2.1 src/sys/netinet6/icmp6.c

cvs diff -r1.169 -r1.169.2.1 src/sys/netinet6/icmp6.c (expand / switch to unified diff)

--- src/sys/netinet6/icmp6.c 2014/06/06 01:02:47 1.169
+++ src/sys/netinet6/icmp6.c 2015/11/05 20:36:03 1.169.2.1
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: icmp6.c,v 1.169 2014/06/06 01:02:47 rmind Exp $ */ 1/* $NetBSD: icmp6.c,v 1.169.2.1 2015/11/05 20:36:03 riz Exp $ */
2/* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */ 2/* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */
3 3
4/* 4/*
5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. 5 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -52,27 +52,27 @@ @@ -52,27 +52,27 @@
52 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 52 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
53 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 53 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
54 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 54 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
55 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 55 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
56 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 56 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
57 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 57 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
58 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 58 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
59 * SUCH DAMAGE. 59 * SUCH DAMAGE.
60 * 60 *
61 * @(#)ip_icmp.c 8.2 (Berkeley) 1/4/94 61 * @(#)ip_icmp.c 8.2 (Berkeley) 1/4/94
62 */ 62 */
63 63
64#include <sys/cdefs.h> 64#include <sys/cdefs.h>
65__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.169 2014/06/06 01:02:47 rmind Exp $"); 65__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.169.2.1 2015/11/05 20:36:03 riz Exp $");
66 66
67#include "opt_inet.h" 67#include "opt_inet.h"
68#include "opt_ipsec.h" 68#include "opt_ipsec.h"
69 69
70#include <sys/param.h> 70#include <sys/param.h>
71#include <sys/systm.h> 71#include <sys/systm.h>
72#include <sys/kmem.h> 72#include <sys/kmem.h>
73#include <sys/mbuf.h> 73#include <sys/mbuf.h>
74#include <sys/protosw.h> 74#include <sys/protosw.h>
75#include <sys/socket.h> 75#include <sys/socket.h>
76#include <sys/socketvar.h> 76#include <sys/socketvar.h>
77#include <sys/time.h> 77#include <sys/time.h>
78#include <sys/kernel.h> 78#include <sys/kernel.h>
@@ -2746,26 +2746,58 @@ sysctl_net_inet6_icmp6_nd6(SYSCTLFN_ARGS @@ -2746,26 +2746,58 @@ sysctl_net_inet6_icmp6_nd6(SYSCTLFN_ARGS
2746 2746
2747 return (nd6_sysctl(rnode->sysctl_num, oldp, oldlenp, 2747 return (nd6_sysctl(rnode->sysctl_num, oldp, oldlenp,
2748 /*XXXUNCONST*/ 2748 /*XXXUNCONST*/
2749 __UNCONST(newp), newlen)); 2749 __UNCONST(newp), newlen));
2750} 2750}
2751 2751
2752static int 2752static int
2753sysctl_net_inet6_icmp6_stats(SYSCTLFN_ARGS) 2753sysctl_net_inet6_icmp6_stats(SYSCTLFN_ARGS)
2754{ 2754{
2755 2755
2756 return (NETSTAT_SYSCTL(icmp6stat_percpu, ICMP6_NSTATS)); 2756 return (NETSTAT_SYSCTL(icmp6stat_percpu, ICMP6_NSTATS));
2757} 2757}
2758 2758
 2759static int
 2760sysctl_net_inet6_icmp6_redirtimeout(SYSCTLFN_ARGS)
 2761{
 2762 int error, tmp;
 2763 struct sysctlnode node;
 2764
 2765 node = *rnode;
 2766 node.sysctl_data = &tmp;
 2767 tmp = icmp6_redirtimeout;
 2768 error = sysctl_lookup(SYSCTLFN_CALL(&node));
 2769 if (error || newp == NULL)
 2770 return error;
 2771 if (tmp < 0)
 2772 return EINVAL;
 2773 icmp6_redirtimeout = tmp;
 2774
 2775 if (icmp6_redirect_timeout_q != NULL) {
 2776 if (icmp6_redirtimeout == 0) {
 2777 rt_timer_queue_destroy(icmp6_redirect_timeout_q,
 2778 true);
 2779 } else {
 2780 rt_timer_queue_change(icmp6_redirect_timeout_q,
 2781 icmp6_redirtimeout);
 2782 }
 2783 } else if (icmp6_redirtimeout > 0) {
 2784 icmp6_redirect_timeout_q =
 2785 rt_timer_queue_create(icmp6_redirtimeout);
 2786 }
 2787
 2788 return 0;
 2789}
 2790
2759static void 2791static void
2760sysctl_net_inet6_icmp6_setup(struct sysctllog **clog) 2792sysctl_net_inet6_icmp6_setup(struct sysctllog **clog)
2761{ 2793{
2762 extern int nd6_maxqueuelen; /* defined in nd6.c */ 2794 extern int nd6_maxqueuelen; /* defined in nd6.c */
2763 2795
2764 sysctl_createv(clog, 0, NULL, NULL, 2796 sysctl_createv(clog, 0, NULL, NULL,
2765 CTLFLAG_PERMANENT, 2797 CTLFLAG_PERMANENT,
2766 CTLTYPE_NODE, "inet6", NULL, 2798 CTLTYPE_NODE, "inet6", NULL,
2767 NULL, 0, NULL, 0, 2799 NULL, 0, NULL, 0,
2768 CTL_NET, PF_INET6, CTL_EOL); 2800 CTL_NET, PF_INET6, CTL_EOL);
2769 sysctl_createv(clog, 0, NULL, NULL, 2801 sysctl_createv(clog, 0, NULL, NULL,
2770 CTLFLAG_PERMANENT, 2802 CTLFLAG_PERMANENT,
2771 CTLTYPE_NODE, "icmp6", 2803 CTLTYPE_NODE, "icmp6",
@@ -2781,27 +2813,28 @@ sysctl_net_inet6_icmp6_setup(struct sysc @@ -2781,27 +2813,28 @@ sysctl_net_inet6_icmp6_setup(struct sysc
2781 CTL_NET, PF_INET6, IPPROTO_ICMPV6, 2813 CTL_NET, PF_INET6, IPPROTO_ICMPV6,
2782 ICMPV6CTL_STATS, CTL_EOL); 2814 ICMPV6CTL_STATS, CTL_EOL);
2783 sysctl_createv(clog, 0, NULL, NULL, 2815 sysctl_createv(clog, 0, NULL, NULL,
2784 CTLFLAG_PERMANENT|CTLFLAG_READWRITE, 2816 CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
2785 CTLTYPE_INT, "rediraccept", 2817 CTLTYPE_INT, "rediraccept",
2786 SYSCTL_DESCR("Accept and process redirect messages"), 2818 SYSCTL_DESCR("Accept and process redirect messages"),
2787 NULL, 0, &icmp6_rediraccept, 0, 2819 NULL, 0, &icmp6_rediraccept, 0,
2788 CTL_NET, PF_INET6, IPPROTO_ICMPV6, 2820 CTL_NET, PF_INET6, IPPROTO_ICMPV6,
2789 ICMPV6CTL_REDIRACCEPT, CTL_EOL); 2821 ICMPV6CTL_REDIRACCEPT, CTL_EOL);
2790 sysctl_createv(clog, 0, NULL, NULL, 2822 sysctl_createv(clog, 0, NULL, NULL,
2791 CTLFLAG_PERMANENT|CTLFLAG_READWRITE, 2823 CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
2792 CTLTYPE_INT, "redirtimeout", 2824 CTLTYPE_INT, "redirtimeout",
2793 SYSCTL_DESCR("Redirect generated route lifetime"), 2825 SYSCTL_DESCR("Redirect generated route lifetime"),
2794 NULL, 0, &icmp6_redirtimeout, 0, 2826 sysctl_net_inet6_icmp6_redirtimeout, 0,
 2827 &icmp6_redirtimeout, 0,
2795 CTL_NET, PF_INET6, IPPROTO_ICMPV6, 2828 CTL_NET, PF_INET6, IPPROTO_ICMPV6,
2796 ICMPV6CTL_REDIRTIMEOUT, CTL_EOL); 2829 ICMPV6CTL_REDIRTIMEOUT, CTL_EOL);
2797#if 0 /* obsoleted */ 2830#if 0 /* obsoleted */
2798 sysctl_createv(clog, 0, NULL, NULL, 2831 sysctl_createv(clog, 0, NULL, NULL,
2799 CTLFLAG_PERMANENT|CTLFLAG_READWRITE, 2832 CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
2800 CTLTYPE_INT, "errratelimit", NULL, 2833 CTLTYPE_INT, "errratelimit", NULL,
2801 NULL, 0, &icmp6_errratelimit, 0, 2834 NULL, 0, &icmp6_errratelimit, 0,
2802 CTL_NET, PF_INET6, IPPROTO_ICMPV6, 2835 CTL_NET, PF_INET6, IPPROTO_ICMPV6,
2803 ICMPV6CTL_ERRRATELIMIT, CTL_EOL); 2836 ICMPV6CTL_ERRRATELIMIT, CTL_EOL);
2804#endif 2837#endif
2805 sysctl_createv(clog, 0, NULL, NULL, 2838 sysctl_createv(clog, 0, NULL, NULL,
2806 CTLFLAG_PERMANENT|CTLFLAG_READWRITE, 2839 CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
2807 CTLTYPE_INT, "nd6_prune", 2840 CTLTYPE_INT, "nd6_prune",