]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
libbpf: Unmap rings when umem deleted
authorlic121 <lic121@chinatelecom.cn>
Tue, 1 Mar 2022 13:26:23 +0000 (13:26 +0000)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 27 Apr 2022 09:57:53 +0000 (11:57 +0200)
commit87ea788a1ed03dda182470958f7469be8f4b4e48
treeb79c2c27fac0f800ed31498aace736b17b94ae59
parentc9b53d54800403f42d59af8a57c0e244e11efdd7
libbpf: Unmap rings when umem deleted

BugLink: https://bugs.launchpad.net/bugs/1969110
[ Upstream commit 9c6e6a80ee741adf6cb3cfd8eef7d1554f91fceb ]

xsk_umem__create() does mmap for fill/comp rings, but xsk_umem__delete()
doesn't do the unmap. This works fine for regular cases, because
xsk_socket__delete() does unmap for the rings. But for the case that
xsk_socket__create_shared() fails, umem rings are not unmapped.

fill_save/comp_save are checked to determine if rings have already be
unmapped by xsk. If fill_save and comp_save are NULL, it means that the
rings have already been used by xsk. Then they are supposed to be
unmapped by xsk_socket__delete(). Otherwise, xsk_umem__delete() does the
unmap.

Fixes: 2f6324a3937f ("libbpf: Support shared umems between queues and devices")
Signed-off-by: Cheng Li <lic121@chinatelecom.cn>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20220301132623.GA19995@vscode.7~
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit adc4a1ed139e1b5d42947f4e1f7f631610c66d71)
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
tools/lib/bpf/xsk.c