From owner-svn-src-all@freebsd.org Thu Jan 31 21:04:53 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4AE7814B7BC4; Thu, 31 Jan 2019 21:04:53 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E2D0671B6B; Thu, 31 Jan 2019 21:04:52 +0000 (UTC) (envelope-from glebius@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D8AE9D167; Thu, 31 Jan 2019 21:04:52 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x0VL4qKA034658; Thu, 31 Jan 2019 21:04:52 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x0VL4ob6034648; Thu, 31 Jan 2019 21:04:50 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201901312104.x0VL4ob6034648@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Thu, 31 Jan 2019 21:04:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r343619 - in head/sys: net netpfil/ipfw X-SVN-Group: head X-SVN-Commit-Author: glebius X-SVN-Commit-Paths: in head/sys: net netpfil/ipfw X-SVN-Commit-Revision: 343619 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: E2D0671B6B X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.98)[-0.981,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-0.999,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Jan 2019 21:04:53 -0000 Author: glebius Date: Thu Jan 31 21:04:50 2019 New Revision: 343619 URL: https://svnweb.freebsd.org/changeset/base/343619 Log: Revert r316461: Remove "IPFW static rules" rmlock, and use pfil's global lock. The pfil(9) system is about to be converted to epoch(9) synchronization, so we need [temporarily] go back with ipfw internal locking. Discussed with: ae Modified: head/sys/net/pfil.c head/sys/net/pfil.h head/sys/netpfil/ipfw/ip_fw2.c head/sys/netpfil/ipfw/ip_fw_dynamic.c head/sys/netpfil/ipfw/ip_fw_iface.c head/sys/netpfil/ipfw/ip_fw_nat.c head/sys/netpfil/ipfw/ip_fw_private.h head/sys/netpfil/ipfw/ip_fw_sockopt.c head/sys/netpfil/ipfw/ip_fw_table.c head/sys/netpfil/ipfw/ip_fw_table_value.c Modified: head/sys/net/pfil.c ============================================================================== --- head/sys/net/pfil.c Thu Jan 31 20:04:18 2019 (r343618) +++ head/sys/net/pfil.c Thu Jan 31 21:04:50 2019 (r343619) @@ -64,6 +64,7 @@ LIST_HEAD(pfilheadhead, pfil_head); VNET_DEFINE(struct pfilheadhead, pfil_head_list); #define V_pfil_head_list VNET(pfil_head_list) VNET_DEFINE(struct rmlock, pfil_lock); +#define V_pfil_lock VNET(pfil_lock) #define PFIL_LOCK_INIT_REAL(l, t) \ rm_init_flags(l, "PFil " t " rmlock", RM_RECURSE) Modified: head/sys/net/pfil.h ============================================================================== --- head/sys/net/pfil.h Thu Jan 31 20:04:18 2019 (r343618) +++ head/sys/net/pfil.h Thu Jan 31 21:04:50 2019 (r343619) @@ -40,7 +40,6 @@ #include #include #include -#include struct mbuf; struct ifnet; @@ -100,9 +99,6 @@ struct pfil_head { #define ph_ifnet ph_un.phu_ptr LIST_ENTRY(pfil_head) ph_list; }; - -VNET_DECLARE(struct rmlock, pfil_lock); -#define V_pfil_lock VNET(pfil_lock) /* Public functions for pfil hook management by packet filters. */ struct pfil_head *pfil_head_get(int, u_long); Modified: head/sys/netpfil/ipfw/ip_fw2.c ============================================================================== --- head/sys/netpfil/ipfw/ip_fw2.c Thu Jan 31 20:04:18 2019 (r343618) +++ head/sys/netpfil/ipfw/ip_fw2.c Thu Jan 31 21:04:50 2019 (r343619) @@ -1404,6 +1404,7 @@ ipfw_chk(struct ip_fw_args *args) int is_ipv4 = 0; int done = 0; /* flag to exit the outer loop */ + IPFW_RLOCK_TRACKER; if (m->m_flags & M_SKIP_FIREWALL || (! V_ipfw_vnet_ready)) return (IP_FW_PASS); /* accept */ Modified: head/sys/netpfil/ipfw/ip_fw_dynamic.c ============================================================================== --- head/sys/netpfil/ipfw/ip_fw_dynamic.c Thu Jan 31 20:04:18 2019 (r343618) +++ head/sys/netpfil/ipfw/ip_fw_dynamic.c Thu Jan 31 21:04:50 2019 (r343619) @@ -53,7 +53,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include Modified: head/sys/netpfil/ipfw/ip_fw_iface.c ============================================================================== --- head/sys/netpfil/ipfw/ip_fw_iface.c Thu Jan 31 20:04:18 2019 (r343618) +++ head/sys/netpfil/ipfw/ip_fw_iface.c Thu Jan 31 21:04:50 2019 (r343619) @@ -50,7 +50,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include Modified: head/sys/netpfil/ipfw/ip_fw_nat.c ============================================================================== --- head/sys/netpfil/ipfw/ip_fw_nat.c Thu Jan 31 20:04:18 2019 (r343618) +++ head/sys/netpfil/ipfw/ip_fw_nat.c Thu Jan 31 21:04:50 2019 (r343619) @@ -45,7 +45,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include #include Modified: head/sys/netpfil/ipfw/ip_fw_private.h ============================================================================== --- head/sys/netpfil/ipfw/ip_fw_private.h Thu Jan 31 20:04:18 2019 (r343618) +++ head/sys/netpfil/ipfw/ip_fw_private.h Thu Jan 31 21:04:50 2019 (r343619) @@ -312,6 +312,8 @@ struct ip_fw_chain { void **srvstate; /* runtime service mappings */ #if defined( __linux__ ) || defined( _WIN32 ) spinlock_t rwmtx; +#else + struct rmlock rwmtx; #endif int static_len; /* total len of static rules (v0) */ uint32_t gencnt; /* NAT generation count */ @@ -452,23 +454,25 @@ struct ipfw_ifc { #define IPFW_PF_RUNLOCK(p) IPFW_RUNLOCK(p) #else /* FreeBSD */ #define IPFW_LOCK_INIT(_chain) do { \ + rm_init_flags(&(_chain)->rwmtx, "IPFW static rules", RM_RECURSE); \ rw_init(&(_chain)->uh_lock, "IPFW UH lock"); \ } while (0) #define IPFW_LOCK_DESTROY(_chain) do { \ + rm_destroy(&(_chain)->rwmtx); \ rw_destroy(&(_chain)->uh_lock); \ } while (0) -#define IPFW_RLOCK_ASSERT(_chain) rm_assert(&V_pfil_lock, RA_RLOCKED) -#define IPFW_WLOCK_ASSERT(_chain) rm_assert(&V_pfil_lock, RA_WLOCKED) +#define IPFW_RLOCK_ASSERT(_chain) rm_assert(&(_chain)->rwmtx, RA_RLOCKED) +#define IPFW_WLOCK_ASSERT(_chain) rm_assert(&(_chain)->rwmtx, RA_WLOCKED) #define IPFW_RLOCK_TRACKER struct rm_priotracker _tracker -#define IPFW_RLOCK(p) rm_rlock(&V_pfil_lock, &_tracker) -#define IPFW_RUNLOCK(p) rm_runlock(&V_pfil_lock, &_tracker) -#define IPFW_WLOCK(p) rm_wlock(&V_pfil_lock) -#define IPFW_WUNLOCK(p) rm_wunlock(&V_pfil_lock) -#define IPFW_PF_RLOCK(p) -#define IPFW_PF_RUNLOCK(p) +#define IPFW_RLOCK(p) rm_rlock(&(p)->rwmtx, &_tracker) +#define IPFW_RUNLOCK(p) rm_runlock(&(p)->rwmtx, &_tracker) +#define IPFW_WLOCK(p) rm_wlock(&(p)->rwmtx) +#define IPFW_WUNLOCK(p) rm_wunlock(&(p)->rwmtx) +#define IPFW_PF_RLOCK(p) IPFW_RLOCK(p) +#define IPFW_PF_RUNLOCK(p) IPFW_RUNLOCK(p) #endif #define IPFW_UH_RLOCK_ASSERT(_chain) rw_assert(&(_chain)->uh_lock, RA_RLOCKED) Modified: head/sys/netpfil/ipfw/ip_fw_sockopt.c ============================================================================== --- head/sys/netpfil/ipfw/ip_fw_sockopt.c Thu Jan 31 20:04:18 2019 (r343618) +++ head/sys/netpfil/ipfw/ip_fw_sockopt.c Thu Jan 31 21:04:50 2019 (r343619) @@ -60,7 +60,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include Modified: head/sys/netpfil/ipfw/ip_fw_table.c ============================================================================== --- head/sys/netpfil/ipfw/ip_fw_table.c Thu Jan 31 20:04:18 2019 (r343618) +++ head/sys/netpfil/ipfw/ip_fw_table.c Thu Jan 31 21:04:50 2019 (r343619) @@ -55,7 +55,6 @@ __FBSDID("$FreeBSD$"); #include #include #include /* ip_fw.h requires IFNAMSIZ */ -#include #include #include /* struct ipfw_rule_ref */ Modified: head/sys/netpfil/ipfw/ip_fw_table_value.c ============================================================================== --- head/sys/netpfil/ipfw/ip_fw_table_value.c Thu Jan 31 20:04:18 2019 (r343618) +++ head/sys/netpfil/ipfw/ip_fw_table_value.c Thu Jan 31 21:04:50 2019 (r343619) @@ -50,7 +50,6 @@ __FBSDID("$FreeBSD$"); #include #include #include /* ip_fw.h requires IFNAMSIZ */ -#include #include #include /* struct ipfw_rule_ref */