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
This commit is contained in:
Eric A. Borisch
2026-02-11 18:26:26 -06:00
committed by Kristof Provost
parent 5fa297f4bc
commit 363b57d579
+7 -1
View File
@@ -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);