From nobody Fri Jul 04 09:22:45 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 4bYSpZ1dmcz61GtW; Fri, 04 Jul 2025 09:22:46 +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 4bYSpY6xQ7z3pkn; Fri, 04 Jul 2025 09:22:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1751620966; 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=WmNqHSl6H6ieVzB6n79JKFCVAaoH4JyaeY/wX+U5ZZ8=; b=vCclI7lfFabD+nhbGhi+Lo0VMBzAkHLxSyK5aMWPB4NpyNTtgGEKKd9tzFwnaiHKx4ti1j YOq4y4YjJBF1QcszDigcfnZKcnhsyeNBCEj8cphQHMgu5KamJ5bM8qgz0FlgSDx+bnftL5 sxcxydV/p47TvFXISN8ju/nxl4phw01ZoArafGo3332I7OGHMXXI4lWnx5EV42EYnCGXyB +vt759pVU/egNd3jztLdXK8ct98Rq8ngGMeR3itj1GX/nxZqti/GOyitn8rsZTlqIWW8oX HZhyIQlq9NJQLuVgwx0T9TAktIFxyVrTi5ZuiY/9vpmt5O6WVAgJVsbdU82dCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1751620966; 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=WmNqHSl6H6ieVzB6n79JKFCVAaoH4JyaeY/wX+U5ZZ8=; b=Dp6Nq3bTQBUM3CajP6TqcgtWyEnS57GeTDFdItqRIMVIB9Z5biHxw1RvFsU6HuuYLNkwq+ sZtv16u/NpgHAe6bxDgBXTXbEhHy9/4VWT54R+7x/MBqEYycZoStPufX+6os18BiGHW8+Y meOGRIS1fXdLXv5G3apZHAJGYk20383Z6ceM+pXh1TbpJUD14beZ0Y/Yjrkm/6UKJ3kVa7 g5+x+FXSgaB6k2aYAiEbBi2+ikSemd8AdeFxHsj2/vb+R7r+Zglabyy03cZgu9BOUo4EFB gUfv3xDQ42+/oZhtSNoZq8mpcSlotjKaHlpIyJP+p0IbXvHniHsALDV9aW+4WA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1751620966; a=rsa-sha256; cv=none; b=AUQt6LphOyXP/JmkbTq6Y9WeuLrqLIgS6XrsEJrI+iJnjGtDHfPm4tElH1LhuEWzQ+wvYP ncKIcjCw/nX07Z+GXMcp/fBIaltU1sQHwHbrRW8lSAsGDwASN0TsjGa8c+AlT6HeSNFFOf TInZKqeH8Uwqobs7HCfGBhRIf3ArMRuki/NF6vBnq9JPWNIYewil41X3Vu0LbRX3kyCJ6V Z9Q0dyBB6BU0rR31vHPUqdonzkM5D5AHTbh5FaPib4Qic7a/iGiX1j2fCcpcDS8o2PgOGp R+sBaD7RRe3+7MEnoiU54ytJQFc/itZru6N94e6COmAiTWTn9Ck3/iUusYLb3g== 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 4bYSpY6Vv4zlQ8; Fri, 04 Jul 2025 09:22:45 +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 5649MjJh055993; Fri, 4 Jul 2025 09:22:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5649MjP6055990; Fri, 4 Jul 2025 09:22:45 GMT (envelope-from git) Date: Fri, 4 Jul 2025 09:22:45 GMT Message-Id: <202507040922.5649MjP6055990@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: 945ba658d803 - main - pfctl: Error out on missing table command, zap internal wrapper function 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: 945ba658d8036102729e3ae7809c56879bf1e259 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=945ba658d8036102729e3ae7809c56879bf1e259 commit 945ba658d8036102729e3ae7809c56879bf1e259 Author: Kristof Provost AuthorDate: 2025-07-01 09:41:12 +0000 Commit: Kristof Provost CommitDate: 2025-07-04 08:31:13 +0000 pfctl: Error out on missing table command, zap internal wrapper function Table name and table command require each other as reflected in the synopsis [-t table -T command [address ...]], so print usage and exit if only one of them is given. By moving the inter-dependence check right after option parsing is done, we can bail out even before opening pf(4) and drop the internal wrapper pfctl_command_tables() as unneeded indirection with now duplicate checks. OK sashan Obtained from: OpenBSD, kn , 97699edbc9 Sponsored by: Rubicon Communications, LLC ("Netgate") --- sbin/pfctl/pfctl.c | 5 ++++- sbin/pfctl/pfctl.h | 2 +- sbin/pfctl/pfctl_table.c | 11 ----------- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index 8c6497b4d1ee..38d74aceba80 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -3175,6 +3175,9 @@ main(int argc, char *argv[]) } } + if (tblcmdopt == NULL ^ tableopt == NULL) + usage(); + if (tblcmdopt != NULL) { argc -= optind; argv += optind; @@ -3400,7 +3403,7 @@ main(int argc, char *argv[]) pfctl_kill_src_nodes(dev, ifaceopt, opts); if (tblcmdopt != NULL) { - error = pfctl_command_tables(argc, argv, tableopt, + error = pfctl_table(argc, argv, tableopt, tblcmdopt, rulesopt, anchorname, opts); rulesopt = NULL; } diff --git a/sbin/pfctl/pfctl.h b/sbin/pfctl/pfctl.h index 5abd5ddcdf8f..08d48695709e 100644 --- a/sbin/pfctl/pfctl.h +++ b/sbin/pfctl/pfctl.h @@ -83,7 +83,7 @@ int pfi_clr_istats(const char *, int *, int); void pfctl_print_title(char *); void pfctl_do_clear_tables(const char *, int); void pfctl_show_tables(const char *, int); -int pfctl_command_tables(int, char *[], char *, const char *, char *, +int pfctl_table(int, char *[], char *, const char *, char *, const char *, int); int pfctl_show_altq(int, const char *, int, int); void warn_namespace_collision(const char *); diff --git a/sbin/pfctl/pfctl_table.c b/sbin/pfctl/pfctl_table.c index abe22a3258de..53abea3e1ae1 100644 --- a/sbin/pfctl/pfctl_table.c +++ b/sbin/pfctl/pfctl_table.c @@ -55,8 +55,6 @@ #include "pfctl.h" extern void usage(void); -static int pfctl_table(int, char *[], char *, const char *, char *, - const char *, int); static void print_table(const struct pfr_table *, int, int); static int print_tstats(const struct pfr_tstats *, int); static int load_addr(struct pfr_buffer *, int, char *[], char *, int, int); @@ -118,15 +116,6 @@ pfctl_show_tables(const char *anchor, int opts) exit(1); } -int -pfctl_command_tables(int argc, char *argv[], char *tname, - const char *command, char *file, const char *anchor, int opts) -{ - if (tname == NULL || command == NULL) - usage(); - return pfctl_table(argc, argv, tname, command, file, anchor, opts); -} - int pfctl_table(int argc, char *argv[], char *tname, const char *command, char *file, const char *anchor, int opts)