git: 4d0186cd12a7 - stable/15 - libpfctl: Sort order of snl attribute parser

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Thu, 19 Feb 2026 16:00:44 UTC
The branch stable/15 has been updated by kp:

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

commit 4d0186cd12a79269d5ddb607eff8deebe4667f67
Author:     Eric A. Borisch <eborisch@gmail.com>
AuthorDate: 2026-02-12 00:26:26 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2026-02-19 16:00:19 +0000

    libpfctl: Sort order of  snl attribute parser
    
    snl atttribute parsers must be sorted by type, so PF_GS_BCOUNTERS
    (16) must follow PF_GF_PCOUNTERS (15). Fix ordering and add a call
    to SNL_VERIFY_PARSERS.
    
    Without this fix, byte counters reported by 'pfctl -s info' with
    a loginterface are always zero.
    
    PR:             291763
    MFC after:      1 week
    Reviewed by:    kp
    Signed-off-by:  eborisch@gmail.com
    
    (cherry picked from commit 363b57d579bafa8a52cfb5a1dcb98af821b1ecb6)
---
 lib/libpfctl/libpfctl.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c
index 0b3bb25163b8..74d319cd2ad1 100644
--- a/lib/libpfctl/libpfctl.c
+++ b/lib/libpfctl/libpfctl.c
@@ -389,12 +389,16 @@ static const struct snl_attr_parser ap_getstatus[] = {
 	{ .type = PF_GS_FCOUNTERS, .off = _OUT(fcounters), .cb = snl_attr_get_counters },
 	{ .type = PF_GS_SCOUNTERS, .off = _OUT(scounters), .cb = snl_attr_get_counters },
 	{ .type = PF_GS_CHKSUM, .off = _OUT(pf_chksum), .arg_u32 = PF_MD5_DIGEST_LENGTH, .cb = snl_attr_get_bytes },
-	{ .type = PF_GS_BCOUNTERS, .off = _OUT(bcounters), .arg_u32 = 2 * 2, .cb = snl_attr_get_uint64_array },
 	{ .type = PF_GS_PCOUNTERS, .off = _OUT(pcounters), .arg_u32 = 2 * 2 * 2, .cb = snl_attr_get_uint64_array },
+	{ .type = PF_GS_BCOUNTERS, .off = _OUT(bcounters), .arg_u32 = 2 * 2, .cb = snl_attr_get_uint64_array },
 };
 SNL_DECLARE_PARSER(getstatus_parser, struct genlmsghdr, snl_f_p_empty, ap_getstatus);
 #undef _OUT
 
+static const struct snl_hdr_parser *stat_parser[] = {
+	&getstatus_parser,
+};
+
 struct pfctl_status *
 pfctl_get_status_h(struct pfctl_handle *h)
 {
@@ -405,6 +409,8 @@ pfctl_get_status_h(struct pfctl_handle *h)
 	uint32_t seq_id;
 	int family_id;
 
+	SNL_VERIFY_PARSERS(stat_parser);
+
 	family_id = snl_get_genl_family(&h->ss, PFNL_FAMILY_NAME);
 	if (family_id == 0)
 		return (NULL);