Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 20 Dec 2025 14:28:38 +0000
From:      Vladimir Druzenko <vvd@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-branches@FreeBSD.org
Cc:        Simon Wollwage <rootnode+freebsd@wollwage.com>
Subject:   git: 08c7101413e4 - 2025Q4 - sysutils/pfstat: Fix build on FreeBSD 15, take maintainership
Message-ID:  <6946b296.3aed2.3cbc3fdb@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch 2025Q4 has been updated by vvd:

URL: https://cgit.FreeBSD.org/ports/commit/?id=08c7101413e45b3dcc85de800566b47db850cda1

commit 08c7101413e45b3dcc85de800566b47db850cda1
Author:     Simon Wollwage <rootnode+freebsd@wollwage.com>
AuthorDate: 2025-12-20 14:15:08 +0000
Commit:     Vladimir Druzenko <vvd@FreeBSD.org>
CommitDate: 2025-12-20 14:28:29 +0000

    sysutils/pfstat: Fix build on FreeBSD 15, take maintainership
    
    pf.c:174:16: error: use of undeclared identifier 'DIOCGETSTATUS'
      174 |         if (ioctl(fd, DIOCGETSTATUS, &s)) {
          |                       ^
    
    Improve port:
    - Replace PORTVERSION with DISTVERSION.
    - Remove legacy unnecessary MAKE_ARGS and REINPLACE_CMD.
    - Replace REINPLACE_CMD in pf.c with CFLAGS+=-I/usr/include/net.
    - Reduce number of INSTALL_* calls in do-install.
    
    PR:             291607
    MFH:            2025Q4
    Co-authored-by: David Marec <david.marec@proton.me>
    Co-authored-by: Vladimir Druzenko <vvd@FreeBSD.org>
    (cherry picked from commit c701d6805046f1928a33188d265821b4579204c3)
---
 sysutils/pfstat/Makefile         | 24 +++++++++----------
 sysutils/pfstat/files/patch-pf.c | 50 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 13 deletions(-)

diff --git a/sysutils/pfstat/Makefile b/sysutils/pfstat/Makefile
index a89e00609971..7062f41a81f8 100644
--- a/sysutils/pfstat/Makefile
+++ b/sysutils/pfstat/Makefile
@@ -1,23 +1,24 @@
 PORTNAME=	pfstat
-PORTVERSION=	2.5
-PORTREVISION=	8
+DISTVERSION=	2.5
+PORTREVISION=	9
 CATEGORIES=	sysutils net
 MASTER_SITES=	https://www.benzedrine.ch/
 
-MAINTAINER=	ports@FreeBSD.org
+MAINTAINER=	rootnode+freebsd@wollwage.com
 COMMENT=	Utility to render graphical statistics for pf
 WWW=		https://www.benzedrine.ch/pfstat.html
 
 LICENSE=	BSD2CLAUSE
 
 LIB_DEPENDS=	libgd.so:graphics/gd \
+		libpfctl.so:net/libpfctl \
 		libpng.so:graphics/png
 
-USES=		iconv jpeg
-
+USES=		iconv jpeg localbase:ldflags
 USE_RC_SUBR=	pfstatd
 
-MAKE_ARGS=	"LD_GD=gd"
+CFLAGS+=	-I/usr/include/net
+LDFLAGS+=	-lpfctl
 
 PLIST_FILES=	bin/pfstat \
 		bin/pfstatd \
@@ -25,16 +26,13 @@ PLIST_FILES=	bin/pfstat \
 		share/man/man8/pfstatd.8.gz
 
 post-patch:
-	@${REINPLACE_CMD} -e 's|-lgd|-l$${LD_GD}|; s| -lttf||' \
-		${WRKSRC}/Makefile
 	@${REINPLACE_CMD} -e "s|/etc/|${PREFIX}/etc/|" \
 		${WRKSRC}/pfstat.[c8]
-	@${REINPLACE_CMD} 's|altq/|net/&|' ${WRKSRC}/pf.c
 
 do-install:
-	${INSTALL_PROGRAM} ${WRKSRC}/pfstat ${STAGEDIR}/${PREFIX}/bin
-	${INSTALL_PROGRAM} ${WRKSRC}/pfstatd/pfstatd ${STAGEDIR}/${PREFIX}/bin
-	${INSTALL_MAN} ${WRKSRC}/pfstat.8 ${STAGEDIR}/${PREFIX}/share/man/man8
-	${INSTALL_MAN} ${WRKSRC}/pfstatd/pfstatd.8 ${STAGEDIR}/${PREFIX}/share/man/man8
+	${INSTALL_PROGRAM} ${WRKSRC}/pfstat \
+		${WRKSRC}/pfstatd/pfstatd ${STAGEDIR}/${PREFIX}/bin
+	${INSTALL_MAN} ${WRKSRC}/pfstat.8 \
+		${WRKSRC}/pfstatd/pfstatd.8 ${STAGEDIR}/${PREFIX}/share/man/man8
 
 .include <bsd.port.mk>
diff --git a/sysutils/pfstat/files/patch-pf.c b/sysutils/pfstat/files/patch-pf.c
new file mode 100644
index 000000000000..a5ee52b7b909
--- /dev/null
+++ b/sysutils/pfstat/files/patch-pf.c
@@ -0,0 +1,50 @@
+--- pf.c.orig	2007-01-11 16:01:58 UTC
++++ pf.c
+@@ -46,6 +46,7 @@ static const char rcsid[] = "$Id: pf.c,v 1.1.1.1 2007/
+ #include <err.h>
+ #include <errno.h>
+ #include <fcntl.h>
++#include <libpfctl.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+@@ -167,20 +168,29 @@ query_counters(int fd, void (*cb)(int, const char *, i
+ static int
+ query_counters(int fd, void (*cb)(int, const char *, int, double))
+ {
+-	struct pf_status s;
+-	int i;
++	struct pfctl_status *s;
++	struct pfctl_status_counter *np;
+ 
+-	memset(&s, 0, sizeof(s));
+-	if (ioctl(fd, DIOCGETSTATUS, &s)) {
+-		fprintf(stderr, "ioctl: DIOCGETSTATUS: %s\n", strerror(errno));
++	s = pfctl_get_status(fd);
++	if (s  == NULL) {
++		fputs("pfctl_get_status failure.\n",stderr);
+ 		return (1);
+ 	}
+-	(*cb)(COL_TYPE_SINCE, "", 0, s.since);
+-	(*cb)(COL_TYPE_GLOBAL, "", 0, s.states);
+-	for (i = 0; i < FCNT_MAX; ++i)
+-		(*cb)(COL_TYPE_GLOBAL, "", 1 + i, s.fcounters[i]);
+-	for (i = 0; i < PFRES_MAX; ++i)
+-		(*cb)(COL_TYPE_GLOBAL, "", 1 + FCNT_MAX + i, s.counters[i]);
++
++	(*cb)(COL_TYPE_SINCE, "", 0, s->since);
++	(*cb)(COL_TYPE_GLOBAL, "", 0, s->states);
++
++	TAILQ_FOREACH(np, &s->fcounters, entry) {
++		if (np->id < FCNT_MAX)
++			(*cb)(COL_TYPE_GLOBAL, "", 1 + np->id, np->counter);
++	}
++
++	TAILQ_FOREACH(np, &s->counters, entry) {
++		if (np->id < PFRES_MAX)
++			(*cb)(COL_TYPE_GLOBAL, "", 1 + FCNT_MAX + np->id, np->counter);
++	}
++
++	pfctl_free_status(s);
+ 	return (0);
+ }


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6946b296.3aed2.3cbc3fdb>