Skip to content

Commit

Permalink
selftests/bpf: Simplify ip_check_defrag
Browse files Browse the repository at this point in the history
Simplify.

Signed-off-by: Geliang Tang <[email protected]>
  • Loading branch information
Geliang Tang committed Mar 30, 2024
1 parent 170fe88 commit ca6e50b
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions tools/testing/selftests/bpf/prog_tests/ip_check_defrag.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,21 +218,11 @@ void test_bpf_ip_check_defrag_ok(bool ipv6)
nstoken = open_netns(NS0);
if (!ASSERT_OK_PTR(nstoken, "setns ns0"))
goto out;
if (ipv6) {
struct sockaddr_in6 *c = (struct sockaddr_in6 *)&caddr;

c->sin6_family = AF_INET6;
inet_pton(AF_INET6, VETH0_ADDR6, &c->sin6_addr);
c->sin6_port = htons(CLIENT_PORT);
err = bind(client_rx_fd, (struct sockaddr *)c, sizeof(*c));
} else {
struct sockaddr_in *c = (struct sockaddr_in *)&caddr;

c->sin_family = AF_INET;
inet_pton(AF_INET, VETH0_ADDR, &c->sin_addr);
c->sin_port = htons(CLIENT_PORT);
err = bind(client_rx_fd, (struct sockaddr *)c, sizeof(*c));
}
if (ipv6)
make_sockaddr(AF_INET6, VETH0_ADDR6, CLIENT_PORT, &caddr, &caddr_len);
else
make_sockaddr(AF_INET, VETH0_ADDR, CLIENT_PORT, &caddr, &caddr_len);
err = bind(client_rx_fd, (struct sockaddr *)&caddr, sizeof(caddr));
close_netns(nstoken);
if (!ASSERT_OK(err, "bind"))
goto out;
Expand Down

0 comments on commit ca6e50b

Please sign in to comment.