From nobody Mon Mar 28 11:37:59 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 181151A3F960; Mon, 28 Mar 2022 11:38:00 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KRrKg34Dvz3vlr; Mon, 28 Mar 2022 11:37:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648467479; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5E4gexSL9Obkr/+Aj4Gm2TKf9muu9uAGYoFc6oih2g0=; b=fp2OmlC8Z2IZJeIjo2gtrM6rImQgraBeLz4kO5ZadiQeqhdJWbyDja+f04YK0gB8SQOKeg wKadOCFBu2dVVH8PaXHRzlPpjg2y55/Tj14RG5Ncggnz6tg0rZa+SK+k4NlwAXei42YJPI c0KfyeqemkcLrDYXC0wm4lrSIy76N2UiU6CYsPA0SH8dhfBBCvfDCuNfK6T6IgT776MS/p 7oHYO7yu1cRoRIMflRUPct7Dgu7uMQlmosT7sXzMbNW1jgow+kYs/VDa342Jrb/rK8zXbt Mms+dzmxpfOyu5piLyD8a25coBZd7c77aonhraXoWT8B+MhF1QJRur9VxYUJ2Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 38FCB1096; Mon, 28 Mar 2022 11:37:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 22SBbxYq076847; Mon, 28 Mar 2022 11:37:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22SBbxnh076846; Mon, 28 Mar 2022 11:37:59 GMT (envelope-from git) Date: Mon, 28 Mar 2022 11:37:59 GMT Message-Id: <202203281137.22SBbxnh076846@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: 2373bf2d1ece - stable/12 - pf: hoist the unlinked rules lock out of the mass rule removal loop List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 2373bf2d1ece15c678ae818fff28ecf394848ebb Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648467479; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5E4gexSL9Obkr/+Aj4Gm2TKf9muu9uAGYoFc6oih2g0=; b=mXDbmoBjgqiCp7XUr+lRggm/CL8I45X1PnoiHU+lhJzZVarnsqYApofo6/0gLHGgpWu8xQ fXFFiYPx8HGMtwPNvyYLIUx9PBt0h7WQOw3HUnH/O39k8PQNNtCks+pUc4cEbT/EH3Z+oR OKraS5ljIS3VIxXlnNGpih8HKWgDbmPq1SCKEbPgzpBx4i5Vw67SB9n37SLGc0kcxDjGDZ gFp+EjjkGJfNJNAOM+8EQ8XUeHdO0RESo/0d/pi+HGBcnEKzsN8amCWerMnkTxA5k71SD0 B2mjR4PNIyJEF0dUd/g1yc6rlZhraFWvaSAXMTzjjK7MFmseDMcMxHsBwOhjeA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648467479; a=rsa-sha256; cv=none; b=xMnW5XvsiYri1WkHsMyvozZXQBZZscpXIRyykXjcVlhGOpil8uH4j7oLf/dvUduPqhd2wA rSoIhDZ/Ffi5jQghYHXPHcNupsook1rXk6l4KM7QTXKfSZcWcEaXdj5G/wT5Vz0YFZ0RX6 0+3jZmL37UyOBqqUFrvYcLKQF4DQA82OZSeUFvsouENB8FfTAKfM9uiYwRLvKwmC7pzhZa lEgIVcpgwxoZ83O9Ddb274jgNiVcUutftNQYpOQslLfN1ijQM9DK0A5LdfN0MdvrA9qVqv VMfUfgNHX5XyBNc4bp7uikXcTY3OBCY1E2W2DqiGAx7wPyZqSF4beobuMnt0MQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=2373bf2d1ece15c678ae818fff28ecf394848ebb commit 2373bf2d1ece15c678ae818fff28ecf394848ebb Author: Mateusz Guzik AuthorDate: 2022-02-28 10:39:02 +0000 Commit: Mateusz Guzik CommitDate: 2022-03-28 11:37:42 +0000 pf: hoist the unlinked rules lock out of the mass rule removal loop Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit b163dcab27862f90e0108a73185945456cafd2f3) --- sys/netpfil/pf/pf_ioctl.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index ac99ac6d80bc..11be26ad9438 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -453,16 +453,26 @@ pf_empty_kpool(struct pf_kpalist *poola) } static void -pf_unlink_rule(struct pf_krulequeue *rulequeue, struct pf_krule *rule) +pf_unlink_rule_locked(struct pf_krulequeue *rulequeue, struct pf_krule *rule) { PF_RULES_WASSERT(); + PF_UNLNKDRULES_ASSERT(); TAILQ_REMOVE(rulequeue, rule, entries); - PF_UNLNKDRULES_LOCK(); rule->rule_ref |= PFRULE_REFS; TAILQ_INSERT_TAIL(&V_pf_unlinked_rules, rule, entries); +} + +static void +pf_unlink_rule(struct pf_krulequeue *rulequeue, struct pf_krule *rule) +{ + + PF_RULES_WASSERT(); + + PF_UNLNKDRULES_LOCK(); + pf_unlink_rule_locked(rulequeue, rule); PF_UNLNKDRULES_UNLOCK(); } @@ -1145,8 +1155,10 @@ pf_commit_rules(u_int32_t ticket, int rs_num, char *anchor) /* Purge the old rule list. */ + PF_UNLNKDRULES_LOCK(); while ((rule = TAILQ_FIRST(old_rules)) != NULL) - pf_unlink_rule(old_rules, rule); + pf_unlink_rule_locked(old_rules, rule); + PF_UNLNKDRULES_UNLOCK(); if (rs->rules[rs_num].inactive.ptr_array) free(rs->rules[rs_num].inactive.ptr_array, M_TEMP); rs->rules[rs_num].inactive.ptr_array = NULL;