From nobody Thu Aug 31 08:56:41 2023 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 4Rbw561TRmz4rw7v; Thu, 31 Aug 2023 08:56:42 +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 4Rbw560f0Gz4YXR; Thu, 31 Aug 2023 08:56:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1693472202; 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=UAs+rxlZtqkMfYbmP5yMQEIqmZTOOTkHq5b3CkE6AF0=; b=cl9Fq+PvMi1NnRvxKtG7PEkH0EkslMvCGSyoXKbdQ8yg9XSjwb78+eX0IWfvtuPSD7dE4a 0kjF6mX99mGx0qOKuuXbq9e+AqySGAmr5ZcQsfKhm6UPvCT4ECpZe53Zdh9Y4EbxnVDlg6 1QbsU7dG7yyqHs4rzl3nfg1LeQ71OCFNaVKPzYmyU5EuCv2J1drxLT0P6SkSwph4ISiCsl ZFkPjXG5VYA3H0GlHyK8j1YnpzfWhwYbVtKCR6a6y1u7PoIv92811zBJmTW4TvL7aAnbFZ D7fElY91TJcJdG5vnsALKwSB4F3Jt0x8gwkBvfJ4hkn0fW1DDxsf/1KPynNeNw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1693472202; a=rsa-sha256; cv=none; b=lLU1swNEd+yD5R4qCdtjqeEZU2eLM5QecBRkkAXnED2LPwDs+9E3j5t3Jopz8blBUxQs0u dN0bDn72JnACjHP/kJdmaD+qJQ7vQQnQegEZLk7E6FMFeVK4j2mzBFwmcRd7eKY79b0NDL x0saZuSz4UE4v5sw9xcFKJyCwnTQVb32OFoa5LfGYI1+c1zllBg307qq9XoHz2UtWS9DVT +2MBOucrR32y7BExr/Z7Y7/0K+efY28JbhFVwLi8054FEZAJrD8YyHZsJ76ifIBAAz7yi/ CQrwvoydK5QH0kqAs1Ly7MUdwlz8ye91UM2C9g4bvhQH1KOva/uicXyU/hCvTg== 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=1693472202; 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=UAs+rxlZtqkMfYbmP5yMQEIqmZTOOTkHq5b3CkE6AF0=; b=EKJZZjg9eTU3zAM/QFFzudRfIDbd5Wp/ghfnHHvNOJ0gFzVdTPhUMacHX3nuosqIeLkUt1 caFbaXDQ3Qo5K31GH2Tr/fv6ldAAj1tMEkExP1XSdECu9Rhp0Joj3Zcbu3Kkfgh9WebHhn GqgjGppW7cyhSUalgOtT49JbiQz8ic7dTr01m/PgOMkJUIJkX1eALoRBMCDuOhXkWWxHu1 ouJB9q+F18DQbani7WBxAj6dKNWlBFUFvYxsQwOTCLF+dQsbaFtkhTpme8gaxJag11h2hL aca2QSoZBZBhHB2wRq7yoPYJarkMsNDvCnJbx+abyQ9SeoAxMI6pAJJ9Tl3pPA== 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 4Rbw556mpNz19sN; Thu, 31 Aug 2023 08:56:41 +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 37V8ufNO083155; Thu, 31 Aug 2023 08:56:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 37V8ufYX083152; Thu, 31 Aug 2023 08:56:41 GMT (envelope-from git) Date: Thu, 31 Aug 2023 08:56:41 GMT Message-Id: <202308310856.37V8ufYX083152@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: ddd08375c855 - main - pf (t)ftp-proxy: use libpfctl instead of DIOCGETSTATUS 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: 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: ddd08375c85576b49fb9a34968ba2c2f4f8d56cf Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=ddd08375c85576b49fb9a34968ba2c2f4f8d56cf commit ddd08375c85576b49fb9a34968ba2c2f4f8d56cf Author: Kristof Provost AuthorDate: 2023-08-29 15:00:44 +0000 Commit: Kristof Provost CommitDate: 2023-08-31 08:56:31 +0000 pf (t)ftp-proxy: use libpfctl instead of DIOCGETSTATUS Prefer libpfctl functions over direct access to the ioctl whenever possible. This will allow subsequent removal of DIOCGETSTATUS (in 15) as there already is an nvlist-based alternative. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D41647 --- contrib/pf/ftp-proxy/filter.c | 9 ++++++--- contrib/pf/tftp-proxy/filter.c | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/contrib/pf/ftp-proxy/filter.c b/contrib/pf/ftp-proxy/filter.c index e4787985e99f..4277e079f3be 100644 --- a/contrib/pf/ftp-proxy/filter.c +++ b/contrib/pf/ftp-proxy/filter.c @@ -169,7 +169,7 @@ do_rollback(void) void init_filter(const char *opt_qname, const char *opt_tagname, int opt_verbose) { - struct pf_status status; + struct pfctl_status *status; qname = opt_qname; tagname = opt_tagname; @@ -182,10 +182,13 @@ init_filter(const char *opt_qname, const char *opt_tagname, int opt_verbose) dev = open("/dev/pf", O_RDWR); if (dev == -1) err(1, "open /dev/pf"); - if (ioctl(dev, DIOCGETSTATUS, &status) == -1) + status = pfctl_get_status(dev); + if (status == NULL) err(1, "DIOCGETSTATUS"); - if (!status.running) + if (!status->running) errx(1, "pf is disabled"); + + pfctl_free_status(status); } int diff --git a/contrib/pf/tftp-proxy/filter.c b/contrib/pf/tftp-proxy/filter.c index 1689d3465fd3..966628464d28 100644 --- a/contrib/pf/tftp-proxy/filter.c +++ b/contrib/pf/tftp-proxy/filter.c @@ -173,7 +173,7 @@ do_rollback(void) void init_filter(char *opt_qname, int opt_verbose) { - struct pf_status status; + struct pfctl_status *status; qname = opt_qname; @@ -187,14 +187,17 @@ init_filter(char *opt_qname, int opt_verbose) syslog(LOG_ERR, "can't open /dev/pf"); exit(1); } - if (ioctl(dev, DIOCGETSTATUS, &status) == -1) { + status = pfctl_get_status(dev); + if (status == NULL) { syslog(LOG_ERR, "DIOCGETSTATUS"); exit(1); } - if (!status.running) { + if (!status->running) { syslog(LOG_ERR, "pf is disabled"); exit(1); } + + pfctl_free_status(status); } int