From nobody Mon Mar 28 11:38:38 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 5D8A71A40692; Mon, 28 Mar 2022 11:38:39 +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 4KRrLR0TZyz3wHG; Mon, 28 Mar 2022 11:38:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648467519; 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=Uo0SXRDopU3Fy1DOE1LLxqknoGsBN/3v2Pjv5lxWVes=; b=XlYn2USBNPnT+/IiPtpmo61yUfxVtDqbKBZcgd8GHvPGWHskni8ign+0ZO+nq7JReNZ+lR w9/qyWWCVsokjPqfOlHW05AjxeG4yB0LGR1LZxLdj26UrFbKXTH4PeNbt273TSgNbMYv6V 2lsJTOqEtIfs1xwhgUdCP2AFsVG6H3tYs+2qwWzq/U3VjXa2qWlRMFQhXRjMzwYeqgySl/ 2db8pOGJuZvKa3F1wKo5U76CfMZP8lsRGAuJfN3dQHMdlZ4KmwvNcVLzeoj9yYMH+2E5DQ 6C6GiryvJrzwrqWEqQNMeNX8ND7zM8EAfdoy7OYkjd9BRB3/wymW7gCS2pWDbw== 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 CEC37AC8; Mon, 28 Mar 2022 11:38:38 +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 22SBccp8077062; Mon, 28 Mar 2022 11:38:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22SBccEq077061; Mon, 28 Mar 2022 11:38:38 GMT (envelope-from git) Date: Mon, 28 Mar 2022 11:38:38 GMT Message-Id: <202203281138.22SBccEq077061@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: 4cf0cc507f35 - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: 4cf0cc507f35714009cba62570b47bb01c1ba49e Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1648467519; 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=Uo0SXRDopU3Fy1DOE1LLxqknoGsBN/3v2Pjv5lxWVes=; b=jIuPae15h+RS47xGF3DrE3KYHEMKDGu7tazB0Y1jTmAGe5ALQ6dGpI1EAHASqgObMEst3S UDwj0z8J6hFFoHR8O2rFnkBR7k0+8b2AUT4zakKNOJgcFA8MLl3ztld1bpCvLd6IdmEejl D8gLSspVGZ5v/fCZDZBdwiqn2eJ4TDaNGHR5rNF9I9p4qxkPS1CxjK25o+nl3iC5yEUyNW qb55EkwQIWsuZH+LX3tEnVyf1xhRmMypEPOKHHZq9tGI5V0CTp617cUPAaj5k/biGL/qyt aUHFprtVANNtt+sKzHYjMB0/01INieXf8Yai+rGqG8Fre23VJ+v5TJkrn7UYng== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1648467519; a=rsa-sha256; cv=none; b=efvLwHqP5IQ16RfF1CNRFNbSFaWl3SZov1uE1RheJog/yEYqLFwyibrGr/nakinx+o71aO XRbCUmSVJ3jWL+anv68r0mNw/4Iy1Ph+Xpd/j1Y1Ar3rdZotlNmq+gbhKcTqpKrDBxEDs1 OS6q9vvCZtPqj05GZTA1C/RvZND0Pq79Sff2JD1GeEir71S1+aZ0iEMDNGvZJPERgOJI19 3bdDUJADVMpySfhGo9wRompQK71MBrZXqz+5ekjgRmfs9sI266b28nYvRCK1AUnFBZOKu7 BON+ckTCbt7psKCbmR6hOvG9srDC3N6PbAKibO75JGN7T7LFVRXuH8+Mr/8+Ew== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=4cf0cc507f35714009cba62570b47bb01c1ba49e commit 4cf0cc507f35714009cba62570b47bb01c1ba49e Author: Mateusz Guzik AuthorDate: 2022-02-28 10:39:02 +0000 Commit: Mateusz Guzik CommitDate: 2022-03-28 11:38:29 +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 4a21b5c52e75..5d4b90f395d5 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -467,16 +467,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(); } @@ -1158,8 +1168,10 @@ pf_commit_rules(u_int32_t ticket, int rs_num, char *anchor) pf_calc_skip_steps(rs->rules[rs_num].active.ptr); /* 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;