From nobody Mon Nov 27 20:37:08 2023 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 4SfHSj2D8jz52lrD; Mon, 27 Nov 2023 20:37:09 +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 4SfHSj0HSrz4Jwd; Mon, 27 Nov 2023 20:37:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701117429; 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=LmSv3VeaqR0pdL5CV79IC/SN/yndivyXr7J6NXn+pqU=; b=Ee1lJOz2k+dHGLXh+MUmbeBpg0kpz/mXU0JQX9eIk7IIaFBKY83yB4xjxA2PgCVpcLTruU PeDBF47RM+tvVN4PXxvEC4CEeMBQo3LqYbSI7Yrp93l9L71VBL1UEI+Drh92xCn9yqSdGu +0B5RT4XsHeuGa8ihZktQ29rQiX6LCc4HfJtG3IfozGYSSYH15xrG0FEEww/uFwPv/XAx2 Y2CEh8LK4UWu5h0aRCqzgUKfISqjp0+MGU/1OEj3Gfe/Xd+kIalitBCF5mZsr2KuxCWfq0 nMCvjUGizInvryI3TBFGDbk+CJUTa1QbeLCHn/yWliFyTLK1imdjJRaylvYewA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701117429; 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=LmSv3VeaqR0pdL5CV79IC/SN/yndivyXr7J6NXn+pqU=; b=oElwOzCxqwl6RQEEpr6C5QFmrC9E6cSCSKH6Pi5AGw5brlH7Yqd7loZjoTtwziQ1UIgh+G WCgDc2r/6ZX4EErtt1dkFUOVSObjXyheZvHIk8jn4PdTFXS7jhq+ePEjTVPaLWiWiSu0LI u2ZIpoCIhi6kNN8e2vh8hfqY/eW3Sdb+769QbXcKKFUbg7Y+H0iOCki7DttJwFZkKErQ6N oDHIiuT2DgfpF6QvbukHVnhstit4N+pxoX+p0/MeBuyVrxn0gghmngGLvNW+FJoBEZsErI ZlGWD67nIpA3PRxOR49e7gYGDj5eCkMHNItu4hhfDnoZL8HAspyhQl6XtUF+dA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1701117429; a=rsa-sha256; cv=none; b=tfTcY07Jx2nd7g1N6zRX4hp6QGwEPov6Zal7b/poc8qiSh8YiudelNRt8vXlMsmBG432Ob evPrLLj7tmRg14Rvv0oQXrC7ptpzoAvFTQ6DPo7C0BKBVOa2CWAOuGzGXRUTmj1g4Nls2M qtWvTu9dSh1Hx1NactBJ6vqCfEsu36hjRSCVk9aeOP7NgmywsDsmUuFLFmCzCMpzaxWD6r 1BtcdysncHHFPhp2n21Ks8THyo9Ir9Di8rMhEW56D9cuS9cvvRPFeP6OKJ8YFCnAjjkI8M 5k/C1LxPMXYgeEqKnJoppYZF+T84VAdHJogLwSWdG1cnt5SkdIC7SsW2qLTh3A== 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 4SfHSh6NY3zsqL; Mon, 27 Nov 2023 20:37:08 +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 3ARKb8h9019689; Mon, 27 Nov 2023 20:37:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3ARKb8vg019686; Mon, 27 Nov 2023 20:37:08 GMT (envelope-from git) Date: Mon, 27 Nov 2023 20:37:08 GMT Message-Id: <202311272037.3ARKb8vg019686@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: 47a0b59379c3 - main - pfctl: use libpfctl instead of DIOCGETRULES directly 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: 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: 47a0b59379c3bec547e7c829eb12de8276227dff Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=47a0b59379c3bec547e7c829eb12de8276227dff commit 47a0b59379c3bec547e7c829eb12de8276227dff Author: Kristof Provost AuthorDate: 2023-11-24 23:43:48 +0000 Commit: Kristof Provost CommitDate: 2023-11-27 20:36:48 +0000 pfctl: use libpfctl instead of DIOCGETRULES directly MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") --- sbin/pfctl/pfctl_optimize.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/sbin/pfctl/pfctl_optimize.c b/sbin/pfctl/pfctl_optimize.c index aefd7b6471e5..95292999c50a 100644 --- a/sbin/pfctl/pfctl_optimize.c +++ b/sbin/pfctl/pfctl_optimize.c @@ -877,24 +877,23 @@ block_feedback(struct pfctl *pf, struct superblock *block) int load_feedback_profile(struct pfctl *pf, struct superblocks *superblocks) { + char anchor_call[MAXPATHLEN] = ""; struct superblock *block, *blockcur; struct superblocks prof_superblocks; struct pf_opt_rule *por; struct pf_opt_queue queue; - struct pfioc_rule pr; + struct pfctl_rules_info rules; struct pfctl_rule a, b, rule; int nr, mnr; TAILQ_INIT(&queue); TAILQ_INIT(&prof_superblocks); - memset(&pr, 0, sizeof(pr)); - pr.rule.action = PF_PASS; - if (ioctl(pf->dev, DIOCGETRULES, &pr)) { + if (pfctl_get_rules_info(pf->dev, &rules, PF_PASS, "")) { warn("DIOCGETRULES"); return (1); } - mnr = pr.nr; + mnr = rules.nr; DEBUG("Loading %d active rules for a feedback profile", mnr); for (nr = 0; nr < mnr; ++nr) { @@ -903,15 +902,14 @@ load_feedback_profile(struct pfctl *pf, struct superblocks *superblocks) warn("calloc"); return (1); } - pr.nr = nr; - if (pfctl_get_rule(pf->dev, nr, pr.ticket, "", PF_PASS, - &rule, pr.anchor_call)) { + if (pfctl_get_rule(pf->dev, nr, rules.ticket, "", PF_PASS, + &rule, anchor_call)) { warn("DIOCGETRULENV"); return (1); } memcpy(&por->por_rule, &rule, sizeof(por->por_rule)); - rs = pf_find_or_create_ruleset(pr.anchor_call); + rs = pf_find_or_create_ruleset(anchor_call); por->por_rule.anchor = rs->anchor; if (TAILQ_EMPTY(&por->por_rule.rpool.list)) memset(&por->por_rule.rpool, 0,