From 74d2a0b79ffd8d43da61eaca36b39935594d8772 Mon Sep 17 00:00:00 2001 From: "R. Christian McDonald" Date: Tue, 13 Oct 2026 10:53:10 -0400 Subject: [PATCH] pf: Parse the GETSTATES state id as 64 bits The GETSTATES dump sends PF_ST_ID as a u64, but the request parser reads it as a u32 and rejects an id taken from the dump with EINVAL. Nothing in base sends PF_ST_ID. Parse and document it as a u64. Reviewed by: kp Fixes: 2cef62886dc7 ("pf: convert state retrieval to netlink") MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D60543 --- sys/netpfil/pf/pf_nl.c | 4 ++-- sys/netpfil/pf/pf_nl.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/netpfil/pf/pf_nl.c b/sys/netpfil/pf/pf_nl.c index 3ddd2308a318..d35545bbfe32 100644 --- a/sys/netpfil/pf/pf_nl.c +++ b/sys/netpfil/pf/pf_nl.c @@ -59,7 +59,7 @@ static bool nlattr_add_pf_threshold(struct nl_writer *, int, struct nl_parsed_state { uint8_t version; - uint32_t id; + uint64_t id; uint32_t creatorid; char ifname[IFNAMSIZ]; uint16_t proto; @@ -72,7 +72,7 @@ struct nl_parsed_state { #define _IN(_field) offsetof(struct genlmsghdr, _field) #define _OUT(_field) offsetof(struct nl_parsed_state, _field) static const struct nlattr_parser nla_p_state[] = { - { .type = PF_ST_ID, .off = _OUT(id), .cb = nlattr_get_uint32 }, + { .type = PF_ST_ID, .off = _OUT(id), .cb = nlattr_get_uint64 }, { .type = PF_ST_CREATORID, .off = _OUT(creatorid), .cb = nlattr_get_uint32 }, { .type = PF_ST_IFNAME, .arg = (const void *)IFNAMSIZ, .off = _OUT(ifname), .cb = nlattr_get_chara }, { .type = PF_ST_AF, .off = _OUT(af), .cb = nlattr_get_uint8 }, diff --git a/sys/netpfil/pf/pf_nl.h b/sys/netpfil/pf/pf_nl.h index c3c8da3571d3..d7adad2e8bd6 100644 --- a/sys/netpfil/pf/pf_nl.h +++ b/sys/netpfil/pf/pf_nl.h @@ -118,7 +118,7 @@ enum pfstate_peer_type_t { enum pfstate_type_t { PF_ST_UNSPEC, - PF_ST_ID = 1, /* u32, state id */ + PF_ST_ID = 1, /* u64, state id */ PF_ST_CREATORID = 2, /* u32, */ PF_ST_IFNAME = 3, /* string */ PF_ST_ORIG_IFNAME = 4, /* string */