When selecting pftop view option for either 'rules' or 'label', the
following errors are encountered.
- Error Reading status (DIOCGETSTATUS): File name too long
This error occurs after the first screen refresh when using the
default pf.conf file.
- Error Reading Anchor / (DIOCGETRULES): Device busy
This error typically occurs within 30 minutes of running.
Patch attached to resolve these errors - tested on OpenBSD 8.0-stable
(amd64).
Index: Makefile
===================================================================
RCS file: /cvs/ports/sysutils/pftop/Makefile,v
diff -u -p -u -p -r1.40 Makefile
--- Makefile 26 Sep 2026 13:57:19 -0000 1.40
+++ Makefile 2 Nov 2026 02:21:39 -0000
@@ -3,7 +3,7 @@
COMMENT= curses-based real time state and rule display for pf
DISTNAME= pftop-0.7
-REVISION= 21
+REVISION= 22
CATEGORIES= sysutils
HOMEPAGE= http://www.eee.metu.edu.tr/~canacar/pftop/
Index: patches/patch-engine_c
===================================================================
RCS file: /cvs/ports/sysutils/pftop/patches/patch-engine_c,v
diff -u -p -u -p -r1.4 patch-engine_c
--- patches/patch-engine_c 8 Jun 2024 21:15:27 -0000 1.4
+++ patches/patch-engine_c 2 Nov 2026 02:21:39 -0000
@@ -1,6 +1,5 @@
-Index: engine.c
---- engine.c.orig
-+++ engine.c
+--- engine.c.orig Wed Nov 7 15:35:44 2007
++++ engine.c Sat Oct 31 12:50:24 2026
@@ -34,11 +34,11 @@
#endif
@@ -24,7 +23,57 @@ Index: engine.c
{
int len;
va_list arg;
-@@ -510,7 +509,7 @@ add_view(field_view *fv)
+@@ -306,7 +305,7 @@ print_bar_title(field_def *fld)
+ void
+ print_fld_bar(field_def *fld, int value)
+ {
+- int i, tw, val, cur;
++ int i, tw, val;
+
+ if (fld->width < 1)
+ return;
+@@ -315,7 +314,7 @@ print_fld_bar(field_def *fld, int value)
+ tw = fld->arg / 2;
+
+ tb_start();
+- cur = 0;
++
+ for(i = 0; i < fld->width; i++) {
+ tw += fld->arg;
+
+@@ -342,9 +341,12 @@ void
+ print_title(void)
+ {
+ field_def **fp;
++ int nl = 0;
+
+ if (curr_view != NULL && curr_view->view != NULL) {
+ for (fp = curr_view->view; *fp != NULL; fp++) {
++ if ((*fp)->title[0] != '\0')
++ nl++;
+ switch((*fp)->align) {
+ case FLD_ALIGN_LEFT:
+ case FLD_ALIGN_RIGHT:
+@@ -357,8 +359,9 @@ print_title(void)
+ break;
+ }
+ }
++ if (nl)
++ end_line();
+ }
+- end_line();
+ }
+
+ /* view related functions */
+@@ -433,7 +436,6 @@ field_setup(void)
+ width -= fwid;
+ }
+
+- change = 0;
+ while (width > 0) {
+ change = 0;
+ for (fp = curr_view->view; *fp != NULL; fp++) {
+@@ -510,7 +512,7 @@ add_view(field_view *fv)
return;
ent->view = fv;
@@ -33,7 +82,7 @@ Index: engine.c
if (curr_view == NULL)
set_curr_view(ent);
-@@ -526,7 +525,7 @@ set_view(char *opt)
+@@ -526,7 +528,7 @@ set_view(char *opt)
if (opt == NULL || (len = strlen(opt)) == 0)
return 1;
@@ -42,7 +91,7 @@ Index: engine.c
v = ve->view;
if (strncasecmp(opt, v->name, len) == 0) {
if (vm)
-@@ -548,7 +547,7 @@ foreach_view(void (*callback)(field_view *))
+@@ -548,7 +550,7 @@ foreach_view(void (*callback)(field_view *))
{
struct view_ent *ve;
@@ -51,7 +100,7 @@ Index: engine.c
callback(ve->view);
}
}
-@@ -560,7 +559,7 @@ set_view_hotkey(int ch)
+@@ -560,7 +562,7 @@ set_view_hotkey(int ch)
field_view *v;
int key = tolower(ch);
@@ -60,7 +109,7 @@ Index: engine.c
v = ve->view;
if (key == v->hotkey) {
set_curr_view(ve);
-@@ -576,12 +575,12 @@ next_view(void)
+@@ -576,12 +578,12 @@ next_view(void)
{
struct view_ent *ve;
@@ -77,7 +126,7 @@ Index: engine.c
set_curr_view(ve);
}
-@@ -591,12 +590,12 @@ prev_view(void)
+@@ -591,12 +593,12 @@ prev_view(void)
{
struct view_ent *ve;
@@ -94,7 +143,7 @@ Index: engine.c
set_curr_view(ve);
}
-@@ -809,6 +808,9 @@ next_order(void)
+@@ -809,6 +811,9 @@ next_order(void)
{
order_type *o, *oc;
@@ -104,7 +153,16 @@ Index: engine.c
oc = curr_view->mgr->order_curr;
for (o = curr_view->mgr->order_list; o->name != NULL; o++) {
-@@ -987,7 +989,6 @@ message_set(const char *msg) {
+@@ -968,7 +973,7 @@ command_set(struct command *cmd, const char *init)
+ cmdbuf[0] = 0;
+ }
+ }
+- curr_message = NULL;
++ message_set(NULL);
+ curr_cmd = cmd;
+ need_update = 1;
+ return prev;
+@@ -987,7 +992,6 @@ message_set(const char *msg) {
int
msgprintf(char *format, ...)
@@ -112,3 +170,12 @@ Index: engine.c
{
static char buf[1024];
int len;
+@@ -1084,7 +1088,7 @@ keyboard(void)
+
+ if (curr_message != NULL) {
+ if (ch > 0) {
+- curr_message = NULL;
++ message_set(NULL);
+ need_update = 1;
+ }
+ }
Index: patches/patch-pftop_c
===================================================================
RCS file: /cvs/ports/sysutils/pftop/patches/patch-pftop_c,v
diff -u -p -u -p -r1.21 patch-pftop_c
--- patches/patch-pftop_c 26 Sep 2026 13:57:19 -0000 1.21
+++ patches/patch-pftop_c 2 Nov 2026 02:21:39 -0000
@@ -1,6 +1,5 @@
-Index: pftop.c
---- pftop.c.orig
-+++ pftop.c
+--- pftop.c.orig Wed Nov 7 15:36:46 2007
++++ pftop.c Sat Oct 31 13:30:34 2026
@@ -55,6 +55,7 @@
#include <err.h>
#include <errno.h>
@@ -244,6 +243,24 @@ Index: pftop.c
}
}
+@@ -708,7 +834,7 @@ read_states(void)
+ ps.ps_len = sbytes;
+ ps.ps_buf = (char *) state_buf;
+
+- if (ioctl(pf_dev, DIOCGETSTATES, &ps) < 0) {
++ if (ioctl(pf_dev, DIOCGETSTATES, &ps) == -1) {
+ msgprintf("Error Reading States (DIOCGETSTATES): %s",
+ strerror(errno));
+ return (-1);
+@@ -786,7 +912,7 @@ print_header(void)
+ int start = dispstart + 1;
+ int end = dispstart + maxprint;
+
+- if (ioctl(pf_dev, DIOCGETSTATUS, &status)) {
++ if (ioctl(pf_dev, DIOCGETSTATUS, &status) == -1) {
+ msgprintf("Error Reading status (DIOCGETSTATUS): %s",
strerror(errno));
+ return (-1);
+ }
@@ -865,7 +991,48 @@ tb_print_addr(struct pf_addr * addr, struct pf_addr *
tbprintf("/%u", unmask(mask, af));
}
@@ -365,7 +382,49 @@ Index: pftop.c
#else
#ifdef HAVE_RULE_NUMBER
print_fld_uint(FLD_RULE, s->rule.nr);
-@@ -1112,7 +1294,7 @@ read_anchor_rules(char *anchor)
+@@ -1065,6 +1247,13 @@ add_rule_alloc(u_int32_t nr)
+ int label_length;
+ #endif
+
++void
++close_pf_trans(u_int32_t ticket)
++{
++ if (ioctl(pf_dev, DIOCXEND, &ticket) == -1)
++ msgprintf("DIOCXEND: %s", strerror(errno));
++}
++
+ int
+ read_anchor_rules(char *anchor)
+ {
+@@ -1075,7 +1264,7 @@ read_anchor_rules(char *anchor)
+ #ifdef HAVE_RULESETS
+ strlcpy(pr.anchor, anchor, sizeof(pr.anchor));
+ #endif
+- if (ioctl(pf_dev, DIOCGETRULES, &pr)) {
++ if (ioctl(pf_dev, DIOCGETRULES, &pr) == -1) {
+ msgprintf("Error Reading Anchor %s (DIOCGETRULES): %s",
+ *anchor ? anchor : "/", strerror(errno));
+ return (-1);
+@@ -1087,9 +1276,10 @@ read_anchor_rules(char *anchor)
+
+ for (nr = 0; nr < num; ++nr) {
+ pr.nr = nr;
+- if (ioctl(pf_dev, DIOCGETRULE, &pr)) {
++ if (ioctl(pf_dev, DIOCGETRULE, &pr) == -1) {
+ msgprintf("Error Reading Rule (DIOCGETRULE): %s",
+ strerror(errno));
++ close_pf_trans(pr.ticket);
+ return (-1);
+ }
+ #ifdef HAVE_RULESETS
+@@ -1107,12 +1297,14 @@ read_anchor_rules(char *anchor)
+ rules[off + nr] = pr.rule;
+ }
+
++ close_pf_trans(pr.ticket);
++
+ return (num);
+ }
#ifdef HAVE_RULESETS
struct anchor_name {
@@ -374,7 +433,25 @@ Index: pftop.c
struct anchor_name *next;
u_int32_t ref;
};
-@@ -1429,7 +1611,7 @@ tb_print_fromto(struct pf_rule_addr *src, struct pf_ru
+@@ -1184,7 +1376,7 @@ read_rulesets(const char *path)
+
+ a->ref += len;
+
+- if (ioctl(pf_dev, DIOCGETRULESETS, &ruleset)) {
++ if (ioctl(pf_dev, DIOCGETRULESETS, &ruleset) == -1) {
+ msgprintf("Error Reading Rulesets (DIOCGETRULESETS): %s",
+ strerror(errno));
+ return (-1);
+@@ -1204,7 +1396,7 @@ read_rulesets(const char *path)
+
+ for (nr = 0; nr < ns; ++nr) {
+ ruleset.nr = nr;
+- if (ioctl(pf_dev, DIOCGETRULESET, &ruleset)) {
++ if (ioctl(pf_dev, DIOCGETRULESET, &ruleset) == -1) {
+ msgprintf("Error Reading Ruleset (DIOCGETRULESET): %s",
+ strerror(errno));
+ return (-1);
+@@ -1429,7 +1621,7 @@ tb_print_fromto(struct pf_rule_addr *src, struct pf_ru
#ifdef HAVE_RULE_UGID
void
tb_print_ugid(u_int8_t op, unsigned u1, unsigned u2,
@@ -383,7 +460,7 @@ Index: pftop.c
{
char a1[11], a2[11];
-@@ -1437,7 +1619,7 @@ tb_print_ugid(u_int8_t op, unsigned u1, unsigned u2,
+@@ -1437,7 +1629,7 @@ tb_print_ugid(u_int8_t op, unsigned u1, unsigned u2,
snprintf(a2, sizeof(a2), "%u", u2);
tbprintf("%s ", t);
@@ -392,7 +469,7 @@ Index: pftop.c
tb_print_op(op, "unknown", a2);
else
tb_print_op(op, a1, a2);
-@@ -1458,8 +1640,9 @@ tb_print_flags(u_int8_t f)
+@@ -1458,8 +1650,9 @@ tb_print_flags(u_int8_t f)
void
print_rule(struct pf_rule *pr)
{
@@ -404,7 +481,7 @@ Index: pftop.c
int numact = sizeof(actiontypes) / sizeof(char *);
#ifdef HAVE_PF_ROUTE
-@@ -1475,8 +1658,12 @@ print_rule(struct pf_rule *pr)
+@@ -1475,8 +1668,12 @@ print_rule(struct pf_rule *pr)
print_fld_str(FLD_LABEL, pr->label);
#endif
#ifdef HAVE_RULE_STATES
@@ -417,7 +494,7 @@ Index: pftop.c
#ifdef HAVE_INOUT_COUNT_RULES
print_fld_size(FLD_PKTS, pr->packets[0] + pr->packets[1]);
-@@ -1486,7 +1673,13 @@ print_rule(struct pf_rule *pr)
+@@ -1486,7 +1683,13 @@ print_rule(struct pf_rule *pr)
print_fld_size(FLD_BYTES, pr->bytes);
#endif
print_fld_uint(FLD_RULE, pr->nr);
@@ -432,7 +509,7 @@ Index: pftop.c
if (pr->quick)
print_fld_str(FLD_QUICK, "Quick");
-@@ -1555,7 +1748,9 @@ print_rule(struct pf_rule *pr)
+@@ -1555,7 +1758,9 @@ print_rule(struct pf_rule *pr)
#ifdef HAVE_PF_ROUTE
if (pr->rt > 0 && pr->rt < numroute) {
tbprintf("%s ", routetypes[pr->rt]);
@@ -442,7 +519,7 @@ Index: pftop.c
tbprintf("... ");
}
#endif
-@@ -1570,10 +1765,10 @@ print_rule(struct pf_rule *pr)
+@@ -1570,10 +1775,10 @@ print_rule(struct pf_rule *pr)
#ifdef HAVE_RULE_UGID
if (pr->uid.op)
tb_print_ugid(pr->uid.op, pr->uid.uid[0], pr->uid.uid[1],
@@ -455,7 +532,7 @@ Index: pftop.c
#endif
if (pr->flags || pr->flagset) {
-@@ -1729,12 +1924,19 @@ pfctl_insert_altq_node(struct pf_altq_node **root,
+@@ -1729,12 +1934,19 @@ pfctl_insert_altq_node(struct pf_altq_node **root,
prev->next = node;
}
}
@@ -481,7 +558,7 @@ Index: pftop.c
}
}
-@@ -1743,10 +1945,11 @@ pfctl_update_qstats(struct pf_altq_node **root, int *i
+@@ -1743,37 +1955,41 @@ pfctl_update_qstats(struct pf_altq_node **root, int *i
{
struct pf_altq_node *node;
struct pfioc_altq pa;
@@ -494,7 +571,11 @@ Index: pftop.c
*inserts = 0;
memset(&pa, 0, sizeof(pa));
-@@ -1757,13 +1960,15 @@ pfctl_update_qstats(struct pf_altq_node **root, int *i
+ memset(&pq, 0, sizeof(pq));
+ memset(&qstats, 0, sizeof(qstats));
+- if (ioctl(pf_dev, DIOCGETALTQS, &pa)) {
++ if (ioctl(pf_dev, DIOCGETALTQS, &pa) == -1) {
+ msgprintf("Error Reading Queues (DIOCGETALTQS): %s",
strerror(errno));
return (-1);
}
@@ -502,7 +583,8 @@ Index: pftop.c
num_queues = nr_queues = pa.nr;
for (nr = 0; nr < nr_queues; ++nr) {
pa.nr = nr;
- if (ioctl(pf_dev, DIOCGETALTQ, &pa)) {
+- if (ioctl(pf_dev, DIOCGETALTQ, &pa)) {
++ if (ioctl(pf_dev, DIOCGETALTQ, &pa) == -1) {
msgprintf("Error Reading Queue (DIOCGETALTQ): %s",
strerror(errno));
- return (-1);
@@ -511,8 +593,11 @@ Index: pftop.c
}
if (pa.altq.qid > 0) {
pq.nr = nr;
-@@ -1773,7 +1978,8 @@ pfctl_update_qstats(struct pf_altq_node **root, int *i
- if (ioctl(pf_dev, DIOCGETQSTATS, &pq)) {
+ pq.ticket = pa.ticket;
+ pq.buf = &qstats;
+ pq.nbytes = sizeof(qstats);
+- if (ioctl(pf_dev, DIOCGETQSTATS, &pq)) {
++ if (ioctl(pf_dev, DIOCGETQSTATS, &pq) == -1) {
msgprintf("Error Reading Queue (DIOCGETQSTATS):
%s",
strerror(errno));
- return (-1);
@@ -521,7 +606,7 @@ Index: pftop.c
}
qstats.valid = 1;
gettimeofday(&qstats.timestamp, NULL);
-@@ -1794,7 +2000,10 @@ pfctl_update_qstats(struct pf_altq_node **root, int *i
+@@ -1794,7 +2010,10 @@ pfctl_update_qstats(struct pf_altq_node **root, int *i
else
--num_queues;
}
@@ -533,3 +618,12 @@ Index: pftop.c
}
void
+@@ -2322,7 +2541,7 @@ main(int argc, char *argv[])
+ err(1, "open(\"/dev/pf\")");
+
+ /* preallocate existing states if possible */
+- if (ioctl(pf_dev, DIOCGETSTATUS, &status)) {
++ if (ioctl(pf_dev, DIOCGETSTATUS, &status) == -1) {
+ warn("DIOCGETSTATUS");
+ alloc_buf(0);
+ } else