Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Wrap ipflow_create() & ip6flow_create() in kernel lock. ...
details: https://anonhg.NetBSD.org/src/rev/6d01708c6890
branches: trunk
changeset: 328350:6d01708c6890
user: pooka <pooka%NetBSD.org@localhost>
date: Tue Apr 01 13:11:44 2014 +0000
description:
Wrap ipflow_create() & ip6flow_create() in kernel lock. Prevents the
interrupt side on another core from seeing the situation while the ipflow
is being modified.
diffstat:
sys/netinet/ip_flow.c | 12 +++++++++---
sys/netinet6/ip6_flow.c | 11 ++++++++---
2 files changed, 17 insertions(+), 6 deletions(-)
diffs (93 lines):
diff -r e782baad1ad9 -r 6d01708c6890 sys/netinet/ip_flow.c
--- a/sys/netinet/ip_flow.c Tue Apr 01 12:57:46 2014 +0000
+++ b/sys/netinet/ip_flow.c Tue Apr 01 13:11:44 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ip_flow.c,v 1.62 2014/03/19 10:54:20 liamjfoy Exp $ */
+/* $NetBSD: ip_flow.c,v 1.63 2014/04/01 13:11:44 pooka Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_flow.c,v 1.62 2014/03/19 10:54:20 liamjfoy Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_flow.c,v 1.63 2014/04/01 13:11:44 pooka Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -423,6 +423,9 @@
*/
if (ip_maxflows == 0 || ip->ip_p == IPPROTO_ICMP)
return;
+
+ KERNEL_LOCK(1, NULL);
+
/*
* See if an existing flow struct exists. If so remove it from it's
* list and free the old route. If not, try to malloc a new one
@@ -437,7 +440,7 @@
ipf = pool_get(&ipflow_pool, PR_NOWAIT);
splx(s);
if (ipf == NULL)
- return;
+ goto out;
ipflow_inuse++;
}
memset(ipf, 0, sizeof(*ipf));
@@ -467,6 +470,9 @@
s = splnet();
IPFLOW_INSERT(&ipflowtable[hash], ipf);
splx(s);
+
+ out:
+ KERNEL_UNLOCK_ONE(NULL);
}
int
diff -r e782baad1ad9 -r 6d01708c6890 sys/netinet6/ip6_flow.c
--- a/sys/netinet6/ip6_flow.c Tue Apr 01 12:57:46 2014 +0000
+++ b/sys/netinet6/ip6_flow.c Tue Apr 01 13:11:44 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ip6_flow.c,v 1.21 2013/05/23 16:49:46 msaitoh Exp $ */
+/* $NetBSD: ip6_flow.c,v 1.22 2014/04/01 13:11:44 pooka 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.21 2013/05/23 16:49:46 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_flow.c,v 1.22 2014/04/01 13:11:44 pooka Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -463,6 +463,8 @@
if (ip6_maxflows == 0 || ip6->ip6_nxt == IPPROTO_IPV6_ICMP)
return;
+ KERNEL_LOCK(1, NULL);
+
/*
* See if an existing flow exists. If so:
* - Remove the flow
@@ -481,7 +483,7 @@
} else {
ip6f = pool_get(&ip6flow_pool, PR_NOWAIT);
if (ip6f == NULL)
- return;
+ goto out;
ip6flow_inuse++;
}
memset(ip6f, 0, sizeof(*ip6f));
@@ -513,6 +515,9 @@
s = splnet();
IP6FLOW_INSERT(&ip6flowtable[hash], ip6f);
splx(s);
+
+ out:
+ KERNEL_UNLOCK_ONE(NULL);
}
/*
Home |
Main Index |
Thread Index |
Old Index