libbpf: Restore umem state after socket create failure
authorCiara Loftus <ciara.loftus@intel.com>
Wed, 31 Mar 2021 06:12:17 +0000 (06:12 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Apr 2021 06:42:01 +0000 (08:42 +0200)
commit4cc9177b099e251bd1f7713a0517d622b1b442b1
tree4c3b46d75249669d2cf8e654f4a8c962ee7c500e
parent5aa7df172207e2b927803ec27a0e1aee5ac45eda
libbpf: Restore umem state after socket create failure

commit 43f1bc1efff16f553dd573d02eb7a15750925568 upstream.

If the call to xsk_socket__create fails, the user may want to retry the
socket creation using the same umem. Ensure that the umem is in the
same state on exit if the call fails by:
1. ensuring the umem _save pointers are unmodified.
2. not unmapping the set of umem rings that were set up with the umem
during xsk_umem__create, since those maps existed before the call to
xsk_socket__create and should remain in tact even in the event of
failure.

Fixes: 2f6324a3937f ("libbpf: Support shared umems between queues and devices")
Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210331061218.1647-3-ciara.loftus@intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
tools/lib/bpf/xsk.c