If the caller of rtrequest*(RTM_DELETE, ...) asked for a copy of
the entry being removed (ret_nrt != NULL), increment the entry's rt_refcnt like we do it for RTM_ADD and RTM_RESOLVE, rather than messing around with 1->0 transitions for rtfree() all over.
This commit is contained in:
parent
053e23428c
commit
71eba91593
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=108269
@ -566,6 +566,8 @@ rtrequest1(req, info, ret_nrt)
|
||||
if (rn->rn_flags & (RNF_ACTIVE | RNF_ROOT))
|
||||
panic ("rtrequest delete");
|
||||
rt = (struct rtentry *)rn;
|
||||
rt->rt_refcnt++;
|
||||
rt->rt_flags &= ~RTF_UP;
|
||||
|
||||
/*
|
||||
* Now search what's left of the subtree for any cloned
|
||||
@ -588,15 +590,6 @@ rtrequest1(req, info, ret_nrt)
|
||||
(rt = (struct rtentry *)rn)->rt_gwroute = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* NB: RTF_UP must be set during the search above,
|
||||
* because we might delete the last ref, causing
|
||||
* rt to get freed prematurely.
|
||||
* eh? then why not just add a reference?
|
||||
* I'm not sure how RTF_UP helps matters. (JRE)
|
||||
*/
|
||||
rt->rt_flags &= ~RTF_UP;
|
||||
|
||||
/*
|
||||
* give the protocol a chance to keep things in sync.
|
||||
*/
|
||||
@ -616,10 +609,8 @@ rtrequest1(req, info, ret_nrt)
|
||||
*/
|
||||
if (ret_nrt)
|
||||
*ret_nrt = rt;
|
||||
else if (rt->rt_refcnt <= 0) {
|
||||
rt->rt_refcnt++; /* make a 1->0 transition */
|
||||
rtfree(rt);
|
||||
}
|
||||
else
|
||||
RTFREE(rt);
|
||||
break;
|
||||
|
||||
case RTM_RESOLVE:
|
||||
@ -1137,10 +1128,7 @@ rtinit(ifa, cmd, flags)
|
||||
* If we are deleting, and we found an entry, then
|
||||
* it's been removed from the tree.. now throw it away.
|
||||
*/
|
||||
if (rt->rt_refcnt <= 0) {
|
||||
rt->rt_refcnt++; /* make a 1->0 transition */
|
||||
rtfree(rt);
|
||||
}
|
||||
RTFREE(rt);
|
||||
} else if (cmd == RTM_ADD) {
|
||||
/*
|
||||
* We just wanted to add it.. we don't actually
|
||||
|
@ -356,8 +356,7 @@ route_output(m, so)
|
||||
case RTM_DELETE:
|
||||
error = rtrequest1(RTM_DELETE, &info, &saved_nrt);
|
||||
if (error == 0) {
|
||||
if ((rt = saved_nrt))
|
||||
rt->rt_refcnt++;
|
||||
rt = saved_nrt;
|
||||
goto report;
|
||||
}
|
||||
break;
|
||||
|
@ -197,11 +197,7 @@ in6_ifloop_request(int cmd, struct ifaddr *ifa)
|
||||
if (nrt) {
|
||||
rt_newaddrmsg(cmd, ifa, e, nrt);
|
||||
if (cmd == RTM_DELETE) {
|
||||
if (nrt->rt_refcnt <= 0) {
|
||||
/* XXX: we should free the entry ourselves. */
|
||||
nrt->rt_refcnt++;
|
||||
rtfree(nrt);
|
||||
}
|
||||
RTFREE(nrt);
|
||||
} else {
|
||||
/* the cmd must be RTM_ADD here */
|
||||
nrt->rt_refcnt--;
|
||||
|
@ -574,14 +574,7 @@ defrouter_delreq(dr, dofree)
|
||||
RTF_GATEWAY, &oldrt);
|
||||
if (oldrt) {
|
||||
nd6_rtmsg(RTM_DELETE, oldrt);
|
||||
if (oldrt->rt_refcnt <= 0) {
|
||||
/*
|
||||
* XXX: borrowed from the RTM_DELETE case of
|
||||
* rtrequest().
|
||||
*/
|
||||
oldrt->rt_refcnt++;
|
||||
rtfree(oldrt);
|
||||
}
|
||||
RTFREE(oldrt);
|
||||
}
|
||||
|
||||
if (dofree) /* XXX: necessary? */
|
||||
@ -1583,13 +1576,8 @@ nd6_prefix_offlink(pr)
|
||||
error));
|
||||
}
|
||||
|
||||
if (rt != NULL) {
|
||||
if (rt->rt_refcnt <= 0) {
|
||||
/* XXX: we should free the entry ourselves. */
|
||||
rt->rt_refcnt++;
|
||||
rtfree(rt);
|
||||
}
|
||||
}
|
||||
if (rt != NULL)
|
||||
RTFREE(rt);
|
||||
|
||||
return(error);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user