diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-09-12 09:22:30 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-09-12 09:22:30 +0000 |
commit | 7ee7ef8f234a0311e99d8f24cb4374c580bce2e5 (patch) | |
tree | f3c6a5021d44adb8e3251ea21599e630ed248440 /sys/net/route.c | |
parent | e26acc52a1c04f4c5156c22b54ddd225385d7174 (diff) |
Use rtref(9) in rtable_match() before returning a route entry.
ok bluhm@, claudio@
Diffstat (limited to 'sys/net/route.c')
-rw-r--r-- | sys/net/route.c | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/sys/net/route.c b/sys/net/route.c index 0a8d63358b1..7a3cd332ccc 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.237 2015/09/11 20:03:40 mpi Exp $ */ +/* $OpenBSD: route.c,v 1.238 2015/09/12 09:22:29 mpi Exp $ */ /* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */ /* @@ -336,32 +336,26 @@ rtisvalid(struct rtentry *rt) struct rtentry * rtalloc(struct sockaddr *dst, int flags, unsigned int tableid) { - struct rtentry *rt; - struct rtentry *newrt = NULL; + struct rtentry *rt0, *rt = NULL; struct rt_addrinfo info; int s, error = 0; - s = splsoftnet(); - bzero(&info, sizeof(info)); info.rti_info[RTAX_DST] = dst; + s = splsoftnet(); rt = rtable_match(tableid, dst); if (rt != NULL) { - newrt = rt; if ((rt->rt_flags & RTF_CLONING) && ISSET(flags, RT_RESOLVE)) { + rt0 = rt; error = rtrequest1(RTM_RESOLVE, &info, RTP_DEFAULT, - &newrt, tableid); - if (error) { - newrt = rt; - rt->rt_refcnt++; + &rt, tableid); + if (error) goto miss; - } - rt = newrt; /* Inform listeners of the new route */ rt_sendmsg(rt, RTM_ADD, tableid); - } else - rt->rt_refcnt++; + rtfree(rt0); + } } else { rtstat.rts_unreach++; miss: @@ -369,7 +363,7 @@ miss: rt_missmsg(RTM_MISS, &info, 0, NULL, error, tableid); } splx(s); - return (newrt); + return (rt); } #ifndef SMALL_KERNEL |