Skip to content

Commit fc2cb86

Browse files
tvyavahaborkmann
authored andcommitted
selftests/xsk: Modify xsk_update_xskmap() to accept the index as an argument
Modify xsk_update_xskmap() to accept the index as an argument, enabling the addition of multiple sockets to xskmap. Signed-off-by: Tushar Vyavahare <tushar.vyavahare@intel.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Magnus Karlsson <magnus.karlsson@intel.com> Link: https://lore.kernel.org/bpf/20230927135241.2287547-8-tushar.vyavahare@intel.com
1 parent fd0815a commit fc2cb86

3 files changed

Lines changed: 5 additions & 6 deletions

File tree

tools/testing/selftests/bpf/xsk.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,10 +442,9 @@ void xsk_clear_xskmap(struct bpf_map *map)
442442
bpf_map_delete_elem(map_fd, &index);
443443
}
444444

445-
int xsk_update_xskmap(struct bpf_map *map, struct xsk_socket *xsk)
445+
int xsk_update_xskmap(struct bpf_map *map, struct xsk_socket *xsk, u32 index)
446446
{
447447
int map_fd, sock_fd;
448-
u32 index = 0;
449448

450449
map_fd = bpf_map__fd(map);
451450
sock_fd = xsk_socket__fd(xsk);

tools/testing/selftests/bpf/xsk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ struct xsk_umem_config {
204204

205205
int xsk_attach_xdp_program(struct bpf_program *prog, int ifindex, u32 xdp_flags);
206206
void xsk_detach_xdp_program(int ifindex, u32 xdp_flags);
207-
int xsk_update_xskmap(struct bpf_map *map, struct xsk_socket *xsk);
207+
int xsk_update_xskmap(struct bpf_map *map, struct xsk_socket *xsk, u32 index);
208208
void xsk_clear_xskmap(struct bpf_map *map);
209209
bool xsk_is_in_mode(u32 ifindex, int mode);
210210

tools/testing/selftests/bpf/xskxceiver.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,7 @@ static void thread_common_ops(struct test_spec *test, struct ifobject *ifobject)
16081608

16091609
xsk_populate_fill_ring(ifobject->umem, ifobject->xsk->pkt_stream, ifobject->use_fill_ring);
16101610

1611-
ret = xsk_update_xskmap(ifobject->xskmap, ifobject->xsk->xsk);
1611+
ret = xsk_update_xskmap(ifobject->xskmap, ifobject->xsk->xsk, 0);
16121612
if (ret)
16131613
exit_with_error(errno);
16141614
}
@@ -1646,7 +1646,7 @@ static void *worker_testapp_validate_rx(void *arg)
16461646
thread_common_ops(test, ifobject);
16471647
} else {
16481648
xsk_clear_xskmap(ifobject->xskmap);
1649-
err = xsk_update_xskmap(ifobject->xskmap, ifobject->xsk->xsk);
1649+
err = xsk_update_xskmap(ifobject->xskmap, ifobject->xsk->xsk, 0);
16501650
if (err) {
16511651
ksft_print_msg("Error: Failed to update xskmap, error %s\n",
16521652
strerror(-err));
@@ -1884,7 +1884,7 @@ static int swap_xsk_resources(struct test_spec *test)
18841884
test->ifobj_tx->xsk = &test->ifobj_tx->xsk_arr[1];
18851885
test->ifobj_rx->xsk = &test->ifobj_rx->xsk_arr[1];
18861886

1887-
ret = xsk_update_xskmap(test->ifobj_rx->xskmap, test->ifobj_rx->xsk->xsk);
1887+
ret = xsk_update_xskmap(test->ifobj_rx->xskmap, test->ifobj_rx->xsk->xsk, 0);
18881888
if (ret)
18891889
return TEST_FAILURE;
18901890

0 commit comments

Comments
 (0)