diff options
| author | Eric A. Borisch <eborisch@gmail.com> | 2026-02-12 00:26:26 +0000 |
|---|---|---|
| committer | Kristof Provost <kp@FreeBSD.org> | 2026-02-12 16:05:16 +0000 |
| commit | 363b57d579bafa8a52cfb5a1dcb98af821b1ecb6 (patch) | |
| tree | ebc25909d04e3a73c8cfd589e721dc9460838c14 | |
| parent | 5fa297f4bcd277dca7eef03e68363fb1e721799e (diff) | |
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
| -rw-r--r-- | lib/libpfctl/libpfctl.c | 8 |
1 files changed, 7 insertions, 1 deletions
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); |
