git: bad971197256 - stable/14 - Revert "ipfilter: Avoid allocating a new ipf token when not needed"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 10 Aug 2025 05:24:43 UTC
The branch stable/14 has been updated by cy:
URL: https://cgit.FreeBSD.org/src/commit/?id=bad971197256729a12c067f1e1f5f7e73dd6098e
commit bad971197256729a12c067f1e1f5f7e73dd6098e
Author: Cy Schubert <cy@FreeBSD.org>
AuthorDate: 2025-07-07 16:50:27 +0000
Commit: Cy Schubert <cy@FreeBSD.org>
CommitDate: 2025-08-10 05:23:57 +0000
Revert "ipfilter: Avoid allocating a new ipf token when not needed"
malloc() outside of a write lock will reduce potential contention.
MFC after: 3 days
This reverts commit 7f5e3b9fa3d159b7f061b4d01a767cbe5d0527f3.
(cherry picked from commit cf9b6857545371ab5becc6a785c62bc844cb2f94)
---
sys/netpfil/ipfilter/netinet/fil.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/sys/netpfil/ipfilter/netinet/fil.c b/sys/netpfil/ipfilter/netinet/fil.c
index 76fde8622498..18ef46e25805 100644
--- a/sys/netpfil/ipfilter/netinet/fil.c
+++ b/sys/netpfil/ipfilter/netinet/fil.c
@@ -7459,6 +7459,10 @@ ipf_token_find(ipf_main_softc_t *softc, int type, int uid, void *ptr)
{
ipftoken_t *it, *new;
+ KMALLOC(new, ipftoken_t *);
+ if (new != NULL)
+ bzero((char *)new, sizeof(*new));
+
WRITE_ENTER(&softc->ipf_tokens);
for (it = softc->ipf_token_head; it != NULL; it = it->ipt_next) {
if ((ptr == it->ipt_ctx) && (type == it->ipt_type) &&
@@ -7467,10 +7471,6 @@ ipf_token_find(ipf_main_softc_t *softc, int type, int uid, void *ptr)
}
if (it == NULL) {
- KMALLOC(new, ipftoken_t *);
- if (new != NULL)
- bzero((char *)new, sizeof(*new));
-
it = new;
new = NULL;
if (it == NULL) {
@@ -7482,6 +7482,11 @@ ipf_token_find(ipf_main_softc_t *softc, int type, int uid, void *ptr)
it->ipt_type = type;
it->ipt_ref = 1;
} else {
+ if (new != NULL) {
+ KFREE(new);
+ new = NULL;
+ }
+
if (it->ipt_complete > 0)
it = NULL;
else