diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-12-04 13:42:49 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-12-04 13:42:49 +0000 |
commit | 3448a3234dbf36c8ac41908988f8aaa912309287 (patch) | |
tree | 42539a311fe1544ba78c2ff228a9dea04bea2b5e /sys/net | |
parent | a395839cdeabaade8cd242b2f98b8845584e1346 (diff) |
Move the KERNEL_LOCK from rt_match() to rtable_match().
ok claudio@
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/route.c | 7 | ||||
-rw-r--r-- | sys/net/rtable.c | 19 |
2 files changed, 15 insertions, 11 deletions
diff --git a/sys/net/route.c b/sys/net/route.c index c2ac0f59da3..a2a9c2a5a87 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.287 2015/12/03 21:57:59 mpi Exp $ */ +/* $OpenBSD: route.c,v 1.288 2015/12/04 13:42:48 mpi Exp $ */ /* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */ /* @@ -240,15 +240,14 @@ rt_match(struct sockaddr *dst, uint32_t *src, int flags, unsigned int tableid) info.rti_info[RTAX_DST] = dst; s = splsoftnet(); - KERNEL_LOCK(); rt = rtable_match(tableid, dst, src); if (rt != NULL) { if ((rt->rt_flags & RTF_CLONING) && ISSET(flags, RT_RESOLVE)) { rt0 = rt; + KERNEL_LOCK(); error = rtrequest(RTM_RESOLVE, &info, RTP_DEFAULT, &rt, tableid); if (error) { - rt0->rt_use++; rt_missmsg(RTM_MISS, &info, 0, 0, error, tableid); } else { @@ -256,11 +255,11 @@ rt_match(struct sockaddr *dst, uint32_t *src, int flags, unsigned int tableid) rt_sendmsg(rt, RTM_ADD, tableid); rtfree(rt0); } + KERNEL_UNLOCK(); } rt->rt_use++; } else rtstat.rts_unreach++; - KERNEL_UNLOCK(); splx(s); return (rt); } diff --git a/sys/net/rtable.c b/sys/net/rtable.c index eed2dd77c2f..9b7b750feeb 100644 --- a/sys/net/rtable.c +++ b/sys/net/rtable.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtable.c,v 1.32 2015/12/03 21:57:59 mpi Exp $ */ +/* $OpenBSD: rtable.c,v 1.33 2015/12/04 13:42:48 mpi Exp $ */ /* * Copyright (c) 2014-2015 Martin Pieuchot @@ -348,15 +348,16 @@ rtable_match(unsigned int rtableid, struct sockaddr *dst, uint32_t *src) { struct radix_node_head *rnh; struct radix_node *rn; - struct rtentry *rt; + struct rtentry *rt = NULL; rnh = rtable_get(rtableid, dst->sa_family); if (rnh == NULL) return (NULL); + KERNEL_LOCK(); rn = rn_match(dst, rnh); if (rn == NULL || (rn->rn_flags & RNF_ROOT) != 0) - return (NULL); + goto out; rt = ((struct rtentry *)rn); rtref(rt); @@ -364,7 +365,8 @@ rtable_match(unsigned int rtableid, struct sockaddr *dst, uint32_t *src) #ifndef SMALL_KERNEL rt = rtable_mpath_select(rt, src); #endif /* SMALL_KERNEL */ - +out: + KERNEL_UNLOCK(); return (rt); } @@ -595,7 +597,7 @@ rtable_match(unsigned int rtableid, struct sockaddr *dst, uint32_t *src) { struct art_root *ar; struct art_node *an; - struct rtentry *rt; + struct rtentry *rt = NULL; struct srpl_iter i; uint8_t *addr; @@ -604,9 +606,11 @@ rtable_match(unsigned int rtableid, struct sockaddr *dst, uint32_t *src) return (NULL); addr = satoaddr(ar, dst); + + KERNEL_LOCK(); an = art_match(ar, addr); if (an == NULL) - return (NULL); + goto out; rt = SRPL_ENTER(&an->an_rtlist, &i); rtref(rt); @@ -615,7 +619,8 @@ rtable_match(unsigned int rtableid, struct sockaddr *dst, uint32_t *src) #ifndef SMALL_KERNEL rt = rtable_mpath_select(rt, src); #endif /* SMALL_KERNEL */ - +out: + KERNEL_UNLOCK(); return (rt); } |