From nobody Thu Mar 10 17:21:12 2022 X-Original-To: dev-commits-src-main@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 446F919F1BD8; Thu, 10 Mar 2022 17:21:13 +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 4KDwp03BKPz4TKn; Thu, 10 Mar 2022 17:21:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646932872; 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=wetL6gu3a9xD6KyYUPanNRmvzLlk40t2ryGrdjtw460=; b=aRTVAOUtW/E3rMMZ4QicBSRE70zM7BxpIHooToNa1ZbBsPrIK0D8WN7tZR2HlNZZs/WHWR SihgKJVDLtV52lcTNj+bZvczhceFMLOHwflVgd6I6dB3HxvlGF+gTgbWm6hLR4OeIzY5ax AR/fTdjyIndTllxDAGHlKP1uErohVH9R9T6ZTjRZytTEQ8wLj0x7AdU3js7McQuKKQX9tg AY7rWMPwrsMNGL+CA1fZQN7FnVk9DcjdZ5qVlar4TP08D6LW4Kpz6lsu0ZkDISPGCNY+6D WRGCwgJ3MO3oTySbo+cvSLJqAVFsE+uga0wVL/BtckpNuhxhFCaJi/HanyB8TQ== 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 41DEC1183; Thu, 10 Mar 2022 17:21:12 +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 22AHLCVJ011468; Thu, 10 Mar 2022 17:21:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22AHLCEe011467; Thu, 10 Mar 2022 17:21:12 GMT (envelope-from git) Date: Thu, 10 Mar 2022 17:21:12 GMT Message-Id: <202203101721.22AHLCEe011467@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: b163dcab2786 - main - pf: hoist the unlinked rules lock out of the mass rule removal loop List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: b163dcab27862f90e0108a73185945456cafd2f3 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646932872; 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=wetL6gu3a9xD6KyYUPanNRmvzLlk40t2ryGrdjtw460=; b=cZ3MNy5aGhpgeJBoj8MXS82TtS+PchLHPHKPeeztuXWMSC9fVazwInHvjIMsCVZH3DBlbM nTaI1eT/svUzHCuInZAsF2K8msU9ZFyqkevGR9SFDhFbyDnjurhKaEyykZaE3VUmncXzxq oUKRWwCnI63gQsCHOkHHEyqv6VraZR7jYXXfl0caQfcSvA5BoW5Y/D7Keqh+OFtAEQEN+I 6pV/2fH7cEGopvUkXP8gc/V4HpahBv/JCo+jKub9nPnnUcaTnYNyaLivtkaj+fSesvaYHY Ul2XLt5HKIckv2fpzih5xh+89TaMMekeiW18BWj4aoZ25RjwKESgRVvNjyGmcQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646932872; a=rsa-sha256; cv=none; b=DfGqLjAJezdSL8/Ee91aXG5tUdoiF9CA4Px+0W7JDWBZUJ0pOjB1MFsZ+UcmMWfS2hS6mC 95Z7PcKFA5gEKSihvGuqb+rURTRGGHo2iVCwMHJitMs0L+jLqd+VABZAB2bMNt+6xs9As5 8woUdkzDExDBHVxaKHWEtI2KRzqtoiVgd48npE+QRHSZ6xHMEkFmNxTmAt956hTo3wWZlG Mnq4K6am6RGLAl4bDV3IbQbrn7ENANVLlwIpj/VYQYMgT/fPu6SFCnITzdZb6U9IEru4lJ gzvUnO9nDMK1yxws52Cdl70nB0sDsrhkjHGCTNmXDuasdEAtlh4eU8UCnd6G9A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=b163dcab27862f90e0108a73185945456cafd2f3 commit b163dcab27862f90e0108a73185945456cafd2f3 Author: Mateusz Guzik AuthorDate: 2022-02-28 10:39:02 +0000 Commit: Mateusz Guzik CommitDate: 2022-03-10 17:20:41 +0000 pf: hoist the unlinked rules lock out of the mass rule removal loop Reviewed by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") --- 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 ef7092c0ed1b..68307c9e7bb3 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -474,16 +474,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(); } @@ -1338,8 +1348,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;