Skip to content

Commit

Permalink
selftests: xsk: Fix socket creation retry
Browse files Browse the repository at this point in the history
The socket creation retry unnecessarily registered the umem once for
every retry. No reason to do this. It wastes memory and it might lead
to too many pages being locked at some point and the failure of a
test.

Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20210922075613.12186-10-magnus.karlsson@gmail.com
  • Loading branch information
Magnus Karlsson authored and Daniel Borkmann committed Sep 27, 2021
1 parent 872a118 commit 89013b8
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions tools/testing/selftests/bpf/xdpxceiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -919,18 +919,17 @@ static void thread_common_ops(struct test_spec *test, struct ifobject *ifobject)
u64 umem_sz = ifobject->umem->num_frames * ifobject->umem->frame_size;
u32 ctr = 0;
void *bufs;
int ret;

bufs = mmap(NULL, umem_sz, PROT_READ | PROT_WRITE, mmap_flags, -1, 0);
if (bufs == MAP_FAILED)
exit_with_error(errno);

while (ctr++ < SOCK_RECONF_CTR) {
int ret;

ret = xsk_configure_umem(&ifobject->umem_arr[i], bufs, umem_sz);
if (ret)
exit_with_error(-ret);
ret = xsk_configure_umem(&ifobject->umem_arr[i], bufs, umem_sz);
if (ret)
exit_with_error(-ret);

while (ctr++ < SOCK_RECONF_CTR) {
ret = xsk_configure_socket(&ifobject->xsk_arr[i], &ifobject->umem_arr[i],
ifobject, i);
if (!ret)
Expand Down

0 comments on commit 89013b8

Please sign in to comment.