Skip to content

Commit

Permalink
selftests/bpf: Use connect_to_fd in sockmap_ktls
Browse files Browse the repository at this point in the history
Signed-off-by: Geliang Tang <[email protected]>
  • Loading branch information
Geliang Tang committed May 28, 2024
1 parent 85be0d4 commit 16aa6d4
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions tools/testing/selftests/bpf/prog_tests/sockmap_ktls.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <netinet/tcp.h>
#include "test_progs.h"
#include "network_helpers.h"

#define MAX_TEST_NAME 80
#define TCP_ULP 31
Expand Down Expand Up @@ -35,26 +36,16 @@ static int disconnect(int fd)
/* Disconnect (unhash) a kTLS socket after removing it from sockmap. */
static void test_sockmap_ktls_disconnect_after_delete(int family, int map)
{
struct sockaddr_storage addr = {0};
socklen_t len = sizeof(addr);
int err, cli, srv, zero = 0;

srv = tcp_server(family);
if (srv == -1)
return;

err = getsockname(srv, (struct sockaddr *)&addr, &len);
if (!ASSERT_OK(err, "getsockopt"))
goto close_srv;

cli = socket(family, SOCK_STREAM, 0);
if (!ASSERT_GE(cli, 0, "socket"))
cli = connect_to_fd(srv, 0);
if (!ASSERT_GE(cli, 0, "connect_to_fd"))
goto close_srv;

err = connect(cli, (struct sockaddr *)&addr, len);
if (!ASSERT_OK(err, "connect"))
goto close_cli;

err = bpf_map_update_elem(map, &zero, &cli, 0);
if (!ASSERT_OK(err, "bpf_map_update_elem"))
goto close_cli;
Expand Down

0 comments on commit 16aa6d4

Please sign in to comment.