From nobody Mon Aug 11 19:27:26 2025 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 4c14Qk4ymGz64nxj; Mon, 11 Aug 2025 19:27:26 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4c14Qk3Hq0z3bB6; Mon, 11 Aug 2025 19:27:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1754940446; 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=Ic+9RLABW2Ni4Z5gjirvkdFeN4dtQCOD6IvmLfjBDXs=; b=gvaWFGG0pPOsVkYMfgl+wqIIM1UZVnovSf6nKI6bAzo1wYnIwgNHFGhzlhzwb6hKwd7Q6s HwwyFLX9C23eZpByP+BtC9eCKiIgrW6goKx+/4qhB/VvUbRjUIAi77rFmt5OrewmzfJhki XaV6EXLfXm9ZsU2Fr/wng34wHDPP2hsplS+G4mPztF+Bt+E2/Joiy5yyFjayIgePIURoFk Fq8fgO/Jtzx+HXUO71Tl9qipMnnm2bwuCsl1/RFOZLaAUWZAXRCAjYduwjk4KaQsa70TWk liW6syxfaqU/de9rk+NQi0dwpIhzcWt5zbnSXbc0HYIOtqKQngHJS0Yd0jajrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1754940446; 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=Ic+9RLABW2Ni4Z5gjirvkdFeN4dtQCOD6IvmLfjBDXs=; b=RB0f+sYMAIuP9iFzJQ1ePKcB9HaxK6FrzynwrYTBukO/Oa0uZTvW1wHOapb6gpcN3waVeu NXEMXzLqACVz1CAnDUx4PMpPM0pIoH86JR+U9kakLPbQQS5NSSkVqGIwUknA83WpXwgixz 5JbrbYQvbLhGDr8bcGV49sv4/g65VWUp+l1/Dfu//7Vbl1SnZL+2rkcNQKBVkjSl4HMstG R6JDx3zUXD6b3XU5LVPkkGEFMVZFyx1UWCBMDmMgJ0QNNLMwpERQ70zZlharaM1sea81SA dzKKvzgBBSQZ1YsUuD0YHBtzy1fI8V6Z0mn13nNKo1OYfwyl/8gK3FpacEbZgA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1754940446; a=rsa-sha256; cv=none; b=CFzknQX9gEkSE1EmrUqaoAz+cYQh9O3rTW45v6IoQmPBUm/MOSmTum+v4UASPg6haJESZr /e9dTS73e7DQLdQ1cR1PWJGUAc23m7Wiv0v9TWH4aOZ0wEWB43+cPOntBao2UuvJwF7Kfj Ey0WmuKrJDEfg9AKhqObwdG6xq7ENX8ReO4NZGEa0u7YA267lnnpkN4parAsqKJjZOpPmQ J0JdIIKXvnsbB9C+F68uSMZlUz1i/Vl5U/AC1oQ6usQ61tB5ZsLTEGHgRGBTJfBvII+7MB hiuTRsePW6HYOunslcimAEZUdnQpPlrD3/7o5Dy9x26ATWI/GhSeC8sw4OH+rw== 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 4c14Qk2TPpz15Hg; Mon, 11 Aug 2025 19:27:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 57BJRQvI013835; Mon, 11 Aug 2025 19:27:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 57BJRQ1X013832; Mon, 11 Aug 2025 19:27:26 GMT (envelope-from git) Date: Mon, 11 Aug 2025 19:27:26 GMT Message-Id: <202508111927.57BJRQ1X013832@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 96bd22f2bd80 - main - pf: fix anchor/ethernet anchor cleanup 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 96bd22f2bd80f9c991a41fc45ef032f256cae170 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=96bd22f2bd80f9c991a41fc45ef032f256cae170 commit 96bd22f2bd80f9c991a41fc45ef032f256cae170 Author: Kristof Provost AuthorDate: 2025-08-11 12:14:18 +0000 Commit: Kristof Provost CommitDate: 2025-08-11 19:27:09 +0000 pf: fix anchor/ethernet anchor cleanup Don't mess with reference counts, but use RB_FOREACH_SAFE() so we can safely delete even wildcard anchors. Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/netpfil/pf/pf_ioctl.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index b6f5d74b5b42..e5da05a958f6 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -6444,19 +6444,14 @@ shutdown_pf(void) int error = 0; u_int32_t t[5]; char nn = '\0'; - struct pf_kanchor *anchor; - struct pf_keth_anchor *eth_anchor; + struct pf_kanchor *anchor, *tmp_anchor; + struct pf_keth_anchor *eth_anchor, *tmp_eth_anchor; int rs_num; do { /* Unlink rules of all user defined anchors */ - RB_FOREACH(anchor, pf_kanchor_global, &V_pf_anchors) { - /* Wildcard based anchors may not have a respective - * explicit anchor rule or they may be left empty - * without rules. It leads to anchor.refcnt=0, and the - * rest of the logic does not expect it. */ - if (anchor->refcnt == 0) - anchor->refcnt = 1; + RB_FOREACH_SAFE(anchor, pf_kanchor_global, &V_pf_anchors, + tmp_anchor) { for (rs_num = 0; rs_num < PF_RULESET_MAX; ++rs_num) { if ((error = pf_begin_rules(&t[rs_num], rs_num, anchor->path)) != 0) { @@ -6474,14 +6469,8 @@ shutdown_pf(void) } /* Unlink rules of all user defined ether anchors */ - RB_FOREACH(eth_anchor, pf_keth_anchor_global, - &V_pf_keth_anchors) { - /* Wildcard based anchors may not have a respective - * explicit anchor rule or they may be left empty - * without rules. It leads to anchor.refcnt=0, and the - * rest of the logic does not expect it. */ - if (eth_anchor->refcnt == 0) - eth_anchor->refcnt = 1; + RB_FOREACH_SAFE(eth_anchor, pf_keth_anchor_global, + &V_pf_keth_anchors, tmp_eth_anchor) { if ((error = pf_begin_eth(&t[0], eth_anchor->path)) != 0) { DPFPRINTF(PF_DEBUG_MISC, "%s: eth "