Skip to content

Commit 3448ad2

Browse files
Zijian Zhangborkmann
authored andcommitted
selftests/bpf: Add apply_bytes test to test_txmsg_redir_wait_sndmem in test_sockmap
Add this to more comprehensively test the socket memory accounting logic in the __SK_REDIRECT and __SK_DROP cases of tcp_bpf_sendmsg. We don't have test when apply_bytes are not zero in test_txmsg_redir_wait_sndmem. test_send_large has opt->rate=2, it will invoke sendmsg two times. Specifically, the first sendmsg will trigger the case where the ret value of tcp_bpf_sendmsg_redir is less than 0; while the second sendmsg happens after the 3 seconds timeout, and it will trigger __SK_DROP because socket c2 has been removed from the sockmap/hash. Signed-off-by: Zijian Zhang <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: John Fastabend <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent ca70b8b commit 3448ad2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tools/testing/selftests/bpf/test_sockmap.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1579,8 +1579,12 @@ static void test_txmsg_redir(int cgrp, struct sockmap_options *opt)
15791579

15801580
static void test_txmsg_redir_wait_sndmem(int cgrp, struct sockmap_options *opt)
15811581
{
1582-
txmsg_redir = 1;
15831582
opt->tx_wait_mem = true;
1583+
txmsg_redir = 1;
1584+
test_send_large(opt, cgrp);
1585+
1586+
txmsg_redir = 1;
1587+
txmsg_apply = 4097;
15841588
test_send_large(opt, cgrp);
15851589
opt->tx_wait_mem = false;
15861590
}

0 commit comments

Comments
 (0)