Skip to content

Commit

Permalink
selftests: xsk: Eliminate MAX_SOCKS define
Browse files Browse the repository at this point in the history
Remove the MAX_SOCKS define as it always will be one for the forseable
future and the code does not work for any other case anyway.

Signed-off-by: Magnus Karlsson <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Acked-by: Maciej Fijalkowski <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
  • Loading branch information
magnus-karlsson authored and borkmann committed Sep 10, 2021
1 parent e2d850d commit 8ce7192
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
18 changes: 9 additions & 9 deletions tools/testing/selftests/bpf/xdpxceiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -693,23 +693,23 @@ static void wait_for_tx_completion(struct xsk_socket_info *xsk)

static void send_pkts(struct ifobject *ifobject)
{
struct pollfd fds[MAX_SOCKS] = { };
struct pollfd fds = { };
u32 pkt_cnt = 0;

fds[0].fd = xsk_socket__fd(ifobject->xsk->xsk);
fds[0].events = POLLOUT;
fds.fd = xsk_socket__fd(ifobject->xsk->xsk);
fds.events = POLLOUT;

while (pkt_cnt < ifobject->pkt_stream->nb_pkts) {
u32 sent;

if (ifobject->use_poll) {
int ret;

ret = poll(fds, 1, POLL_TMOUT);
ret = poll(&fds, 1, POLL_TMOUT);
if (ret <= 0)
continue;

if (!(fds[0].revents & POLLOUT))
if (!(fds.revents & POLLOUT))
continue;
}

Expand Down Expand Up @@ -855,24 +855,24 @@ static void *worker_testapp_validate_rx(void *arg)
{
struct test_spec *test = (struct test_spec *)arg;
struct ifobject *ifobject = test->ifobj_rx;
struct pollfd fds[MAX_SOCKS] = { };
struct pollfd fds = { };

if (test->current_step == 1)
thread_common_ops(test, ifobject);

if (stat_test_type != STAT_TEST_RX_FILL_EMPTY)
xsk_populate_fill_ring(ifobject->umem);

fds[0].fd = xsk_socket__fd(ifobject->xsk->xsk);
fds[0].events = POLLIN;
fds.fd = xsk_socket__fd(ifobject->xsk->xsk);
fds.events = POLLIN;

pthread_barrier_wait(&barr);

if (test_type == TEST_TYPE_STATS)
while (!rx_stats_are_valid(ifobject))
continue;
else
receive_pkts(ifobject->pkt_stream, ifobject->xsk, fds);
receive_pkts(ifobject->pkt_stream, ifobject->xsk, &fds);

if (test_type == TEST_TYPE_TEARDOWN)
print_verbose("Destroying socket\n");
Expand Down
1 change: 0 additions & 1 deletion tools/testing/selftests/bpf/xdpxceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#define MAX_INTERFACES 2
#define MAX_INTERFACE_NAME_CHARS 7
#define MAX_INTERFACES_NAMESPACE_CHARS 10
#define MAX_SOCKS 1
#define MAX_SOCKETS 2
#define MAX_TEST_NAME_SIZE 32
#define MAX_TEARDOWN_ITER 10
Expand Down

0 comments on commit 8ce7192

Please sign in to comment.