diff options
-rw-r--r-- | sys/net/route.c | 10 | ||||
-rw-r--r-- | sys/net/route.h | 4 |
2 files changed, 13 insertions, 1 deletions
diff --git a/sys/net/route.c b/sys/net/route.c index dd7d149..92875c7 100644 --- a/sys/net/route.c +++ b/sys/net/route.c @@ -237,6 +237,14 @@ rtentry_ctor(void *mem, int size, void *arg, int how) } static void +rtentry_dtor(void *mem, int size, void *arg) +{ + struct rtentry *rt = mem; + + RT_UNLOCK_COND(rt); +} + +static void vnet_route_init(const void *unused __unused) { struct domain *dom; @@ -248,7 +256,7 @@ vnet_route_init(const void *unused __unused) sizeof(struct radix_node_head *), M_RTABLE, M_WAITOK|M_ZERO); V_rtzone = uma_zcreate("rtentry", sizeof(struct rtentry), - rtentry_ctor, NULL, + rtentry_ctor, rtentry_dtor, rtentry_zinit, rtentry_zfini, UMA_ALIGN_PTR, 0); for (dom = domains; dom; dom = dom->dom_next) { if (dom->dom_rtattach == NULL) diff --git a/sys/net/route.h b/sys/net/route.h index 61f3b29..a4d2a1f 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -309,6 +309,10 @@ struct rt_addrinfo { #define RT_UNLOCK(_rt) mtx_unlock(&(_rt)->rt_mtx) #define RT_LOCK_DESTROY(_rt) mtx_destroy(&(_rt)->rt_mtx) #define RT_LOCK_ASSERT(_rt) mtx_assert(&(_rt)->rt_mtx, MA_OWNED) +#define RT_UNLOCK_COND(_rt) do { \ + if (mtx_owned(&(_rt)->rt_mtx)) \ + mtx_unlock(&(_rt)->rt_mtx); \ +} while (0) #define RT_ADDREF(_rt) do { \ RT_LOCK_ASSERT(_rt); \ |