Skip to content

Commit 47e96a1

Browse files
bastien-curutchetKernel Patches Daemon
authored andcommitted
selftests/bpf: test_xsk: Add return value to init_iface()
init_iface() doesn't have any return value while it can fail. In case of failure it calls exit_on_error() which exits the application immediately. This prevents the following tests from being run and isn't compliant with the CI Add a return value to init_iface() so errors can be handled more smoothly. Signed-off-by: Bastien Curutchet (eBPF Foundation) <[email protected]>
1 parent fa141e9 commit 47e96a1

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

tools/testing/selftests/bpf/test_xsk.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2198,7 +2198,7 @@ static bool hugepages_present(void)
21982198
return true;
21992199
}
22002200

2201-
void init_iface(struct ifobject *ifobj, thread_func_t func_ptr)
2201+
int init_iface(struct ifobject *ifobj, thread_func_t func_ptr)
22022202
{
22032203
LIBBPF_OPTS(bpf_xdp_query_opts, query_opts);
22042204
int err;
@@ -2208,7 +2208,7 @@ void init_iface(struct ifobject *ifobj, thread_func_t func_ptr)
22082208
err = xsk_load_xdp_programs(ifobj);
22092209
if (err) {
22102210
ksft_print_msg("Error loading XDP program\n");
2211-
exit_with_error(err);
2211+
return err;
22122212
}
22132213

22142214
if (hugepages_present())
@@ -2217,7 +2217,7 @@ void init_iface(struct ifobject *ifobj, thread_func_t func_ptr)
22172217
err = bpf_xdp_query(ifobj->ifindex, XDP_FLAGS_DRV_MODE, &query_opts);
22182218
if (err) {
22192219
ksft_print_msg("Error querying XDP capabilities\n");
2220-
exit_with_error(-err);
2220+
return err;
22212221
}
22222222
if (query_opts.feature_flags & NETDEV_XDP_ACT_RX_SG)
22232223
ifobj->multi_buff_supp = true;
@@ -2229,6 +2229,8 @@ void init_iface(struct ifobject *ifobj, thread_func_t func_ptr)
22292229
ifobj->xdp_zc_max_segs = 0;
22302230
}
22312231
}
2232+
2233+
return 0;
22322234
}
22332235

22342236
int testapp_send_receive(struct test_spec *test)

tools/testing/selftests/bpf/test_xsk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ struct ifobject {
137137
};
138138
struct ifobject *ifobject_create(void);
139139
void ifobject_delete(struct ifobject *ifobj);
140-
void init_iface(struct ifobject *ifobj, thread_func_t func_ptr);
140+
int init_iface(struct ifobject *ifobj, thread_func_t func_ptr);
141141

142142
int xsk_configure_umem(struct ifobject *ifobj, struct xsk_umem_info *umem, void *buffer, u64 size);
143143
int xsk_configure_socket(struct xsk_socket_info *xsk, struct xsk_umem_info *umem,

tools/testing/selftests/bpf/xskxceiver.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,11 @@ int main(int argc, char **argv)
358358
ifobj_tx->set_ring.default_rx = ifobj_tx->ring.rx_pending;
359359
}
360360

361-
init_iface(ifobj_rx, worker_testapp_validate_rx);
362-
init_iface(ifobj_tx, worker_testapp_validate_tx);
361+
if (init_iface(ifobj_rx, worker_testapp_validate_rx) ||
362+
init_iface(ifobj_tx, worker_testapp_validate_tx)) {
363+
ksft_print_msg("Error : can't initialize interfaces\n");
364+
ksft_exit_xfail();
365+
}
363366

364367
test_init(&test, ifobj_tx, ifobj_rx, 0, &tests[0]);
365368
tx_pkt_stream_default = pkt_stream_generate(DEFAULT_PKT_CNT, MIN_PKT_SIZE);

0 commit comments

Comments
 (0)