Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netinet6 ip6flow refactor like ipflow.
details: https://anonhg.NetBSD.org/src/rev/2b540ddb15a0
branches: trunk
changeset: 346767:2b540ddb15a0
user: knakahara <knakahara%NetBSD.org@localhost>
date: Tue Aug 02 04:50:16 2016 +0000
description:
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
diffstat:
sys/netinet6/files.netinet6 | 4 +-
sys/netinet6/ip6_flow.c | 100 +++++++++++++++++++++++++++++++++++++++++++-
sys/netinet6/ip6_input.c | 80 +----------------------------------
3 files changed, 102 insertions(+), 82 deletions(-)
diffs (258 lines):
diff -r dc5645e6aacd -r 2b540ddb15a0 sys/netinet6/files.netinet6
--- a/sys/netinet6/files.netinet6 Mon Aug 01 19:06:32 2016 +0000
+++ b/sys/netinet6/files.netinet6 Tue Aug 02 04:50:16 2016 +0000
@@ -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_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
diff -r dc5645e6aacd -r 2b540ddb15a0 sys/netinet6/ip6_flow.c
--- a/sys/netinet6/ip6_flow.c Mon Aug 01 19:06:32 2016 +0000
+++ b/sys/netinet6/ip6_flow.c Tue Aug 02 04:50:16 2016 +0000
@@ -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 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 @@
mutex_enter(&ip6flow_lock);
ret = ip6flow_init_locked(table_size);
mutex_exit(&ip6flow_lock);
+ ip6flow_sysctl_init(NULL);
return ret;
}
@@ -618,3 +623,94 @@
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);
+}
diff -r dc5645e6aacd -r 2b540ddb15a0 sys/netinet6/ip6_input.c
--- a/sys/netinet6/ip6_input.c Mon Aug 01 19:06:32 2016 +0000
+++ b/sys/netinet6/ip6_input.c Tue Aug 02 04:50:16 2016 +0000
@@ -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 @@
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 @@
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,
Home |
Main Index |
Thread Index |
Old Index