mirror of
https://github.com/torvalds/linux.git
synced 2024-12-02 00:51:44 +00:00
selftest/bpf: Change udp to inet in some function names
This is to prepare for adding new unix stream tests. Mostly renames, also pass the socket types as an argument. Signed-off-by: Jiang Wang <jiang.wang@bytedance.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Reviewed-by: Cong Wang <cong.wang@bytedance.com> Acked-by: John Fastabend <john.fastabend@gmail.com> Acked-by: Jakub Sitnicki <jakub@cloudflare.com> Link: https://lore.kernel.org/bpf/20210816190327.2739291-5-jiang.wang@bytedance.com
This commit is contained in:
parent
9b03152bd4
commit
75e0e27db6
@ -1692,14 +1692,14 @@ static void test_reuseport(struct test_sockmap_listen *skel,
|
||||
}
|
||||
}
|
||||
|
||||
static int udp_socketpair(int family, int *s, int *c)
|
||||
static int inet_socketpair(int family, int type, int *s, int *c)
|
||||
{
|
||||
struct sockaddr_storage addr;
|
||||
socklen_t len;
|
||||
int p0, c0;
|
||||
int err;
|
||||
|
||||
p0 = socket_loopback(family, SOCK_DGRAM | SOCK_NONBLOCK);
|
||||
p0 = socket_loopback(family, type | SOCK_NONBLOCK);
|
||||
if (p0 < 0)
|
||||
return p0;
|
||||
|
||||
@ -1708,7 +1708,7 @@ static int udp_socketpair(int family, int *s, int *c)
|
||||
if (err)
|
||||
goto close_peer0;
|
||||
|
||||
c0 = xsocket(family, SOCK_DGRAM | SOCK_NONBLOCK, 0);
|
||||
c0 = xsocket(family, type | SOCK_NONBLOCK, 0);
|
||||
if (c0 < 0) {
|
||||
err = c0;
|
||||
goto close_peer0;
|
||||
@ -1747,10 +1747,10 @@ static void udp_redir_to_connected(int family, int sock_mapfd, int verd_mapfd,
|
||||
|
||||
zero_verdict_count(verd_mapfd);
|
||||
|
||||
err = udp_socketpair(family, &p0, &c0);
|
||||
err = inet_socketpair(family, SOCK_DGRAM, &p0, &c0);
|
||||
if (err)
|
||||
return;
|
||||
err = udp_socketpair(family, &p1, &c1);
|
||||
err = inet_socketpair(family, SOCK_DGRAM, &p1, &c1);
|
||||
if (err)
|
||||
goto close_cli0;
|
||||
|
||||
@ -1825,7 +1825,7 @@ static void test_udp_redir(struct test_sockmap_listen *skel, struct bpf_map *map
|
||||
udp_skb_redir_to_connected(skel, map, family);
|
||||
}
|
||||
|
||||
static void udp_unix_redir_to_connected(int family, int sock_mapfd,
|
||||
static void inet_unix_redir_to_connected(int family, int type, int sock_mapfd,
|
||||
int verd_mapfd, enum redir_mode mode)
|
||||
{
|
||||
const char *log_prefix = redir_mode_str(mode);
|
||||
@ -1843,7 +1843,7 @@ static void udp_unix_redir_to_connected(int family, int sock_mapfd,
|
||||
return;
|
||||
c0 = sfd[0], p0 = sfd[1];
|
||||
|
||||
err = udp_socketpair(family, &p1, &c1);
|
||||
err = inet_socketpair(family, SOCK_DGRAM, &p1, &c1);
|
||||
if (err)
|
||||
goto close;
|
||||
|
||||
@ -1897,14 +1897,16 @@ static void udp_unix_skb_redir_to_connected(struct test_sockmap_listen *skel,
|
||||
return;
|
||||
|
||||
skel->bss->test_ingress = false;
|
||||
udp_unix_redir_to_connected(family, sock_map, verdict_map, REDIR_EGRESS);
|
||||
inet_unix_redir_to_connected(family, SOCK_DGRAM, sock_map, verdict_map,
|
||||
REDIR_EGRESS);
|
||||
skel->bss->test_ingress = true;
|
||||
udp_unix_redir_to_connected(family, sock_map, verdict_map, REDIR_INGRESS);
|
||||
inet_unix_redir_to_connected(family, SOCK_DGRAM, sock_map, verdict_map,
|
||||
REDIR_INGRESS);
|
||||
|
||||
xbpf_prog_detach2(verdict, sock_map, BPF_SK_SKB_VERDICT);
|
||||
}
|
||||
|
||||
static void unix_udp_redir_to_connected(int family, int sock_mapfd,
|
||||
static void unix_inet_redir_to_connected(int family, int type, int sock_mapfd,
|
||||
int verd_mapfd, enum redir_mode mode)
|
||||
{
|
||||
const char *log_prefix = redir_mode_str(mode);
|
||||
@ -1917,7 +1919,7 @@ static void unix_udp_redir_to_connected(int family, int sock_mapfd,
|
||||
|
||||
zero_verdict_count(verd_mapfd);
|
||||
|
||||
err = udp_socketpair(family, &p0, &c0);
|
||||
err = inet_socketpair(family, SOCK_DGRAM, &p0, &c0);
|
||||
if (err)
|
||||
return;
|
||||
|
||||
@ -1972,9 +1974,11 @@ static void unix_udp_skb_redir_to_connected(struct test_sockmap_listen *skel,
|
||||
return;
|
||||
|
||||
skel->bss->test_ingress = false;
|
||||
unix_udp_redir_to_connected(family, sock_map, verdict_map, REDIR_EGRESS);
|
||||
unix_inet_redir_to_connected(family, SOCK_DGRAM, sock_map, verdict_map,
|
||||
REDIR_EGRESS);
|
||||
skel->bss->test_ingress = true;
|
||||
unix_udp_redir_to_connected(family, sock_map, verdict_map, REDIR_INGRESS);
|
||||
unix_inet_redir_to_connected(family, SOCK_DGRAM, sock_map, verdict_map,
|
||||
REDIR_INGRESS);
|
||||
|
||||
xbpf_prog_detach2(verdict, sock_map, BPF_SK_SKB_VERDICT);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user