From owner-svn-src-projects@freebsd.org Thu Jun 30 17:16:23 2016 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B4D56B87CEA for ; Thu, 30 Jun 2016 17:16:23 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7865C2CBE; Thu, 30 Jun 2016 17:16:23 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5UHGMTD043007; Thu, 30 Jun 2016 17:16:22 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5UHGMQm043006; Thu, 30 Jun 2016 17:16:22 GMT (envelope-from bz@FreeBSD.org) Message-Id: <201606301716.u5UHGMQm043006@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Thu, 30 Jun 2016 17:16:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r302300 - projects/vnet/sys/netpfil/ipfw X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Jun 2016 17:16:23 -0000 Author: bz Date: Thu Jun 30 17:16:22 2016 New Revision: 302300 URL: https://svnweb.freebsd.org/changeset/base/302300 Log: In case of the global eventhandler make sure the current VNET is still operational before doing any work; otherwise we might run into, e.g., released locks. PR: 210724 Reported by: olevole olevole.ru Sponsored by: The FreeBSD Foundation Modified: projects/vnet/sys/netpfil/ipfw/ip_fw_nat.c Modified: projects/vnet/sys/netpfil/ipfw/ip_fw_nat.c ============================================================================== --- projects/vnet/sys/netpfil/ipfw/ip_fw_nat.c Thu Jun 30 15:04:03 2016 (r302299) +++ projects/vnet/sys/netpfil/ipfw/ip_fw_nat.c Thu Jun 30 17:16:22 2016 (r302300) @@ -104,6 +104,10 @@ ifaddr_change(void *arg __unused, struct KASSERT(curvnet == ifp->if_vnet, ("curvnet(%p) differs from iface vnet(%p)", curvnet, ifp->if_vnet)); + + if (V_ipfw_vnet_ready == 0 || V_ipfw_nat_ready == 0) + return; + chain = &V_layer3_chain; IPFW_UH_WLOCK(chain); /* Check every nat entry... */ @@ -1145,12 +1149,12 @@ vnet_ipfw_nat_uninit(const void *arg __u chain = &V_layer3_chain; IPFW_WLOCK(chain); + V_ipfw_nat_ready = 0; LIST_FOREACH_SAFE(ptr, &chain->nat, _next, ptr_temp) { LIST_REMOVE(ptr, _next); free_nat_instance(ptr); } flush_nat_ptrs(chain, -1 /* flush all */); - V_ipfw_nat_ready = 0; IPFW_WUNLOCK(chain); return (0); }