diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-01-26 11:36:39 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-01-26 11:36:39 +0000 |
commit | 2bdc6311b18ab319f7eb0a32ee1a512372c10d19 (patch) | |
tree | f452405feacd6ff99ccdc83c4828830872c30df3 /sys/netinet | |
parent | 95c40f9dcde3f9af00877121538b6dc4dcccb688 (diff) |
Do not always try to rtfree(9) route entries inside rtdeletemsg(9).
Instead check the error code returned by this function and let the
caller free the route entry when appropriate.
ok bluhm@
Diffstat (limited to 'sys/netinet')
-rw-r--r-- | sys/netinet/if_ether.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c index 01458833ac9..6ff4877f1cc 100644 --- a/sys/netinet/if_ether.c +++ b/sys/netinet/if_ether.c @@ -1,4 +1,4 @@ -/* $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 $ */ /* @@ -789,6 +789,7 @@ arptfree(struct llinfo_arp *la) struct rtentry *rt = la->la_rt; struct sockaddr_dl *sdl; u_int tid = 0; + int error; if (rt == NULL) panic("arptfree"); @@ -803,7 +804,13 @@ arptfree(struct llinfo_arp *la) 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); + } } /* |