From nobody Wed Jul 9 08:59:05 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 4bcX2x5NqGz61NKh; Wed, 09 Jul 2025 08:59:05 +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 4bcX2x3qjhz3cLl; Wed, 09 Jul 2025 08:59:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1752051545; 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=YXjl1onoV/L8Tk2xkKvtXWi1NRkUvgwVUbugoBnlfLk=; b=fMze+y5VVRbtiiAbZ+zTSy1N60BZdNVyHohLZdspDfjHndfSZUTFDC5BKZX7gW/mDVj3Re 9zHKld5/Yx71+zCApdktAFGwIr3JTsZcPRo4Foy/uLCf4qe3ilDhPaef2fV1IkEyS2u2cm rGvBF7jMi5QpQPzxscR1UU2AoN9sXBzNnhfMBu353x1Kujr8ltUZuR35dCXeWNuUz7qPgv Lsl5QCoJZJuaIgRFGNnLixG4cQmhKQ7qhkOxmvMtPXfscgr65ANWPGmsKNcqet+SFVzcFj gtzRVO3aFEtOa2ktBbjNl1eNiaE4ar7IHM3d1iEuhFb8FyZu/bQp8oaD12KNvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1752051545; 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=YXjl1onoV/L8Tk2xkKvtXWi1NRkUvgwVUbugoBnlfLk=; b=iV2b/rmqA2AkWAqIb/xl6Me7i1yLCIPZ1WhLb7Ef2NEL+mjKJtbDR0WwBOsKzsvwBWwrfW DBh5XQsWwwZj4jMZjPIJBXGH8KVnz/HQK1Y9adv6SfaQw1OZcF9TT0NvOMJRkHjJEUD0DI nlX3hI4o16XPAodULSoqt7S84+8wcxZYBgkscpXe4sm/6AKcoOwswlbM7spqitqWy8ICY1 a2wnKc9oWqFvt7lD2a5noTutMxJupTSTn8CgT6HFtOdGev9oJhpSUmGwr84lWQj3x4i6JA xXiOcgUvM7eJKzBYwVZZAMSiUiSi5fPejV/zDBL+/FjmLiCI/Id/90syhOwy+w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1752051545; a=rsa-sha256; cv=none; b=vqPMi45yfZVdckj5K9Wo2AddeCiFpfRJDt4gacrU9gMAeCD8VMhBbeQ4xJqpyJloQ17WnJ WFKO9H2FHkuOIjbq4XbD1J8d/+ZpP57z86v2uNT3IewWjLjRFW8VqM7GyRvb/uH2vVwhmq hSLoNmV7pMes7dFaLYnLbL+LqukZC/MDytzs3MWR4YfNMdciM0fsQ0cc1G8BflksswOrD/ BD9rPqeN3pK6hsN78wi8872mij4x+eR8Wa7RGG2kN7xnR93AE+sZzdmhhbKuLiqdxXRYB3 LRGhoi9cdQkI8ChUjF35pG5S4i0Swc4VGJ84Ll7WbyB2OD1T/Wj7qDFK7UkuwQ== 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 4bcX2x3Gk4z1D2; Wed, 09 Jul 2025 08:59:05 +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 5698x5fH044925; Wed, 9 Jul 2025 08:59:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5698x5gD044922; Wed, 9 Jul 2025 08:59:05 GMT (envelope-from git) Date: Wed, 9 Jul 2025 08:59:05 GMT Message-Id: <202507090859.5698x5gD044922@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: f97839e05c06 - main - pfctl: Avoid optimizing empty rulesets 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: f97839e05c062a74940b2c501a08b1dd972cdc33 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=f97839e05c062a74940b2c501a08b1dd972cdc33 commit f97839e05c062a74940b2c501a08b1dd972cdc33 Author: Kristof Provost AuthorDate: 2025-07-03 12:49:32 +0000 Commit: Kristof Provost CommitDate: 2025-07-09 08:57:49 +0000 pfctl: Avoid optimizing empty rulesets All optimizations work on actual rules; if there are none, return early. While here, tell which ruleset/anchor is being optimized to make the debug message actually useful. OK mikeb Obtained from: OpenBSD, kn , 757f1589f1 Sponsored by: Rubicon Communications, LLC ("Netgate") --- sbin/pfctl/pfctl_optimize.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sbin/pfctl/pfctl_optimize.c b/sbin/pfctl/pfctl_optimize.c index b58bace326c2..e727324bbf40 100644 --- a/sbin/pfctl/pfctl_optimize.c +++ b/sbin/pfctl/pfctl_optimize.c @@ -273,7 +273,10 @@ pfctl_optimize_ruleset(struct pfctl *pf, struct pfctl_ruleset *rs) struct pfctl_rule *r; struct pfctl_rulequeue *old_rules; - DEBUG("optimizing ruleset"); + if (TAILQ_EMPTY(rs->rules[PF_RULESET_FILTER].active.ptr)) + return (0); + + DEBUG("optimizing ruleset \"%s\"", rs->anchor->path); memset(&table_buffer, 0, sizeof(table_buffer)); skip_init(); TAILQ_INIT(&opt_queue);