Commit 085dcccf authored by Magnus Karlsson's avatar Magnus Karlsson Committed by Alexei Starovoitov

selftests/xsk: print correct error codes when exiting

Print the correct error codes when exiting the test suite due to some
terminal error. Some of these had a switched sign and some of them
printed zero instead of errno.

Fixes: facb7cb2 ("selftests/bpf: Xsk selftests - SKB POLL, NOPOLL")
Signed-off-by: default avatarMagnus Karlsson <magnus.karlsson@intel.com>
Acked-by: default avatarMaciej Fijalkowski <maciej.fijalkowski@intel.com>
Link: https://lore.kernel.org/r/20230111093526.11682-5-magnus.karlsson@gmail.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 1e04f23b
...@@ -350,7 +350,7 @@ static bool ifobj_zc_avail(struct ifobject *ifobject) ...@@ -350,7 +350,7 @@ static bool ifobj_zc_avail(struct ifobject *ifobject)
umem = calloc(1, sizeof(struct xsk_umem_info)); umem = calloc(1, sizeof(struct xsk_umem_info));
if (!umem) { if (!umem) {
munmap(bufs, umem_sz); munmap(bufs, umem_sz);
exit_with_error(-ENOMEM); exit_with_error(ENOMEM);
} }
umem->frame_size = XSK_UMEM__DEFAULT_FRAME_SIZE; umem->frame_size = XSK_UMEM__DEFAULT_FRAME_SIZE;
ret = xsk_configure_umem(umem, bufs, umem_sz); ret = xsk_configure_umem(umem, bufs, umem_sz);
...@@ -936,7 +936,7 @@ static int receive_pkts(struct test_spec *test, struct pollfd *fds) ...@@ -936,7 +936,7 @@ static int receive_pkts(struct test_spec *test, struct pollfd *fds)
if (ifobj->use_poll) { if (ifobj->use_poll) {
ret = poll(fds, 1, POLL_TMOUT); ret = poll(fds, 1, POLL_TMOUT);
if (ret < 0) if (ret < 0)
exit_with_error(-ret); exit_with_error(errno);
if (!ret) { if (!ret) {
if (!is_umem_valid(test->ifobj_tx)) if (!is_umem_valid(test->ifobj_tx))
...@@ -963,7 +963,7 @@ static int receive_pkts(struct test_spec *test, struct pollfd *fds) ...@@ -963,7 +963,7 @@ static int receive_pkts(struct test_spec *test, struct pollfd *fds)
if (xsk_ring_prod__needs_wakeup(&umem->fq)) { if (xsk_ring_prod__needs_wakeup(&umem->fq)) {
ret = poll(fds, 1, POLL_TMOUT); ret = poll(fds, 1, POLL_TMOUT);
if (ret < 0) if (ret < 0)
exit_with_error(-ret); exit_with_error(errno);
} }
ret = xsk_ring_prod__reserve(&umem->fq, rcvd, &idx_fq); ret = xsk_ring_prod__reserve(&umem->fq, rcvd, &idx_fq);
} }
...@@ -1015,7 +1015,7 @@ static int __send_pkts(struct ifobject *ifobject, u32 *pkt_nb, struct pollfd *fd ...@@ -1015,7 +1015,7 @@ static int __send_pkts(struct ifobject *ifobject, u32 *pkt_nb, struct pollfd *fd
if (timeout) { if (timeout) {
if (ret < 0) { if (ret < 0) {
ksft_print_msg("ERROR: [%s] Poll error %d\n", ksft_print_msg("ERROR: [%s] Poll error %d\n",
__func__, ret); __func__, errno);
return TEST_FAILURE; return TEST_FAILURE;
} }
if (ret == 0) if (ret == 0)
...@@ -1024,7 +1024,7 @@ static int __send_pkts(struct ifobject *ifobject, u32 *pkt_nb, struct pollfd *fd ...@@ -1024,7 +1024,7 @@ static int __send_pkts(struct ifobject *ifobject, u32 *pkt_nb, struct pollfd *fd
} }
if (ret <= 0) { if (ret <= 0) {
ksft_print_msg("ERROR: [%s] Poll error %d\n", ksft_print_msg("ERROR: [%s] Poll error %d\n",
__func__, ret); __func__, errno);
return TEST_FAILURE; return TEST_FAILURE;
} }
} }
...@@ -1323,18 +1323,18 @@ static void thread_common_ops(struct test_spec *test, struct ifobject *ifobject) ...@@ -1323,18 +1323,18 @@ static void thread_common_ops(struct test_spec *test, struct ifobject *ifobject)
if (ifobject->xdp_flags & XDP_FLAGS_SKB_MODE) { if (ifobject->xdp_flags & XDP_FLAGS_SKB_MODE) {
if (opts.attach_mode != XDP_ATTACHED_SKB) { if (opts.attach_mode != XDP_ATTACHED_SKB) {
ksft_print_msg("ERROR: [%s] XDP prog not in SKB mode\n"); ksft_print_msg("ERROR: [%s] XDP prog not in SKB mode\n");
exit_with_error(-EINVAL); exit_with_error(EINVAL);
} }
} else if (ifobject->xdp_flags & XDP_FLAGS_DRV_MODE) { } else if (ifobject->xdp_flags & XDP_FLAGS_DRV_MODE) {
if (opts.attach_mode != XDP_ATTACHED_DRV) { if (opts.attach_mode != XDP_ATTACHED_DRV) {
ksft_print_msg("ERROR: [%s] XDP prog not in DRV mode\n"); ksft_print_msg("ERROR: [%s] XDP prog not in DRV mode\n");
exit_with_error(-EINVAL); exit_with_error(EINVAL);
} }
} }
ret = xsk_socket__update_xskmap(ifobject->xsk->xsk, ifobject->xsk_map_fd); ret = xsk_socket__update_xskmap(ifobject->xsk->xsk, ifobject->xsk_map_fd);
if (ret) if (ret)
exit_with_error(-ret); exit_with_error(errno);
} }
static void *worker_testapp_validate_tx(void *arg) static void *worker_testapp_validate_tx(void *arg)
...@@ -1541,7 +1541,7 @@ static void swap_xsk_resources(struct ifobject *ifobj_tx, struct ifobject *ifobj ...@@ -1541,7 +1541,7 @@ static void swap_xsk_resources(struct ifobject *ifobj_tx, struct ifobject *ifobj
ret = xsk_socket__update_xskmap(ifobj_rx->xsk->xsk, ifobj_rx->xsk_map_fd); ret = xsk_socket__update_xskmap(ifobj_rx->xsk->xsk, ifobj_rx->xsk_map_fd);
if (ret) if (ret)
exit_with_error(-ret); exit_with_error(errno);
} }
static void testapp_bpf_res(struct test_spec *test) static void testapp_bpf_res(struct test_spec *test)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment