diff options
author | Vitaliy Makkoveev <mvs@cvs.openbsd.org> | 2023-01-21 17:35:02 +0000 |
---|---|---|
committer | Vitaliy Makkoveev <mvs@cvs.openbsd.org> | 2023-01-21 17:35:02 +0000 |
commit | 4267d7ffe6dd3e9693513b2c5cabec195a4b5605 (patch) | |
tree | 409db2b5c0bfd978bbf414bd3206f1563e9151f2 /sys/netinet/if_ether.c | |
parent | 2607d2257115c52a5705a9486935524b8a61cdc0 (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/netinet/if_ether.c')
-rw-r--r-- | sys/netinet/if_ether.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c index 6edb24bc6c0..7edc263361c 100644 --- a/sys/netinet/if_ether.c +++ b/sys/netinet/if_ether.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ether.c,v 1.252 2022/12/07 14:38:29 claudio Exp $ */ +/* $OpenBSD: if_ether.c,v 1.253 2023/01/21 17:35:01 mvs Exp $ */ /* $NetBSD: if_ether.c,v 1.31 1996/05/11 12:59:58 mycroft Exp $ */ /* @@ -412,16 +412,16 @@ arpresolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m, if (ifp->if_flags & (IFF_NOARP|IFF_STATICARP)) goto bad; - KERNEL_LOCK(); + RT_LOCK(); /* - * Re-check since we grab the kernel lock after the first check. + * Re-check since we grab the route lock after the first check. * rtrequest_delete() can be called with shared netlock. From * there arp_rtrequest() is reached which touches RTF_LLINFO - * and rt_llinfo. As this is called with kernel lock we grab the - * kernel lock here and are safe. XXXSMP + * and rt_llinfo. As this is called with route lock we grab the + * route lock here and are safe. XXXSMP */ if (!ISSET(rt->rt_flags, RTF_LLINFO)) { - KERNEL_UNLOCK(); + RT_UNLOCK(); goto bad; } la = (struct llinfo_arp *)rt->rt_llinfo; @@ -471,7 +471,7 @@ arpresolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m, } } - KERNEL_UNLOCK(); + RT_UNLOCK(); return (EAGAIN); bad: @@ -611,9 +611,9 @@ in_arpinput(struct ifnet *ifp, struct mbuf *m) } else if (rt != NULL) { int error; - KERNEL_LOCK(); + RT_LOCK(); error = arpcache(ifp, ea, rt); - KERNEL_UNLOCK(); + RT_UNLOCK(); if (error) goto out; } @@ -659,7 +659,7 @@ arpcache(struct ifnet *ifp, struct ether_arp *ea, struct rtentry *rt) unsigned int len; int changed = 0; - KERNEL_ASSERT_LOCKED(); + RT_ASSERT_LOCKED(); KASSERT(sdl != NULL); /* |