From nobody Mon Feb 9 06:24:39 2026 Received: from mail.nppct.ru (mail.nppct.ru [195.133.245.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9035A1D63C9 for ; Sun, 2 Feb 2025 07:50:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.133.245.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738482658; cv=none; b=rR9yvWkd5OuILBAHKqPrnSASQt0dh7klUJcmOM7hWHOiSOfH6cnKXfuDw9hMOn3d6Fw+Fhb3CBil1MVh1sxKvSFv2oUBriyHROJYnj92iSz9TEIgqoCs6C6D5hMeETAqLQiS+7RFngbVk34RYb8BEV9WxnFeLTT9QK61NDKDz4s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738482658; c=relaxed/simple; bh=kyQ9akgwVX8wxCsx2V+xoWQH+koRQPP7eyCpSK9HL0k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Sg07RpYC7hgvctDpBy7fqvjTSglKzLvg8qJLlerbXAH/4xuM+OsK4AQrDe9YU968DEhvuLyZy5MNxd1SELlctvS9I0bJ5uDOPa1HXQxZ9oYEb4tOgWrOmF3qxJuEcpQ2M+o4l+WFOu/0Yh35NyZRDamLDWC1d12ImzyRtakWD4c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nppct.ru; spf=pass smtp.mailfrom=nppct.ru; dkim=pass (1024-bit key) header.d=nppct.ru header.i=@nppct.ru header.b=MUj2kT4z; arc=none smtp.client-ip=195.133.245.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nppct.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nppct.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nppct.ru header.i=@nppct.ru header.b="MUj2kT4z" Received: from mail.nppct.ru (localhost [127.0.0.1]) by mail.nppct.ru (Postfix) with ESMTP id 128741C243E for ; Sun, 2 Feb 2025 10:50:55 +0300 (MSK) Authentication-Results: mail.nppct.ru (amavisd-new); dkim=pass (1024-bit key) reason="pass (just generated, assumed good)" header.d=nppct.ru DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nppct.ru; h= content-transfer-encoding:content-type:content-type:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:to:from:from; s=dkim; t=1738482654; x=1739346655; bh=ky Q9akgwVX8wxCsx2V+xoWQH+koRQPP7eyCpSK9HL0k=; b=MUj2kT4z+4QkVmcAGe KHbLnHMGZqfEBrqsPS1k71M9Yh61Rfaz6nRgB6ycGXyuzclzF8sKpigqOt5d9tyM v2IV1cAPsQw1BnSg+dM61dTKyX9r/vwsjs6fphhfFcM6LPwJ2aTEqmHIstpiPQuf gtfa4jFyTLCreseo5suIU1uWc= X-Virus-Scanned: Debian amavisd-new at mail.nppct.ru Received: from mail.nppct.ru ([127.0.0.1]) by mail.nppct.ru (mail.nppct.ru [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Udf1CTLlCM3m for ; Sun, 2 Feb 2025 10:50:54 +0300 (MSK) Received: from localhost.localdomain (unknown [87.249.24.51]) by mail.nppct.ru (Postfix) with ESMTPSA id 8D0761C19B7; Sun, 2 Feb 2025 10:50:25 +0300 (MSK) From: Alexey Nepomnyashih To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Alexey Nepomnyashih , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , bpf@vger.kernel.org, "Paul E. McKenney" , Frederic Weisbecker , Neeraj Upadhyay , Josh Triplett , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Joel Fernandes , rcu@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org, =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= , Hou Tao Subject: [PATCH 6.1 15/16] bpf: Remove unnecessary check when updating LPM trie Date: Sun, 2 Feb 2025 07:46:52 +0000 Message-ID: <20250202074709.932174-16-sdl@nppct.ru> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250202074709.932174-1-sdl@nppct.ru> References: <20250202074709.932174-1-sdl@nppct.ru> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable From: Hou Tao commit 156c977c539e87e173f505b23989d7b0ec0bc7d8 upstream. When "node->prefixlen =3D=3D matchlen" is true, it means that the node is fully matched. If "node->prefixlen =3D=3D key->prefixlen" is false, it means the prefix length of key is greater than the prefix length of node, otherwise, matchlen will not be equal with node->prefixlen. However, it also implies that the prefix length of node must be less than max_prefixlen. Therefore, "node->prefixlen =3D=3D trie->max_prefixlen" will always be false when the check of "node->prefixlen =3D=3D key->prefixlen" returns false. Remove this unnecessary comparison. Reviewed-by: Toke H=C3=B8iland-J=C3=B8rgensen Acked-by: Daniel Borkmann Signed-off-by: Hou Tao Link: https://lore.kernel.org/r/20241206110622.1161752-2-houtao@huaweicloud= .com Signed-off-by: Alexei Starovoitov Signed-off-by: Alexey Nepomnyashih --- kernel/bpf/lpm_trie.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/bpf/lpm_trie.c b/kernel/bpf/lpm_trie.c index fd6e31e72290..6c96241f49a4 100644 --- a/kernel/bpf/lpm_trie.c +++ b/kernel/bpf/lpm_trie.c @@ -358,8 +358,7 @@ static int trie_update_elem(struct bpf_map *map, matchlen =3D longest_prefix_match(trie, node, key); =20 if (node->prefixlen !=3D matchlen || - node->prefixlen =3D=3D key->prefixlen || - node->prefixlen =3D=3D trie->max_prefixlen) + node->prefixlen =3D=3D key->prefixlen) break; =20 next_bit =3D extract_bit(key->data, node->prefixlen); --=20 2.43.0