git: cc16c3c3cb5f - stable/14 - pfilctl: fix 'pfilctl hooks' when nothing is connected

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Tue, 16 Apr 2024 15:58:48 UTC
The branch stable/14 has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=cc16c3c3cb5f166a2c743077ac8ec37f6af5c24a

commit cc16c3c3cb5f166a2c743077ac8ec37f6af5c24a
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2024-03-28 21:10:15 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2024-04-16 15:56:13 +0000

    pfilctl: fix 'pfilctl hooks' when nothing is connected
    
    The 'hooks' command actually worked accidentially until now.  It used
    PFILIOC_LISTHEADS to determine current number of hooks.  This worked when
    at least one head had a hook connected to it.
    
    (cherry picked from commit 1bfe195143ffb6832ac6702e281964541554fcb3)
---
 sbin/pfilctl/pfilctl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sbin/pfilctl/pfilctl.c b/sbin/pfilctl/pfilctl.c
index c2fe04ecc777..81b6d9716dc9 100644
--- a/sbin/pfilctl/pfilctl.c
+++ b/sbin/pfilctl/pfilctl.c
@@ -151,8 +151,8 @@ listhooks(int argc __unused, char *argv[] __unused)
 	u_int nhooks, i;
 
 	plh.pio_nhooks = 0;
-	if (ioctl(dev, PFILIOC_LISTHEADS, &plh) != 0)
-		err(1, "ioctl(PFILIOC_LISTHEADS)");
+	if (ioctl(dev, PFILIOC_LISTHOOKS, &plh) != 0)
+		err(1, "ioctl(PFILIOC_LISTHOOKS)");
 retry:
 	plh.pio_hooks = calloc(plh.pio_nhooks, sizeof(struct pfilioc_hook));
 	if (plh.pio_hooks == NULL)