From nobody Wed Sep 13 02:11:12 2023 X-Original-To: dev-commits-src-main@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 4RlkTF0ZZrz4sTXL; Wed, 13 Sep 2023 02:11:13 +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 4RlkTF07Y0z4Kpl; Wed, 13 Sep 2023 02:11:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694571073; 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=HxtmMMCY5zMzlIt/lqb3vWA63aySyiVnEmmSjFwlNa8=; b=M5+tVn5lOm7V0C9kQoarFTC+ezaIZ7xdOnCWEzaCXW8IeUK143dZBvb3FbK/zE2byLQrBb 3l/HTIThgAoIIBIWYVeGqF3KuZFSqhDAS+frOiMpqiD+RjD9kSw8JlW9YtksfP+hvUXl5Z 4cCAaelm6CpCXAsShxgwXm78Q5AE3XsQlpMUBsmNBP+v993tZZTSwoBnRfiblRjRLLku2c T7VxddrJLgkcOxc3PxSrp1W0SQd9AeepNUthcrcx/SYknG/0Xx+iE+/s2YmNKVnffg0Nv9 OyJm1LJh3kp1NUSXh3jFJHoIkTFUN8dE9La5/Tb8zDSM6/dpCKO6+YFDda/Aag== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694571073; a=rsa-sha256; cv=none; b=yzp23Wfqd12xEqhu7MyTN3ZryL26TYwEYL7CMPkplYZ8MCiAknN171jXnjeQEvCg275Eyz T83+JKCVSovvAusue5qmGVd5sI9JrSrxaaj1XR7mCefJ0LC4GHoxTYWZZnuwbIgd4S5+GL 8ETJvaK71Czdh3qGDMSwEYksqxci2u12SU4ZgqUVnyBbG2Yz5X3z+Iz2GhnMiCb0fTMqLQ modfqr6K9nInxrMLriUUiozJ3OWImIuUY6TGRIco9GidJ6ftd73Kh0pTdxkTTAu4bzTA6A TcPQEJWoEYF+XotfwPFhF9wHpc8SiuK628MYUQmdtr5NyJvYn/1Ou9XLYCyOjA== 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=1694571073; 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=HxtmMMCY5zMzlIt/lqb3vWA63aySyiVnEmmSjFwlNa8=; b=HMNZ25AZM4AlitE3HxIo6BuA+nO4kzi7Fhl3FmzCTRhXOyS7ZD3IiDnKFdFf74XN37B8ZZ UXjmeMBUbZU33ZHqShsKICTlRjaW8twFUpsnbfQ9UMKyVj5s5xmV//3AWGR+GwPEFSypt+ 15BO4jGIsjnrCC1hTWzxHISNwUNGl4ffXAYNExzBbb6mrzO8PRGcfyIcBBTWw7beTg7TWC DWwBhy0avFMnaQ6NPbIbf917LxFYJ7+jaCrHDT3T9qtSetftSYOZoEm4VHjQaMT4tBYcDA sy5dOuLEot7KdoM3FoyRtBvADQkZayaUYlYjnZPVXtxyFVpW3nSf5kBQiBwTiw== 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 4RlkTD6L3JzwR9; Wed, 13 Sep 2023 02:11:12 +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 38D2BCju012379; Wed, 13 Sep 2023 02:11:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38D2BC8i012376; Wed, 13 Sep 2023 02:11:12 GMT (envelope-from git) Date: Wed, 13 Sep 2023 02:11:12 GMT Message-Id: <202309130211.38D2BC8i012376@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Cy Schubert Subject: git: 7f5e3b9fa3d1 - main - ipfilter: Avoid allocating a new ipf token when not needed List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 7f5e3b9fa3d159b7f061b4d01a767cbe5d0527f3 Auto-Submitted: auto-generated The branch main has been updated by cy: URL: https://cgit.FreeBSD.org/src/commit/?id=7f5e3b9fa3d159b7f061b4d01a767cbe5d0527f3 commit 7f5e3b9fa3d159b7f061b4d01a767cbe5d0527f3 Author: Cy Schubert AuthorDate: 2023-09-12 20:29:29 +0000 Commit: Cy Schubert CommitDate: 2023-09-13 02:10:40 +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. MFC after: 2 weeks --- 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