From nobody Thu Sep 25 12:41:48 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 4cXYHx5Fj8z68Scy; Thu, 25 Sep 2025 12:41:49 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cXYHx0C04z42yR; Thu, 25 Sep 2025 12:41:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758804109; 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=NRrJf2hawEfU78gQLy6pyIeIQ+YRCw7irzAsSEZ+4Pg=; b=TOx9alb8RVIYoFQXizMeEp/Uj//09mvErFxsaEz2Y9DFXGv9PQOYrY81UByfx9WcaRXzZq PobqAXct/ei+kWKsNeTXT/sZdcn/KoTBV79T2hFixrBtBsJXWkoCtcCXR+Dgmd1fhFprug /fa1G96tPaoXLr2t9iU34PpyYTpnQ5PtZASvR47Rx5PdH/5/gWSw1Y0VOOYlfPwGwRo34N 7BOy6iXJzU9a5XeOSVLqTQgq8VPDIQt5LubG62mGgecJvQa7abbxajwI9ZvjQbklSgtVZZ pO37MpXW1cV4LvvLQgAW02/AQ0HwyeYMwLNlUPVxRJ65qxNWBukFDIIz/zb/XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758804109; 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=NRrJf2hawEfU78gQLy6pyIeIQ+YRCw7irzAsSEZ+4Pg=; b=WWCKYQZmm3pnsU8BSx9W5XI7/zeUHXzpqB2XdX0/3MxEIuj0ZpWhiPjSMc8/dmRptD2Bhx 2+a+3S4YUKuwf2MO9Nzy1+mvZRmuMgw9QWlfnow9UkdCg1X85uUq64RNygKTpwqg68eTtb Rw5ZZa1oxuHdihbE2yA16vGXa8+gbgAFYqo8MfnpTgsVQHvaPmvSmv3FnoCKxq46CXu1p1 NyjZK8yKHux5mtIObBK8fkNkJ06wCg3eoPkOR0YHQBz+6+bq/a1FCkjcT01ciej75Q0On0 3ey5n9tvseTF1pG/rt8XoiSOaAaxHBSbzLDZTyZzxd47sxbVTF2ubKpCpT3VXA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1758804109; a=rsa-sha256; cv=none; b=qFRGrm+gvKd3DAmFRnNMF1xDoaYwaJ9MrWX2UwaZvwN/bXh4Cn23YBp8MEYcSCyGTPrTMp o7evnvHJDAWjdcnLatjBsbPTairp7ZK9Fsl/FKcnyEwknQvbu56ZAmvWL327lGK5yoym8B MQbBGHzXQTJ9MkROEn5Kb5Y83MmH8mbTaMTO84OCWt7wjvTCRm5pgqpP8mq3upHohhfPFx mdEPP/0jaRp5DCJKyNcRgMqlPwP7pomHJDkxoJbHOxhqFmZ/8XJPM01WqfN+fH1ECxAiEs GEA/8zSB9APObaiLcwvp9N0WVgQNbXSFty4OQixF7heJ+KUesa3QTgpGcifJkg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4cXYHw6m2Dz1Gpw; Thu, 25 Sep 2025 12:41:48 +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 58PCfmbm004888; Thu, 25 Sep 2025 12:41:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 58PCfmkH004885; Thu, 25 Sep 2025 12:41:48 GMT (envelope-from git) Date: Thu, 25 Sep 2025 12:41:48 GMT Message-Id: <202509251241.58PCfmkH004885@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: 08fbad1b135b - main - pfctl: refactor 'rule_numbers' variable 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: 08fbad1b135b0efcfc82f793999463def9f95610 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=08fbad1b135b0efcfc82f793999463def9f95610 commit 08fbad1b135b0efcfc82f793999463def9f95610 Author: Kristof Provost AuthorDate: 2025-08-28 15:52:18 +0000 Commit: Kristof Provost CommitDate: 2025-09-25 12:41:11 +0000 pfctl: refactor 'rule_numbers' variable The 'rule_numbers' is used for more than just displaying rule numbers. Rename it and move the actual opts checking into the relevant functions. Sponsored by: Rubicon Communications, LLC ("Netgate") --- sbin/pfctl/pfctl.c | 5 ++--- sbin/pfctl/pfctl_parser.c | 11 +++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index b8f4305a3e38..21562fa03e0d 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -1315,7 +1315,6 @@ pfctl_show_rules(int dev, char *path, int opts, enum pfctl_show format, struct pfctl_rule rule; char anchor_call[MAXPATHLEN]; u_int32_t nr, header = 0; - int rule_numbers = opts & (PF_OPT_VERBOSE2 | PF_OPT_DEBUG); int numeric = opts & PF_OPT_NUMERIC; int len = strlen(path), ret = 0; char *npath, *p; @@ -1413,7 +1412,7 @@ pfctl_show_rules(int dev, char *path, int opts, enum pfctl_show format, case PFCTL_SHOW_RULES: if (rule.label[0][0] && (opts & PF_OPT_SHOWALL)) labels = 1; - print_rule(&rule, anchor_call, rule_numbers, numeric); + print_rule(&rule, anchor_call, opts, numeric); /* * Do not print newline, when we have not * printed expired rule. @@ -1492,7 +1491,7 @@ pfctl_show_rules(int dev, char *path, int opts, enum pfctl_show format, if (rule.label[0][0] && (opts & PF_OPT_SHOWALL)) labels = 1; INDENT(depth, !(opts & PF_OPT_VERBOSE)); - print_rule(&rule, anchor_call, rule_numbers, numeric); + print_rule(&rule, anchor_call, opts, numeric); /* * If this is a 'unnamed' brace notation diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c index f04bc93436d8..b8531067d3f6 100644 --- a/sbin/pfctl/pfctl_parser.c +++ b/sbin/pfctl/pfctl_parser.c @@ -389,9 +389,11 @@ print_flags(uint16_t f) void print_fromto(struct pf_rule_addr *src, pf_osfp_t osfp, struct pf_rule_addr *dst, - sa_family_t af, u_int8_t proto, int verbose, int numeric) + sa_family_t af, u_int8_t proto, int opts, int numeric) { char buf[PF_OSFP_LEN*3]; + int verbose = opts & (PF_OPT_VERBOSE2 | PF_OPT_DEBUG); + if (src->addr.type == PF_ADDR_ADDRMASK && dst->addr.type == PF_ADDR_ADDRMASK && PF_AZERO(&src->addr.v.a.addr, AF_INET6) && @@ -854,7 +856,7 @@ print_eth_rule(struct pfctl_eth_rule *r, const char *anchor_call, } void -print_rule(struct pfctl_rule *r, const char *anchor_call, int verbose, int numeric) +print_rule(struct pfctl_rule *r, const char *anchor_call, int opts, int numeric) { static const char *actiontypes[] = { "pass", "block", "scrub", "no scrub", "nat", "no nat", "binat", "no binat", "rdr", "no rdr", @@ -862,7 +864,8 @@ print_rule(struct pfctl_rule *r, const char *anchor_call, int verbose, int numer static const char *anchortypes[] = { "anchor", "anchor", "anchor", "anchor", "nat-anchor", "nat-anchor", "binat-anchor", "binat-anchor", "rdr-anchor", "rdr-anchor" }; - int i, ropts; + int i, ropts; + int verbose = opts & (PF_OPT_VERBOSE2 | PF_OPT_DEBUG); char *p; if ((r->rule_flag & PFRULE_EXPIRED) && (!verbose)) @@ -988,7 +991,7 @@ print_rule(struct pfctl_rule *r, const char *anchor_call, int verbose, int numer printf(" proto %u", r->proto); } print_fromto(&r->src, r->os_fingerprint, &r->dst, r->af, r->proto, - verbose, numeric); + opts, numeric); if (r->rcv_ifname[0]) printf(" %sreceived-on %s", r->rcvifnot ? "!" : "", r->rcv_ifname);