]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
bpf: Handle in-place update for full LPM trie correctly
authorHou Tao <houtao1@huawei.com>
Fri, 6 Dec 2024 11:06:17 +0000 (19:06 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 14 Dec 2024 19:03:19 +0000 (20:03 +0100)
commit7218e441ad9d8f76cd76402035713c3c53865129
tree2095e94072e4c38f22701e9647c67ce8ffdf3aa9
parent6dc076a257a5343308eeb5e94f11112f608d929e
bpf: Handle in-place update for full LPM trie correctly

[ Upstream commit 532d6b36b2bfac5514426a97a4df8d103d700d43 ]

When a LPM trie is full, in-place updates of existing elements
incorrectly return -ENOSPC.

Fix this by deferring the check of trie->n_entries. For new insertions,
n_entries must not exceed max_entries. However, in-place updates are
allowed even when the trie is full.

Fixes: b95a5c4db09b ("bpf: add a longest prefix match trie map implementation")
Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Hou Tao <houtao1@huawei.com>
Link: https://lore.kernel.org/r/20241206110622.1161752-5-houtao@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/bpf/lpm_trie.c