Commit d1b24fcf authored by Jordan Rife's avatar Jordan Rife Committed by Alexei Starovoitov

selftests/bpf: Migrate WILDCARD_IP test

Move wildcard IP sendmsg test case out of bpf/test_sock_addr.c into
prog_tests/sock_addr.c.
Signed-off-by: default avatarJordan Rife <jrife@google.com>
Link: https://lore.kernel.org/r/20240510190246.3247730-7-jrife@google.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent a2618c0d
......@@ -40,6 +40,7 @@
#define SERV6_V4MAPPED_IP "::ffff:192.168.0.4"
#define SRC6_IP "::1"
#define SRC6_REWRITE_IP TEST_IPV6
#define WILDCARD6_IP "::"
#define SERV6_PORT 6060
#define SERV6_REWRITE_PORT 6666
......@@ -443,6 +444,7 @@ BPF_SKEL_FUNCS(connect6_prog, connect_v6_prog);
BPF_SKEL_FUNCS(connect_unix_prog, connect_unix_prog);
BPF_SKEL_FUNCS(sendmsg4_prog, sendmsg_v4_prog);
BPF_SKEL_FUNCS(sendmsg6_prog, sendmsg_v6_prog);
BPF_SKEL_FUNCS(sendmsg6_prog, sendmsg_v6_preserve_dst_prog);
BPF_SKEL_FUNCS(sendmsg_unix_prog, sendmsg_unix_prog);
BPF_SKEL_FUNCS(recvmsg4_prog, recvmsg4_prog);
BPF_SKEL_FUNCS(recvmsg6_prog, recvmsg6_prog);
......@@ -780,6 +782,22 @@ static struct sock_addr_test tests[] = {
SRC6_REWRITE_IP,
SUCCESS,
},
{
SOCK_ADDR_TEST_SENDMSG,
"sendmsg6: sendmsg [::] (BSD'ism) (dgram)",
sendmsg_v6_preserve_dst_prog_load,
sendmsg_v6_preserve_dst_prog_destroy,
BPF_CGROUP_UDP6_SENDMSG,
&user_ops,
AF_INET6,
SOCK_DGRAM,
WILDCARD6_IP,
SERV6_PORT,
SERV6_REWRITE_IP,
SERV6_PORT,
SRC6_IP,
SUCCESS,
},
{
SOCK_ADDR_TEST_SENDMSG,
"sendmsg_unix: sendmsg (dgram)",
......@@ -830,6 +848,22 @@ static struct sock_addr_test tests[] = {
SRC6_REWRITE_IP,
SUCCESS,
},
{
SOCK_ADDR_TEST_SENDMSG,
"sendmsg6: sock_sendmsg [::] (BSD'ism) (dgram)",
sendmsg_v6_preserve_dst_prog_load,
sendmsg_v6_preserve_dst_prog_destroy,
BPF_CGROUP_UDP6_SENDMSG,
&kern_ops_sock_sendmsg,
AF_INET6,
SOCK_DGRAM,
WILDCARD6_IP,
SERV6_PORT,
SERV6_REWRITE_IP,
SERV6_PORT,
SRC6_IP,
SUCCESS,
},
{
SOCK_ADDR_TEST_SENDMSG,
"sendmsg_unix: sock_sendmsg (dgram)",
......@@ -880,6 +914,22 @@ static struct sock_addr_test tests[] = {
SRC6_REWRITE_IP,
SUCCESS,
},
{
SOCK_ADDR_TEST_SENDMSG,
"sendmsg6: kernel_sendmsg [::] (BSD'ism) (dgram)",
sendmsg_v6_preserve_dst_prog_load,
sendmsg_v6_preserve_dst_prog_destroy,
BPF_CGROUP_UDP6_SENDMSG,
&kern_ops_kernel_sendmsg,
AF_INET6,
SOCK_DGRAM,
WILDCARD6_IP,
SERV6_PORT,
SERV6_REWRITE_IP,
SERV6_PORT,
SRC6_IP,
SUCCESS,
},
{
SOCK_ADDR_TEST_SENDMSG,
"sendmsg_unix: sock_sendmsg (dgram)",
......
......@@ -59,4 +59,10 @@ int sendmsg_v6_prog(struct bpf_sock_addr *ctx)
return 1;
}
SEC("cgroup/sendmsg6")
int sendmsg_v6_preserve_dst_prog(struct bpf_sock_addr *ctx)
{
return 1;
}
char _license[] SEC("license") = "GPL";
......@@ -92,7 +92,6 @@ static int bind4_prog_load(const struct sock_addr_test *test);
static int bind6_prog_load(const struct sock_addr_test *test);
static int connect4_prog_load(const struct sock_addr_test *test);
static int connect6_prog_load(const struct sock_addr_test *test);
static int sendmsg_allow_prog_load(const struct sock_addr_test *test);
static int sendmsg_deny_prog_load(const struct sock_addr_test *test);
static int sendmsg4_rw_asm_prog_load(const struct sock_addr_test *test);
static int sendmsg6_rw_asm_prog_load(const struct sock_addr_test *test);
......@@ -343,20 +342,6 @@ static struct sock_addr_test tests[] = {
SRC6_REWRITE_IP,
SUCCESS,
},
{
"sendmsg6: preserve dst IP = [::] (BSD'ism)",
sendmsg_allow_prog_load,
BPF_CGROUP_UDP6_SENDMSG,
BPF_CGROUP_UDP6_SENDMSG,
AF_INET6,
SOCK_DGRAM,
WILDCARD6_IP,
SERV6_PORT,
SERV6_REWRITE_IP,
SERV6_PORT,
SRC6_IP,
SUCCESS,
},
{
"sendmsg6: deny call",
sendmsg_deny_prog_load,
......@@ -457,11 +442,6 @@ static int xmsg_ret_only_prog_load(const struct sock_addr_test *test,
return load_insns(test, insns, ARRAY_SIZE(insns));
}
static int sendmsg_allow_prog_load(const struct sock_addr_test *test)
{
return xmsg_ret_only_prog_load(test, /*rc*/ 1);
}
static int sendmsg_deny_prog_load(const struct sock_addr_test *test)
{
return xmsg_ret_only_prog_load(test, /*rc*/ 0);
......
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