From nobody Wed Sep 27 02:21:10 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 4RwL2H1YvJz4tkKT; Wed, 27 Sep 2023 02:21:11 +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 4RwL2H18Jjz4Xn8; Wed, 27 Sep 2023 02:21:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695781271; 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=ENF8uCYOO5QqYifGyV4qLMMKuyJywjudKQXAzgECGPM=; b=nHnxGo/lBnddz92G55dv8oPf8LuNQ1MJurZbKq/HwjXV1gaGA/U3l8LUX3GJkiM2EubptV xeJ6mvOOEj9Lb51J6LzhQOBo5lRoc7Z6sBdJnd8MxN7xMdYMU6dxVNqRlAJZ+1MabySC6y bSIcUE/y+rQEtJi9AfQXHLM23KZZaB5vkLpMvMewJe31xJXUzEkWtVk5nKNhXWaNcm8NsI YlckABwQ0RINJE0bJlxSq9Jf/FXI8MLAwnN2Ve+wmEEhR2wUDr2DFKbDqyVWMDpXhBPPHW tPlcCAjLaqzZH50zx7XhNXLAVL3gCrEp6Eo6snS6Fk8bR6cqCAV03I1JR2y8EA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1695781271; a=rsa-sha256; cv=none; b=LdRfwfCvk+tBjwH+bOIbFUE3Lo/UShuvC04WQWfewXT87AmkEVtgVcatFL5A/Wj6OC59x0 Yd5U1cD0989BVyW4qOizpY7F+XVjoRIl5qkJOmvjXJNJ71reFvBZwxAujzzGRd4zKVy6YU mdugYcv4SWnJw5s+QJICvdua4p0H6q0HsPSGev3pz6huUGxDsvGwUdQI3QLRcrciWOqtk+ xz4IwswhCcX8duGho2JE2R5/3h8QGbAinInasKfAjhYCBtnolNkVEubxST1M0nIPOyhsEz 2IpWuSnAUODNy9Rpi67qVhp4CYrOakMvdW9HpJ1r+BJ3bOTWceuOzYv/88XdiQ== 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=1695781271; 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=ENF8uCYOO5QqYifGyV4qLMMKuyJywjudKQXAzgECGPM=; b=M/45d0klWTcYfIcgJ+URvb6EJut+ygSwq/qkQPlr006TU+czNAhqX5MkekvfhnTG+9J1hy 2Gq4w1puymMPbZtMDVfYTGujOrPx3IG2NYP9Cjrq0UyQv7ZjoGjlUdkz/ZcWd3BeoAbiXn XvReQFt4h/KKf7TyjVanK9uG2v7S+SU/J898kTz8lu/BqDuXqlhMSG3gR/f4f+JngqL1gt PvrSYJ4rHvAT0k3Oj1i9EABQcA10jQ54TAW3kw1CstSYkG+dhYO0Bib1tWVz1TpnPbG4ga lWtSFKBo+cQ8oUmbwBCit7KU6dqUPFJqi7P99okyDw+AzamwHNYn0RMwWZjDXQ== 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 4RwL2H0C5gz6R1; Wed, 27 Sep 2023 02:21:11 +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 38R2LAsi073330; Wed, 27 Sep 2023 02:21:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38R2LAJq073327; Wed, 27 Sep 2023 02:21:10 GMT (envelope-from git) Date: Wed, 27 Sep 2023 02:21:10 GMT Message-Id: <202309270221.38R2LAJq073327@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: 7642bb1c5325 - stable/14 - 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/14 X-Git-Reftype: branch X-Git-Commit: 7642bb1c5325ddc5b38339fd81309f00beea1ff2 Auto-Submitted: auto-generated The branch stable/14 has been updated by cy: URL: https://cgit.FreeBSD.org/src/commit/?id=7642bb1c5325ddc5b38339fd81309f00beea1ff2 commit 7642bb1c5325ddc5b38339fd81309f00beea1ff2 Author: Cy Schubert AuthorDate: 2023-09-12 20:29:29 +0000 Commit: Cy Schubert CommitDate: 2023-09-27 02:21:03 +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