From nobody Wed Sep 27 02:22:30 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RwL3q20z3z4tkcP; Wed, 27 Sep 2023 02:22:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RwL3q1Tf8z4YgN; Wed, 27 Sep 2023 02:22:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695781351; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5iWQDn8e6OXWlNF37T1iqx4konGhTkC9C/pAErS7wG0=; b=CChdWRRFQDGCVriw5Kru6kfQ5MZpG6FPFnBAg/bjnGxIbjdh3kofJYK+F/nfpG80I5quGW U0Fr0UddJDUAcIeBRHSXMWPjVYpzg0U7cygEyeMF7ALy/GlVkcuK35Q005R7HjJsjWMkOE Qh3kTYMNeR04342y4m8ESdqdM5A49hbosK9BgtYV5z7vr4ziOdVPDATJFBCcPxj5C+ked1 lX/kdNf1tzmo+UFhcL/zWmy9rLpK/ssQclOAVHrcXUeQk57dtfONXQE691JJbIxSZvM90t ZHlHniL9J9mAKejzlyxKIxv+vNKxAiWlsp4BBqOBnc2ipAjlUOM3C9tLzA6eTQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1695781351; a=rsa-sha256; cv=none; b=rmkoBs5GaN1PYcInsFVh3JS2Uv7fJoq0qW2z/5/5p/jCu5HAE9jgttgZadENAUIUyNRaur wgOXO7t8YmI881e3+klAhvN8Jbk9J6TsneTWtx2BEbRFd3/7zMEl8HPi3+SIPkZdAuO5YY LgLCrmMfPI6A3sTw9aRkWqYFKW2aZ+6u2gEXCiCpbyYrMPP5H/W2q1RU/gVFuyM27LJByI 7zxn8/AXD6umdgPy0mD9R6kB7Ub2+3tyn5EAIx21VJSpOsbLrn3027MwuuHgU7xXgvSsJc qOjgDLgO0oWO60xu2sfZNPB51Bl6ZVzdMTMvo2OiEWgNvnz2fteVdJQ7GyfifQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695781351; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5iWQDn8e6OXWlNF37T1iqx4konGhTkC9C/pAErS7wG0=; b=RNlVhb+pvK/JCkKJUFBdmgnoOHX0dHPfXOlqN7veb95fHHppq4d9KNjtIQ+/ZjPMGhYA3o sbjbzGAKK3bHQZMqQ+Z2iKqcQJUbFHVlwzwylSBHqUSwSfw90A7wUHnWDy/e90hGU96RLA yWnyKLtRAyTDH3cF0uHeNY2pGRMZhnlH7t5JR1rMS++tO3L4sYnIkTGkHfNoGT5IwDQP/J LenxVJb3GENGqo+VCJZJZbmsIP1wrfJ3eNi7uYzZZx+MkC42bY3V7VfPKQpd7HYYnpp6Fg Fk9+gJlxsdiOEZ0Y4wHVtsEI4rB+ArtWzCAmUZwKyUcCQRS/74gNlcJ+n2lQNQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RwL3q0YDFz61M; Wed, 27 Sep 2023 02:22:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 38R2MUb9078904; Wed, 27 Sep 2023 02:22:30 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38R2MUPm078873; Wed, 27 Sep 2023 02:22:30 GMT (envelope-from git) Date: Wed, 27 Sep 2023 02:22:30 GMT Message-Id: <202309270222.38R2MUPm078873@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Cy Schubert Subject: git: b083794291d2 - stable/12 - ipfilter: Avoid allocating a new ipf token when not needed List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cy X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: b083794291d245f05940552a37f7d5c5badc2d17 Auto-Submitted: auto-generated The branch stable/12 has been updated by cy: URL: https://cgit.FreeBSD.org/src/commit/?id=b083794291d245f05940552a37f7d5c5badc2d17 commit b083794291d245f05940552a37f7d5c5badc2d17 Author: Cy Schubert AuthorDate: 2023-09-12 20:29:29 +0000 Commit: Cy Schubert CommitDate: 2023-09-27 02:22:26 +0000 ipfilter: Avoid allocating a new ipf token when not needed Only allocate a new ipftoken_t if one cannot be found. This eliminates allocating unnecessary token structures that will never be used when performing simple lookups for existing token structures. (cherry picked from commit 7f5e3b9fa3d159b7f061b4d01a767cbe5d0527f3) --- sys/netpfil/ipfilter/netinet/fil.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/sys/netpfil/ipfilter/netinet/fil.c b/sys/netpfil/ipfilter/netinet/fil.c index 3cf9111340a3..455da5d6fa71 100644 --- a/sys/netpfil/ipfilter/netinet/fil.c +++ b/sys/netpfil/ipfilter/netinet/fil.c @@ -7461,10 +7461,6 @@ 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) && @@ -7473,6 +7469,10 @@ 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) { @@ -7484,11 +7484,6 @@ 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