From owner-svn-src-head@FreeBSD.ORG Wed Mar 5 21:16:47 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 50B1AE09; Wed, 5 Mar 2014 21:16:47 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 3D2BCE92; Wed, 5 Mar 2014 21:16:47 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s25LGlxR007926; Wed, 5 Mar 2014 21:16:47 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s25LGkEq007924; Wed, 5 Mar 2014 21:16:46 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201403052116.s25LGkEq007924@svn.freebsd.org> From: Gleb Smirnoff Date: Wed, 5 Mar 2014 21:16:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r262806 - head/sys/net X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Mar 2014 21:16:47 -0000 Author: glebius Date: Wed Mar 5 21:16:46 2014 New Revision: 262806 URL: http://svnweb.freebsd.org/changeset/base/262806 Log: The route code used to mtx_destroy() a locked mutex before rtentry free. Now, after r262763 it started to return locked mutexes to UMA. To fix that, conditionally unlock the mutex in the destructor. Tested by: "Sergey V. Dyatko" Modified: head/sys/net/route.c head/sys/net/route.h Modified: head/sys/net/route.c ============================================================================== --- head/sys/net/route.c Wed Mar 5 20:01:04 2014 (r262805) +++ head/sys/net/route.c Wed Mar 5 21:16:46 2014 (r262806) @@ -237,6 +237,14 @@ rtentry_ctor(void *mem, int size, void * } 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 __unu 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) Modified: head/sys/net/route.h ============================================================================== --- head/sys/net/route.h Wed Mar 5 20:01:04 2014 (r262805) +++ head/sys/net/route.h Wed Mar 5 21:16:46 2014 (r262806) @@ -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); \