summaryrefslogtreecommitdiff
path: root/sys/netinet6
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2023-05-03 11:43:32 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2023-05-03 11:43:32 +0000
commitca6539afaacb2d2f1447113a6256cc4bc90e9a88 (patch)
treedbaf38b2c23c4a91f7d31b686b1e2bff4d6cb491 /sys/netinet6
parent8c9886e4a01a802adf9b69f96dbbc8efe18f5997 (diff)
Some checks in nd6_resolve() do not require kernel lock. The analog
code for ARP has been unlocked a while ago. OK kn@
Diffstat (limited to 'sys/netinet6')
-rw-r--r--sys/netinet6/nd6.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c
index a67096332d5..b3948beb8b8 100644
--- a/sys/netinet6/nd6.c
+++ b/sys/netinet6/nd6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nd6.c,v 1.273 2023/05/02 06:06:13 bluhm Exp $ */
+/* $OpenBSD: nd6.c,v 1.274 2023/05/03 11:43:31 bluhm Exp $ */
/* $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $ */
/*
@@ -1260,15 +1260,12 @@ nd6_resolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m,
return (0);
}
- /* XXXSMP there is a MP race in nd6_resolve() */
- KERNEL_LOCK();
uptime = getuptime();
rt = rt_getll(rt0);
if (ISSET(rt->rt_flags, RTF_REJECT) &&
(rt->rt_expire == 0 || rt->rt_expire > uptime)) {
m_freem(m);
- KERNEL_UNLOCK();
return (rt == rt0 ? EHOSTDOWN : EHOSTUNREACH);
}
@@ -1291,6 +1288,11 @@ nd6_resolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m,
goto bad;
}
+ KERNEL_LOCK();
+ if (!ISSET(rt->rt_flags, RTF_LLINFO)) {
+ KERNEL_UNLOCK();
+ goto bad;
+ }
ln = (struct llinfo_nd6 *)rt->rt_llinfo;
KASSERT(ln != NULL);
@@ -1321,6 +1323,8 @@ nd6_resolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m,
* send the packet.
*/
if (ln->ln_state > ND6_LLINFO_INCOMPLETE) {
+ KERNEL_UNLOCK();
+
sdl = satosdl(rt->rt_gateway);
if (sdl->sdl_alen != ETHER_ADDR_LEN) {
char addr[INET6_ADDRSTRLEN];
@@ -1332,7 +1336,6 @@ nd6_resolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m,
}
bcopy(LLADDR(sdl), desten, sdl->sdl_alen);
- KERNEL_UNLOCK();
return (0);
}
@@ -1374,7 +1377,6 @@ nd6_resolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m,
bad:
m_freem(m);
- KERNEL_UNLOCK();
return (EINVAL);
}