diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-08-17 09:46:27 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-08-17 09:46:27 +0000 |
commit | de4fde5386bf63560a5c22cd6f69dbf741b6dd10 (patch) | |
tree | 5001fa9c75195dd3c61986ec4b97ee81918adecf | |
parent | 42caa7e7c2be90f8e46363bb0ad71b4746c8419d (diff) |
Convert two rt->rt_refcnt-- into rtfree(9) making sure the route entry
is freed when we no longer need it.
In this case both code paths are executed in process context and thus
serialized by the KERNEL_LOCK. Since we are adding a route entry to
the table in both cases, rtfree(9) will not actually free the entry
because it is still RT_VALID.
ok bluhm@
-rw-r--r-- | sys/net/route.c | 8 | ||||
-rw-r--r-- | sys/net/rtsock.c | 4 |
2 files changed, 6 insertions, 6 deletions
diff --git a/sys/net/route.c b/sys/net/route.c index bd95a7378db..f8fa97ca62b 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.218 2015/08/17 09:41:24 mpi Exp $ */ +/* $OpenBSD: route.c,v 1.219 2015/08/17 09:46:26 mpi Exp $ */ /* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */ /* @@ -1182,7 +1182,6 @@ rt_ifa_add(struct ifaddr *ifa, int flags, struct sockaddr *dst) error = rtrequest1(RTM_ADD, &info, prio, &nrt, rtableid); if (error == 0 && (rt = nrt) != NULL) { - rt->rt_refcnt--; if (rt->rt_ifa != ifa) { printf("%s: wrong ifa (%p) was (%p)\n", __func__, ifa, rt->rt_ifa); @@ -1202,8 +1201,9 @@ rt_ifa_add(struct ifaddr *ifa, int flags, struct sockaddr *dst) * userland that a new address has been added. */ if (flags & RTF_LOCAL) - rt_sendaddrmsg(nrt, RTM_NEWADDR); - rt_sendmsg(nrt, RTM_ADD, rtableid); + rt_sendaddrmsg(rt, RTM_NEWADDR); + rt_sendmsg(rt, RTM_ADD, rtableid); + rtfree(rt); } return (error); } diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 5183568d8d4..538f2c08cb8 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.166 2015/07/18 21:58:06 mpi Exp $ */ +/* $OpenBSD: rtsock.c,v 1.167 2015/08/17 09:46:26 mpi Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -598,11 +598,11 @@ route_output(struct mbuf *m, ...) if (error == 0 && saved_nrt) { rt_setmetrics(rtm->rtm_inits, &rtm->rtm_rmx, &saved_nrt->rt_rmx); - saved_nrt->rt_refcnt--; /* write back the priority the kernel used */ rtm->rtm_priority = saved_nrt->rt_priority & RTP_MASK; rtm->rtm_index = saved_nrt->rt_ifp->if_index; rtm->rtm_flags = saved_nrt->rt_flags; + rtfree(saved_nrt); } break; case RTM_DELETE: |