]> www.infradead.org Git - users/willy/pagecache.git/commit
bpf: Remove unnecessary check when updating LPM trie
authorHou Tao <houtao1@huawei.com>
Fri, 6 Dec 2024 11:06:14 +0000 (19:06 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 6 Dec 2024 17:14:25 +0000 (09:14 -0800)
commit156c977c539e87e173f505b23989d7b0ec0bc7d8
tree1b3e5077c8522fe8112b843a9b54a8e593c4d06b
parente2cf913314b9543f4479788443c7e9009c6c56d8
bpf: Remove unnecessary check when updating LPM trie

When "node->prefixlen == matchlen" is true, it means that the node is
fully matched. If "node->prefixlen == 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 == trie->max_prefixlen" will always be false
when the check of "node->prefixlen == key->prefixlen" returns false.
Remove this unnecessary comparison.

Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Hou Tao <houtao1@huawei.com>
Link: https://lore.kernel.org/r/20241206110622.1161752-2-houtao@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/lpm_trie.c