From nobody Tue May 28 20:31:24 2024 X-Original-To: dev-commits-src-all@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 4Vpkgd1RW0z5L6Jd; Tue, 28 May 2024 20:31:25 +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 4Vpkgd109bz4jl8; Tue, 28 May 2024 20:31:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716928285; 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=CgGv8rDyCpL2vKiYXYcWDQfHxFnPVXjKSzBCKoltmLQ=; b=tKPym1nAWu0/u6Lt9Ghr5XIDlBVbCTDT1LaWuZr2B2jmlWKGHbxrwhp4UjZl3yqKqF5w9E A0fRwA1N6BYsAsacH9RczSjPPn/BhIpooZ84tldNYIdHQTfFRuIWWR06DrOka6k2xAofJP NKlDR6dGQaSbgLfoEcCsS9IRFNsh6f9RqiC5vmjfQ17M4btNssj4TZE8cWbUy3Uj3EriZZ DOaqdewMnDjb0X/def/yF5n6Ht9Mtta8UUOQiJIIRBb3WPE0UpxZRiz450gzwTzK2LKjv8 D1D/HK1DljScLW/lDUqp4GFyqbkWcULsCu0JaV1QRW6ByzzhHgk6aTW0agcwrA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1716928285; a=rsa-sha256; cv=none; b=Xfokxrh+EaQrdv89qqEFaE8Xh1uAUcA8SfwzDpTq6hY90qjNhflLRgdRiJ/Ds23jsFXr0/ yWJe75gU/SO5MA2nTV4xCYNXXfYC8E9GZeSn5qdjOXmblwAona7jpUTkpf/Mpj5r+u2Lvt bX0gSGMiy8TbPNmbT/TwBKetvEdKMMZlsMd9O/zqwNKzc+LW60YOdZmI6+oOl6YO+fNYva AGF7I1RXg9JcnXNFQdznxTMJlF2Rl39P0TZpJeTHbEXsT75csiAtNUTYtRHYFJSFLgT/m/ /rUCiQXaLWNzI8p1lYAkvFEW2zw5FSeOlhFUKoHOuyHsb5flKa3KOst5646VsA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716928285; 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=CgGv8rDyCpL2vKiYXYcWDQfHxFnPVXjKSzBCKoltmLQ=; b=uc2E37IGu3VJYmGdDnaMZca6qpLqdgqnHS8G06T+C/Oo1D5jtFJW8ymI9Uq8RzUgjKLMrs g7/giDiuoUCuJgu4pao63R50o3awf7bhyyOse+gCTSo96ZjGnS0L8h+kT0bfYYhSnpgGv0 XAwdYQTj6J1atG8QtCRM2DAw5uW03mDeG9UwEEUfDLT4QOIAmMIj0hSpsNPGzPW5O7y0OB 7lLOIWu4JZn0k1Roo7LukHMivLscCR36gOy+bx0TFZZ7zSzxTsXCgWT0wv2zePWWr4pZ6G Nd0zAQ7d2SkWyNgC11TxBSeBxAU1FeMsw4nyYQyHvQN2uwK06zH/crWJTqWNlg== 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 4Vpkgd0bhGzRRv; Tue, 28 May 2024 20:31:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 44SKVOff068094; Tue, 28 May 2024 20:31:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44SKVOW9068091; Tue, 28 May 2024 20:31:24 GMT (envelope-from git) Date: Tue, 28 May 2024 20:31:24 GMT Message-Id: <202405282031.44SKVOW9068091@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: cd2054d48bc6 - main - libpfctl: add pfctl_get_rule_h() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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: cd2054d48bc6d16edb0fdb84a7e4006620883c1e Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=cd2054d48bc6d16edb0fdb84a7e4006620883c1e commit cd2054d48bc6d16edb0fdb84a7e4006620883c1e Author: Kristof Provost AuthorDate: 2024-05-24 11:15:12 +0000 Commit: Kristof Provost CommitDate: 2024-05-28 20:27:22 +0000 libpfctl: add pfctl_get_rule_h() Add a handle variant of pfctl_get_rule(). This converts us from using the nvlist variant to the netlink variant, and also moves us closer to a world where all libpfctl functions take the handle. While here have pfctl use the new function. Sponsored by: Rubicon Communications, LLC ("Netgate") --- lib/libpfctl/libpfctl.c | 8 ++++++++ lib/libpfctl/libpfctl.h | 3 +++ sbin/pfctl/pfctl.c | 2 +- sbin/pfctl/pfctl_optimize.c | 2 +- usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c | 2 +- 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 479b96123012..e833a23b269a 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -1388,6 +1388,14 @@ pfctl_get_rules_info(int dev __unused, struct pfctl_rules_info *rules, uint32_t return (error); } +int +pfctl_get_rule_h(struct pfctl_handle *h, uint32_t nr, uint32_t ticket, const char *anchor, + uint32_t ruleset, struct pfctl_rule *rule, char *anchor_call) +{ + return (pfctl_get_clear_rule_h(h, nr, ticket, anchor, ruleset, rule, + anchor_call, false)); +} + int pfctl_get_rule(int dev, uint32_t nr, uint32_t ticket, const char *anchor, uint32_t ruleset, struct pfctl_rule *rule, char *anchor_call) diff --git a/lib/libpfctl/libpfctl.h b/lib/libpfctl/libpfctl.h index 73282eb3cc3d..391e73b61e02 100644 --- a/lib/libpfctl/libpfctl.h +++ b/lib/libpfctl/libpfctl.h @@ -420,6 +420,9 @@ int pfctl_get_rules_info(int dev, struct pfctl_rules_info *rules, int pfctl_get_rule(int dev, uint32_t nr, uint32_t ticket, const char *anchor, uint32_t ruleset, struct pfctl_rule *rule, char *anchor_call); +int pfctl_get_rule_h(struct pfctl_handle *h, uint32_t nr, uint32_t ticket, + const char *anchor, uint32_t ruleset, struct pfctl_rule *rule, + char *anchor_call); int pfctl_get_clear_rule(int dev, uint32_t nr, uint32_t ticket, const char *anchor, uint32_t ruleset, struct pfctl_rule *rule, char *anchor_call, bool clear); diff --git a/sbin/pfctl/pfctl.c b/sbin/pfctl/pfctl.c index 1843ec5713d6..c89981075ea6 100644 --- a/sbin/pfctl/pfctl.c +++ b/sbin/pfctl/pfctl.c @@ -1444,7 +1444,7 @@ pfctl_show_nat(int dev, char *path, int opts, char *anchorname, int depth) brace = 0; INDENT(depth, !(opts & PF_OPT_VERBOSE)); - if (pfctl_get_rule(dev, nr, ri.ticket, path, + if (pfctl_get_rule_h(pfh, nr, ri.ticket, path, nattype[i], &rule, anchor_call)) { warn("DIOCGETRULE"); return (-1); diff --git a/sbin/pfctl/pfctl_optimize.c b/sbin/pfctl/pfctl_optimize.c index 9b43a840c06f..7440bf8a506d 100644 --- a/sbin/pfctl/pfctl_optimize.c +++ b/sbin/pfctl/pfctl_optimize.c @@ -903,7 +903,7 @@ load_feedback_profile(struct pfctl *pf, struct superblocks *superblocks) return (1); } - if (pfctl_get_rule(pf->dev, nr, rules.ticket, "", PF_PASS, + if (pfctl_get_rule_h(pf->h, nr, rules.ticket, "", PF_PASS, &rule, anchor_call)) { warn("DIOCGETRULENV"); return (1); diff --git a/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c b/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c index 1086aa7dcf82..f02329901f69 100644 --- a/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c +++ b/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c @@ -1526,7 +1526,7 @@ pfl_scan_ruleset(const char *path) } for (nr = rules.nr, i = 0; i < nr; i++) { - if (pfctl_get_rule(pfctl_fd(pfh), i, rules.ticket, path, + if (pfctl_get_rule_h(pfh, i, rules.ticket, path, PF_PASS, &rule, anchor_call)) { syslog(LOG_ERR, "pfl_scan_ruleset: ioctl(DIOCGETRULE):" " %s", strerror(errno));