Module Name: src
Committed By: knakahara
Date: Tue Aug 2 04:50:16 UTC 2016
Modified Files:
src/sys/netinet6: files.netinet6 ip6_flow.c ip6_input.c
Log Message:
ip6flow refactor like ipflow.
- move ip6flow sysctls into ip6_flow.c like ip_flow.c:r1.64
- build ip6_flow.c only if GATEWAY kernel option is enabled
To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/netinet6/files.netinet6
cvs rdiff -u -r1.29 -r1.30 src/sys/netinet6/ip6_flow.c
cvs rdiff -u -r1.165 -r1.166 src/sys/netinet6/ip6_input.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/files.netinet6
diff -u src/sys/netinet6/files.netinet6:1.11 src/sys/netinet6/files.netinet6:1.12
--- src/sys/netinet6/files.netinet6:1.11 Tue Oct 13 21:28:35 2015
+++ src/sys/netinet6/files.netinet6 Tue Aug 2 04:50:16 2016
@@ -1,4 +1,4 @@
-# $NetBSD: files.netinet6,v 1.11 2015/10/13 21:28:35 rjs Exp $
+# $NetBSD: files.netinet6,v 1.12 2016/08/02 04:50:16 knakahara Exp $
defflag opt_inet6.h RFC2292
@@ -15,7 +15,7 @@ file netinet6/in6_pcb.c inet6
file netinet6/in6_print.c
file netinet6/in6_proto.c inet6
file netinet6/in6_src.c inet6
-file netinet6/ip6_flow.c inet6
+file netinet6/ip6_flow.c inet6 & gateway
file netinet6/ip6_forward.c inet6
file netinet6/ip6_id.c inet6
file netinet6/ip6_input.c inet6
Index: src/sys/netinet6/ip6_flow.c
diff -u src/sys/netinet6/ip6_flow.c:1.29 src/sys/netinet6/ip6_flow.c:1.30
--- src/sys/netinet6/ip6_flow.c:1.29 Tue Jul 26 05:53:30 2016
+++ src/sys/netinet6/ip6_flow.c Tue Aug 2 04:50:16 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: ip6_flow.c,v 1.29 2016/07/26 05:53:30 ozaki-r Exp $ */
+/* $NetBSD: ip6_flow.c,v 1.30 2016/08/02 04:50:16 knakahara Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip6_flow.c,v 1.29 2016/07/26 05:53:30 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_flow.c,v 1.30 2016/08/02 04:50:16 knakahara Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -106,6 +106,10 @@ static void ip6flow_slowtimo_work(struct
static struct workqueue *ip6flow_slowtimo_wq;
static struct work ip6flow_slowtimo_wk;
+static int sysctl_net_inet6_ip6_hashsize(SYSCTLFN_PROTO);
+static int sysctl_net_inet6_ip6_maxflows(SYSCTLFN_PROTO);
+static void ip6flow_sysctl_init(struct sysctllog **);
+
/*
* Insert an ip6flow into the list.
*/
@@ -235,6 +239,7 @@ ip6flow_init(int table_size)
mutex_enter(&ip6flow_lock);
ret = ip6flow_init_locked(table_size);
mutex_exit(&ip6flow_lock);
+ ip6flow_sysctl_init(NULL);
return ret;
}
@@ -618,3 +623,94 @@ ip6flow_invalidate_all(int new_size)
return error;
}
+
+/*
+ * sysctl helper routine for net.inet.ip6.maxflows. Since
+ * we could reduce this value, call ip6flow_reap();
+ */
+static int
+sysctl_net_inet6_ip6_maxflows(SYSCTLFN_ARGS)
+{
+ int error;
+
+ error = sysctl_lookup(SYSCTLFN_CALL(rnode));
+ if (error || newp == NULL)
+ return (error);
+
+ mutex_enter(softnet_lock);
+ KERNEL_LOCK(1, NULL);
+
+ ip6flow_reap(0);
+
+ KERNEL_UNLOCK_ONE(NULL);
+ mutex_exit(softnet_lock);
+
+ return (0);
+}
+
+static int
+sysctl_net_inet6_ip6_hashsize(SYSCTLFN_ARGS)
+{
+ int error, tmp;
+ struct sysctlnode node;
+
+ node = *rnode;
+ tmp = ip6_hashsize;
+ node.sysctl_data = &tmp;
+ error = sysctl_lookup(SYSCTLFN_CALL(&node));
+ if (error || newp == NULL)
+ return (error);
+
+ if ((tmp & (tmp - 1)) == 0 && tmp != 0) {
+ /*
+ * Can only fail due to malloc()
+ */
+ mutex_enter(softnet_lock);
+ KERNEL_LOCK(1, NULL);
+
+ error = ip6flow_invalidate_all(tmp);
+
+ KERNEL_UNLOCK_ONE(NULL);
+ mutex_exit(softnet_lock);
+ } else {
+ /*
+ * EINVAL if not a power of 2
+ */
+ error = EINVAL;
+ }
+
+ return error;
+}
+
+static void
+ip6flow_sysctl_init(struct sysctllog **clog)
+{
+
+ sysctl_createv(clog, 0, NULL, NULL,
+ CTLFLAG_PERMANENT,
+ CTLTYPE_NODE, "inet6",
+ SYSCTL_DESCR("PF_INET6 related settings"),
+ NULL, 0, NULL, 0,
+ CTL_NET, PF_INET6, CTL_EOL);
+ sysctl_createv(clog, 0, NULL, NULL,
+ CTLFLAG_PERMANENT,
+ CTLTYPE_NODE, "ip6",
+ SYSCTL_DESCR("IPv6 related settings"),
+ NULL, 0, NULL, 0,
+ CTL_NET, PF_INET6, IPPROTO_IPV6, CTL_EOL);
+
+ sysctl_createv(clog, 0, NULL, NULL,
+ CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+ CTLTYPE_INT, "maxflows",
+ SYSCTL_DESCR("Number of flows for fast forwarding (IPv6)"),
+ sysctl_net_inet6_ip6_maxflows, 0, &ip6_maxflows, 0,
+ CTL_NET, PF_INET6, IPPROTO_IPV6,
+ CTL_CREATE, CTL_EOL);
+ sysctl_createv(clog, 0, NULL, NULL,
+ CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+ CTLTYPE_INT, "hashsize",
+ SYSCTL_DESCR("Size of hash table for fast forwarding (IPv6)"),
+ sysctl_net_inet6_ip6_hashsize, 0, &ip6_hashsize, 0,
+ CTL_NET, PF_INET6, IPPROTO_IPV6,
+ CTL_CREATE, CTL_EOL);
+}
Index: src/sys/netinet6/ip6_input.c
diff -u src/sys/netinet6/ip6_input.c:1.165 src/sys/netinet6/ip6_input.c:1.166
--- src/sys/netinet6/ip6_input.c:1.165 Mon Aug 1 03:15:31 2016
+++ src/sys/netinet6/ip6_input.c Tue Aug 2 04:50:16 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: ip6_input.c,v 1.165 2016/08/01 03:15:31 ozaki-r Exp $ */
+/* $NetBSD: ip6_input.c,v 1.166 2016/08/02 04:50:16 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.165 2016/08/01 03:15:31 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.166 2016/08/02 04:50:16 knakahara Exp $");
#ifdef _KERNEL_OPT
#include "opt_gateway.h"
@@ -1530,66 +1530,6 @@ ip6_delaux(struct mbuf *m)
m_tag_delete(m, mtag);
}
-#ifdef GATEWAY
-/*
- * sysctl helper routine for net.inet.ip6.maxflows. Since
- * we could reduce this value, call ip6flow_reap();
- */
-static int
-sysctl_net_inet6_ip6_maxflows(SYSCTLFN_ARGS)
-{
- int error;
-
- error = sysctl_lookup(SYSCTLFN_CALL(rnode));
- if (error || newp == NULL)
- return (error);
-
- mutex_enter(softnet_lock);
- KERNEL_LOCK(1, NULL);
-
- ip6flow_reap(0);
-
- KERNEL_UNLOCK_ONE(NULL);
- mutex_exit(softnet_lock);
-
- return (0);
-}
-
-static int
-sysctl_net_inet6_ip6_hashsize(SYSCTLFN_ARGS)
-{
- int error, tmp;
- struct sysctlnode node;
-
- node = *rnode;
- tmp = ip6_hashsize;
- node.sysctl_data = &tmp;
- error = sysctl_lookup(SYSCTLFN_CALL(&node));
- if (error || newp == NULL)
- return (error);
-
- if ((tmp & (tmp - 1)) == 0 && tmp != 0) {
- /*
- * Can only fail due to malloc()
- */
- mutex_enter(softnet_lock);
- KERNEL_LOCK(1, NULL);
-
- error = ip6flow_invalidate_all(tmp);
-
- KERNEL_UNLOCK_ONE(NULL);
- mutex_exit(softnet_lock);
- } else {
- /*
- * EINVAL if not a power of 2
- */
- error = EINVAL;
- }
-
- return error;
-}
-#endif /* GATEWAY */
-
/*
* System control for IP6
*/
@@ -1908,22 +1848,6 @@ sysctl_net_inet6_ip6_setup(struct sysctl
NULL, 0, &ip6_mcast_pmtu, 0,
CTL_NET, PF_INET6, IPPROTO_IPV6,
CTL_CREATE, CTL_EOL);
-#ifdef GATEWAY
- sysctl_createv(clog, 0, NULL, NULL,
- CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
- CTLTYPE_INT, "maxflows",
- SYSCTL_DESCR("Number of flows for fast forwarding (IPv6)"),
- sysctl_net_inet6_ip6_maxflows, 0, &ip6_maxflows, 0,
- CTL_NET, PF_INET6, IPPROTO_IPV6,
- CTL_CREATE, CTL_EOL);
- sysctl_createv(clog, 0, NULL, NULL,
- CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
- CTLTYPE_INT, "hashsize",
- SYSCTL_DESCR("Size of hash table for fast forwarding (IPv6)"),
- sysctl_net_inet6_ip6_hashsize, 0, &ip6_hashsize, 0,
- CTL_NET, PF_INET6, IPPROTO_IPV6,
- CTL_CREATE, CTL_EOL);
-#endif
/* anonportalgo RFC6056 subtree */
const struct sysctlnode *portalgo_node;
sysctl_createv(clog, 0, NULL, &portalgo_node,