Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Feb 2026 21:39:34 +0000
From:      Kristof Provost <kp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Cc:        Eric A. Borisch <eborisch@gmail.com>
Subject:   git: 363b57d579ba - main - libpfctl: Sort order of  snl attribute parser
Message-ID:  <698e4896.1c5d6.2e11b88d@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by kp:

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

commit 363b57d579bafa8a52cfb5a1dcb98af821b1ecb6
Author:     Eric A. Borisch <eborisch@gmail.com>
AuthorDate: 2026-02-12 00:26:26 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2026-02-12 16:05:16 +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
---
 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 63f61932519c..4f4a7fe57002 100644
--- a/lib/libpfctl/libpfctl.c
+++ b/lib/libpfctl/libpfctl.c
@@ -389,14 +389,18 @@ 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 },
 	{ .type = PF_GS_NCOUNTERS, .off = _OUT(ncounters), .cb = snl_attr_get_counters },
 	{ .type = PF_GS_FRAGMENTS, .off = _OUT(fragments), .cb = snl_attr_get_uint64 },
 };
 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)
 {
@@ -407,6 +411,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);


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?698e4896.1c5d6.2e11b88d>