-/* $OpenBSD: route.c,v 1.201 2015/01/21 21:32:42 bluhm Exp $ */
+/* $OpenBSD: route.c,v 1.202 2015/01/26 11:36:38 mpi Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
rt_missmsg(RTM_DELETE, &info, info.rti_flags, ifp, error, tableid);
- /* Adjust the refcount */
- if (error == 0 && rt->rt_refcnt <= 0) {
- rt->rt_refcnt++;
- rtfree(rt);
- }
return (error);
}
rtflushclone1(struct radix_node *rn, void *arg, u_int id)
{
struct rtentry *rt, *parent;
+ int error;
rt = (struct rtentry *)rn;
parent = (struct rtentry *)arg;
- if ((rt->rt_flags & RTF_CLONED) != 0 && rt->rt_parent == parent)
- rtdeletemsg(rt, id);
+ if ((rt->rt_flags & RTF_CLONED) != 0 && rt->rt_parent == parent) {
+ error = rtdeletemsg(rt, id);
+
+ /* Adjust the refcount */
+ if (error == 0 && rt->rt_refcnt <= 0) {
+ rt->rt_refcnt++;
+ rtfree(rt);
+ }
+ }
return 0;
}
if (rt->rt_ifp == ifp) {
int cloning = (rt->rt_flags & RTF_CLONING);
- if (rtdeletemsg(rt, id) == 0 && cloning)
- return (EAGAIN);
+ if (rtdeletemsg(rt, id) == 0) {
+
+ /* Adjust the refcount */
+ if (rt->rt_refcnt <= 0) {
+ rt->rt_refcnt++;
+ rtfree(rt);
+ }
+
+ if (cloning)
+ return (EAGAIN);
+ }
}
/*
-/* $OpenBSD: if_ether.c,v 1.141 2015/01/13 12:16:18 mpi Exp $ */
+/* $OpenBSD: if_ether.c,v 1.142 2015/01/26 11:36:38 mpi Exp $ */
/* $NetBSD: if_ether.c,v 1.31 1996/05/11 12:59:58 mycroft Exp $ */
/*
struct rtentry *rt = la->la_rt;
struct sockaddr_dl *sdl;
u_int tid = 0;
+ int error;
if (rt == NULL)
panic("arptfree");
if (rt->rt_ifp)
tid = rt->rt_ifp->if_rdomain;
- rtdeletemsg(rt, tid);
+ error = rtdeletemsg(rt, tid);
+
+ /* Adjust the refcount */
+ if (error == 0 && rt->rt_refcnt <= 0) {
+ rt->rt_refcnt++;
+ rtfree(rt);
+ }
}
/*