summaryrefslogtreecommitdiff
path: root/sys/net/route.h
diff options
context:
space:
mode:
authorVitaliy Makkoveev <mvs@cvs.openbsd.org>2023-01-21 17:35:02 +0000
committerVitaliy Makkoveev <mvs@cvs.openbsd.org>2023-01-21 17:35:02 +0000
commit4267d7ffe6dd3e9693513b2c5cabec195a4b5605 (patch)
tree409db2b5c0bfd978bbf414bd3206f1563e9151f2 /sys/net/route.h
parent2607d2257115c52a5705a9486935524b8a61cdc0 (diff)
Introduce `rt_lock' rwlock(9) and use it instead of kernel lock to
serialize arpcache() and arpresolve(). In fact, net stack already has sleep points, so the rwlock(9) is better here because we avoid intersection with the rest of kernel locked paths. Also this new lock assumed to use to route layer protection instead of netlock. Hrvoje Popovski had tested this diff and found no visible performance impact. ok bluhm@
Diffstat (limited to 'sys/net/route.h')
-rw-r--r--sys/net/route.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/net/route.h b/sys/net/route.h
index 2178e401731..4c0c38577dc 100644
--- a/sys/net/route.h
+++ b/sys/net/route.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.h,v 1.196 2022/06/28 10:01:13 bluhm Exp $ */
+/* $OpenBSD: route.h,v 1.197 2023/01/21 17:35:01 mvs Exp $ */
/* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */
/*
@@ -383,6 +383,13 @@ struct rt_addrinfo {
#ifdef _KERNEL
#include <sys/percpu.h>
+#include <sys/rwlock.h>
+
+extern struct rwlock rt_lock;
+
+#define RT_LOCK() rw_enter_write(&rt_lock)
+#define RT_UNLOCK() rw_exit_write(&rt_lock)
+#define RT_ASSERT_LOCKED() rw_assert_wrlock(&rt_lock)
enum rtstat_counters {
rts_badredirect, /* bogus redirect calls */