git: b43db87c97dd - stable/12 - pf: getstates: avoid taking the hashrow lock if the row is empty
Kristof Provost
kp at FreeBSD.org
Fri Jul 9 13:24:26 UTC 2021
The branch stable/12 has been updated by kp:
URL: https://cgit.FreeBSD.org/src/commit/?id=b43db87c97dd396da866919842715aef7b84daba
commit b43db87c97dd396da866919842715aef7b84daba
Author: Kristof Provost <kp at FreeBSD.org>
AuthorDate: 2021-06-29 09:34:49 +0000
Commit: Kristof Provost <kp at FreeBSD.org>
CommitDate: 2021-07-09 08:08:32 +0000
pf: getstates: avoid taking the hashrow lock if the row is empty
Reviewed by: mjg
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D30946
(cherry picked from commit a19ff8ce9b58548a5f965db2c46eb03c38b15edb)
---
sys/netpfil/pf/pf_ioctl.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c
index 0ce39db05c15..92b0cda8261e 100644
--- a/sys/netpfil/pf/pf_ioctl.c
+++ b/sys/netpfil/pf/pf_ioctl.c
@@ -5122,6 +5122,10 @@ pf_getstates(struct pfioc_nv *nv)
for (int i = 0; i < pf_hashmask; i++) {
struct pf_idhash *ih = &V_pf_idhash[i];
+ /* Avoid taking the lock if there are no states in the row. */
+ if (LIST_EMPTY(&ih->states))
+ continue;
+
PF_HASHROW_LOCK(ih);
LIST_FOREACH(s, &ih->states, entry) {
if (s->timeout == PFTM_UNLINKED)
More information about the dev-commits-src-all
mailing list