Skip to content

Commit

Permalink
selftests/bpf: Add apply_bytes test to test_txmsg_redir_wait_sndmem i…
Browse files Browse the repository at this point in the history
…n 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]>
  • Loading branch information
Zijian Zhang authored and Kernel Patches Daemon committed Oct 17, 2024
1 parent f7d2a2c commit c6b8e29
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tools/testing/selftests/bpf/test_sockmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1485,8 +1485,12 @@ static void test_txmsg_redir(int cgrp, struct sockmap_options *opt)

static void test_txmsg_redir_wait_sndmem(int cgrp, struct sockmap_options *opt)
{
txmsg_redir = 1;
opt->tx_wait_mem = true;
txmsg_redir = 1;
test_send_large(opt, cgrp);

txmsg_redir = 1;
txmsg_apply = 4097;
test_send_large(opt, cgrp);
opt->tx_wait_mem = false;
}
Expand Down

0 comments on commit c6b8e29

Please sign in to comment.