From nobody Wed Sep 27 02:22:14 2023 X-Original-To: dev-commits-src-all@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 4RwL3V3qXBz4tkYq; Wed, 27 Sep 2023 02:22:14 +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 4RwL3V3N5Dz4Y8P; Wed, 27 Sep 2023 02:22:14 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695781334; 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=jkwMF/DhKb60QOA+az8me8BRJCh0Kpw87JmBTC2gKuY=; b=ufzaUROy5OXPTkGQYi1xIDeDbhJME+9EbHG8v/c/K8aDZosdtDaENd+Z1Rch9NHf+//YL8 yTacIDf7+Y/KvY5uHo5N8RUn7TAB7OeXPJYjzSnLAwBnbnx1uTti7gGEZasprsLmom66WG 4cmECe+BKFOnhsceJQ0IG0W/yinyW6y3jTEQr9C5/hGVg2fFCdK21XJhj9/SbxFOnXIYjB OoPm2I6rcAhPVIP1q/yZwtl9dW8oSCtuzCw+KmVIcy2I9CuPIIVqL9pZNpQyHxi+wEG9i0 XQChpEp6xNETnmP0U6YIiiGZHMKm975QhLpOJmO8ftg6Q1jZKgwOcqj5kRpr7A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1695781334; a=rsa-sha256; cv=none; b=ZdHwqKtdDYMRmNKBvq1zbylbQlq+JsBPpJeRNtyqD7AGc6nqtSm4E8DnXVGswZC4t5nEAq Hb/Svmhuv0qpJXFf1y4kHkqSzXsG7NGTAgxzDTl5yzOgE+zpi4vncXAIsoDxvY9rn7zaMH axo2YuR5Tw/jNIWNC7fmwQ+2776QNtnThqhcX3KrUaspuK9lDTfCWbX+z9qExZCMb1xwN1 rEnhmMJM/WBXRjZQLQSX4d4hHDgBHFYtOivT4ZmHphTTan5JXIABnZ3yrFJ5pPbHaD3rjU xcCftoSw0WrBe1yRmw/WahiXZA/rfRCWAEo4zwLV3hotS8RJKauSdl1q/MsRtw== 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=1695781334; 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=jkwMF/DhKb60QOA+az8me8BRJCh0Kpw87JmBTC2gKuY=; b=ZlNV1hV/x2iytvNLJ3DYN+iGP7dnO6CB0JUIwsm0g4+ws/L2wzv8aU7vJF3SP7Z51NVlPT AzulfkNvmu67oqYeSmfip138x81siNEN+MDcL9jf2co6xrlFkvWWc63JGLeG6cyEUJk1II u7aiaxnr5fQDPYnqnktnoX19mRUqoWSAupL09rasZ5yK1mM6bgg7JHZRdiUJSAWiiFu+aM MP6MhejOFdRf+/vbR6gJk0g6jSzU5ZH/tYIdyqDefz7ZwhDZ2qS0X3jsBLhjR2RAAQPbVe ipSvKQXgOtcqSBN3MfK1Bvo7KNjp27VpPkbEjIA/eqHD+F+/CgO/XXTaqUdzpw== 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 4RwL3V2Qj0z5rh; Wed, 27 Sep 2023 02:22:14 +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 38R2ME7w075725; Wed, 27 Sep 2023 02:22:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38R2ME4B075722; Wed, 27 Sep 2023 02:22:14 GMT (envelope-from git) Date: Wed, 27 Sep 2023 02:22:14 GMT Message-Id: <202309270222.38R2ME4B075722@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: c22fec731ef0 - stable/13 - ipfilter: Avoid allocating a new ipf token when not needed List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/13 X-Git-Reftype: branch X-Git-Commit: c22fec731ef037ece2f8c746fe93db02bc07dc74 Auto-Submitted: auto-generated The branch stable/13 has been updated by cy: URL: https://cgit.FreeBSD.org/src/commit/?id=c22fec731ef037ece2f8c746fe93db02bc07dc74 commit c22fec731ef037ece2f8c746fe93db02bc07dc74 Author: Cy Schubert AuthorDate: 2023-09-12 20:29:29 +0000 Commit: Cy Schubert CommitDate: 2023-09-27 02:22:05 +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 7dee98d0c1ad..b04ec3496a65 100644 --- a/sys/netpfil/ipfilter/netinet/fil.c +++ b/sys/netpfil/ipfilter/netinet/fil.c @@ -7460,10 +7460,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) && @@ -7472,6 +7468,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) { @@ -7483,11 +7483,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