Commit fc2cb864 authored by Tushar Vyavahare's avatar Tushar Vyavahare Committed by Daniel Borkmann

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: default avatarTushar Vyavahare <tushar.vyavahare@intel.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarMagnus Karlsson <magnus.karlsson@intel.com>
Link: https://lore.kernel.org/bpf/20230927135241.2287547-8-tushar.vyavahare@intel.com
parent fd0815ae
...@@ -442,10 +442,9 @@ void xsk_clear_xskmap(struct bpf_map *map) ...@@ -442,10 +442,9 @@ void xsk_clear_xskmap(struct bpf_map *map)
bpf_map_delete_elem(map_fd, &index); bpf_map_delete_elem(map_fd, &index);
} }
int xsk_update_xskmap(struct bpf_map *map, struct xsk_socket *xsk) int xsk_update_xskmap(struct bpf_map *map, struct xsk_socket *xsk, u32 index)
{ {
int map_fd, sock_fd; int map_fd, sock_fd;
u32 index = 0;
map_fd = bpf_map__fd(map); map_fd = bpf_map__fd(map);
sock_fd = xsk_socket__fd(xsk); sock_fd = xsk_socket__fd(xsk);
......
...@@ -204,7 +204,7 @@ struct xsk_umem_config { ...@@ -204,7 +204,7 @@ struct xsk_umem_config {
int xsk_attach_xdp_program(struct bpf_program *prog, int ifindex, u32 xdp_flags); int xsk_attach_xdp_program(struct bpf_program *prog, int ifindex, u32 xdp_flags);
void xsk_detach_xdp_program(int ifindex, u32 xdp_flags); void xsk_detach_xdp_program(int ifindex, u32 xdp_flags);
int xsk_update_xskmap(struct bpf_map *map, struct xsk_socket *xsk); int xsk_update_xskmap(struct bpf_map *map, struct xsk_socket *xsk, u32 index);
void xsk_clear_xskmap(struct bpf_map *map); void xsk_clear_xskmap(struct bpf_map *map);
bool xsk_is_in_mode(u32 ifindex, int mode); bool xsk_is_in_mode(u32 ifindex, int mode);
......
...@@ -1608,7 +1608,7 @@ static void thread_common_ops(struct test_spec *test, struct ifobject *ifobject) ...@@ -1608,7 +1608,7 @@ static void thread_common_ops(struct test_spec *test, struct ifobject *ifobject)
xsk_populate_fill_ring(ifobject->umem, ifobject->xsk->pkt_stream, ifobject->use_fill_ring); xsk_populate_fill_ring(ifobject->umem, ifobject->xsk->pkt_stream, ifobject->use_fill_ring);
ret = xsk_update_xskmap(ifobject->xskmap, ifobject->xsk->xsk); ret = xsk_update_xskmap(ifobject->xskmap, ifobject->xsk->xsk, 0);
if (ret) if (ret)
exit_with_error(errno); exit_with_error(errno);
} }
...@@ -1646,7 +1646,7 @@ static void *worker_testapp_validate_rx(void *arg) ...@@ -1646,7 +1646,7 @@ static void *worker_testapp_validate_rx(void *arg)
thread_common_ops(test, ifobject); thread_common_ops(test, ifobject);
} else { } else {
xsk_clear_xskmap(ifobject->xskmap); xsk_clear_xskmap(ifobject->xskmap);
err = xsk_update_xskmap(ifobject->xskmap, ifobject->xsk->xsk); err = xsk_update_xskmap(ifobject->xskmap, ifobject->xsk->xsk, 0);
if (err) { if (err) {
ksft_print_msg("Error: Failed to update xskmap, error %s\n", ksft_print_msg("Error: Failed to update xskmap, error %s\n",
strerror(-err)); strerror(-err));
...@@ -1884,7 +1884,7 @@ static int swap_xsk_resources(struct test_spec *test) ...@@ -1884,7 +1884,7 @@ static int swap_xsk_resources(struct test_spec *test)
test->ifobj_tx->xsk = &test->ifobj_tx->xsk_arr[1]; test->ifobj_tx->xsk = &test->ifobj_tx->xsk_arr[1];
test->ifobj_rx->xsk = &test->ifobj_rx->xsk_arr[1]; test->ifobj_rx->xsk = &test->ifobj_rx->xsk_arr[1];
ret = xsk_update_xskmap(test->ifobj_rx->xskmap, test->ifobj_rx->xsk->xsk); ret = xsk_update_xskmap(test->ifobj_rx->xskmap, test->ifobj_rx->xsk->xsk, 0);
if (ret) if (ret)
return TEST_FAILURE; return TEST_FAILURE;
......
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