Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <zijianzhang@bytedance.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20241016234838.3167769-2-zijianzhang@bytedance.com

authored by

Zijian Zhang and committed by
Daniel Borkmann
3448ad23 ca70b8ba

+5 -1
+5 -1
tools/testing/selftests/bpf/test_sockmap.c
··· 1579 1579 1580 1580 static void test_txmsg_redir_wait_sndmem(int cgrp, struct sockmap_options *opt) 1581 1581 { 1582 - txmsg_redir = 1; 1583 1582 opt->tx_wait_mem = true; 1583 + txmsg_redir = 1; 1584 + test_send_large(opt, cgrp); 1585 + 1586 + txmsg_redir = 1; 1587 + txmsg_apply = 4097; 1584 1588 test_send_large(opt, cgrp); 1585 1589 opt->tx_wait_mem = false; 1586 1590 }