summaryrefslogtreecommitdiff
path: root/sys/net/route.c
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.c
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.c')
-rw-r--r--sys/net/route.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/net/route.c b/sys/net/route.c
index 6f5cb089aec..d6dcc3110d2 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.414 2022/08/29 07:51:45 bluhm Exp $ */
+/* $OpenBSD: route.c,v 1.415 2023/01/21 17:35:01 mvs Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
@@ -113,6 +113,7 @@
#include <sys/queue.h>
#include <sys/pool.h>
#include <sys/atomic.h>
+#include <sys/rwlock.h>
#include <net/if.h>
#include <net/if_var.h>
@@ -139,6 +140,8 @@
#define ROUNDUP(a) (a>0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
+struct rwlock rt_lock = RWLOCK_INITIALIZER("rtlck");
+
/* Give some jitter to hash, to avoid synchronization between routers. */
static uint32_t rt_hashjitter;
@@ -253,10 +256,10 @@ rt_clone(struct rtentry **rtp, struct sockaddr *dst, unsigned int rtableid)
* It should also be higher to let the ARP layer find
* cloned routes instead of the cloning one.
*/
- KERNEL_LOCK();
+ RT_LOCK();
error = rtrequest(RTM_RESOLVE, &info, rt->rt_priority - 1, &rt,
rtableid);
- KERNEL_UNLOCK();
+ RT_UNLOCK();
if (error) {
rtm_miss(RTM_MISS, &info, 0, RTP_NONE, 0, error, rtableid);
} else {