Skip to content

Commit e645bcf

Browse files
bastien-curutchetAlexei Starovoitov
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. Reviewed-by: Maciej Fijalkowski <[email protected]> Signed-off-by: Bastien Curutchet (eBPF Foundation) <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent f477b0f commit e645bcf

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
@@ -2189,7 +2189,7 @@ static bool hugepages_present(void)
21892189
return true;
21902190
}
21912191

2192-
void init_iface(struct ifobject *ifobj, thread_func_t func_ptr)
2192+
int init_iface(struct ifobject *ifobj, thread_func_t func_ptr)
21932193
{
21942194
LIBBPF_OPTS(bpf_xdp_query_opts, query_opts);
21952195
int err;
@@ -2199,7 +2199,7 @@ void init_iface(struct ifobject *ifobj, thread_func_t func_ptr)
21992199
err = xsk_load_xdp_programs(ifobj);
22002200
if (err) {
22012201
ksft_print_msg("Error loading XDP program\n");
2202-
exit_with_error(err);
2202+
return err;
22032203
}
22042204

22052205
if (hugepages_present())
@@ -2208,7 +2208,7 @@ void init_iface(struct ifobject *ifobj, thread_func_t func_ptr)
22082208
err = bpf_xdp_query(ifobj->ifindex, XDP_FLAGS_DRV_MODE, &query_opts);
22092209
if (err) {
22102210
ksft_print_msg("Error querying XDP capabilities\n");
2211-
exit_with_error(-err);
2211+
return err;
22122212
}
22132213
if (query_opts.feature_flags & NETDEV_XDP_ACT_RX_SG)
22142214
ifobj->multi_buff_supp = true;
@@ -2220,6 +2220,8 @@ void init_iface(struct ifobject *ifobj, thread_func_t func_ptr)
22202220
ifobj->xdp_zc_max_segs = 0;
22212221
}
22222222
}
2223+
2224+
return 0;
22232225
}
22242226

22252227
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
@@ -373,8 +373,11 @@ int main(int argc, char **argv)
373373
ifobj_tx->set_ring.default_rx = ifobj_tx->ring.rx_pending;
374374
}
375375

376-
init_iface(ifobj_rx, worker_testapp_validate_rx);
377-
init_iface(ifobj_tx, worker_testapp_validate_tx);
376+
if (init_iface(ifobj_rx, worker_testapp_validate_rx) ||
377+
init_iface(ifobj_tx, worker_testapp_validate_tx)) {
378+
ksft_print_msg("Error : can't initialize interfaces\n");
379+
ksft_exit_xfail();
380+
}
378381

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

0 commit comments

Comments
 (0)