git: aaa266adc32b - stable/14 - pf: Use a macro to get the hash row in pf_find_state_byid()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 15 Apr 2025 02:25:33 UTC
The branch stable/14 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=aaa266adc32b5e5a71aedbf5a1cf610049705553
commit aaa266adc32b5e5a71aedbf5a1cf610049705553
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-03-29 08:52:06 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-04-15 02:25:24 +0000
pf: Use a macro to get the hash row in pf_find_state_byid()
This seems a bit preferable to open-coding it. No functional change
intended.
Reviewed by: kp, glebius
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D49518
(cherry picked from commit 27f70efebf1d9424462f291e9d04e62272083aa7)
---
sys/net/pfvar.h | 3 ++-
sys/netpfil/pf/pf.c | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h
index 9ceed54fd52b..949cb36ee474 100644
--- a/sys/net/pfvar.h
+++ b/sys/net/pfvar.h
@@ -2117,7 +2117,8 @@ VNET_DECLARE(struct pf_idhash *, pf_idhash);
VNET_DECLARE(struct pf_srchash *, pf_srchash);
#define V_pf_srchash VNET(pf_srchash)
-#define PF_IDHASH(s) (be64toh((s)->id) % (V_pf_hashmask + 1))
+#define PF_IDHASHID(id) (be64toh(id) % (V_pf_hashmask + 1))
+#define PF_IDHASH(s) PF_IDHASHID((s)->id)
VNET_DECLARE(void *, pf_swi_cookie);
#define V_pf_swi_cookie VNET(pf_swi_cookie)
diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c
index b14ab91cd7aa..06761060b583 100644
--- a/sys/netpfil/pf/pf.c
+++ b/sys/netpfil/pf/pf.c
@@ -1658,7 +1658,7 @@ pf_find_state_byid(uint64_t id, uint32_t creatorid)
pf_counter_u64_add(&V_pf_status.fcounters[FCNT_STATE_SEARCH], 1);
- ih = &V_pf_idhash[(be64toh(id) % (V_pf_hashmask + 1))];
+ ih = &V_pf_idhash[PF_IDHASHID(id)];
PF_HASHROW_LOCK(ih);
LIST_FOREACH(s, &ih->states, entry)