tools/testing/selftests/bpf/test_sockmap.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/test_sockmap.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/test_sockmap.c- Extension
.c- Size
- 44572 bytes
- Lines
- 2022
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
stdio.hstdlib.hsys/socket.hsys/ioctl.hsys/select.hnetinet/in.harpa/inet.hunistd.hstring.herrno.hstdbool.hsignal.hfcntl.hsys/wait.htime.hsched.hsys/time.hsys/types.hsys/sendfile.hlinux/netlink.hlinux/socket.hlinux/sock_diag.hlinux/bpf.hlinux/if_link.hassert.hlibgen.hgetopt.hbpf/bpf.hbpf/libbpf.hbpf_util.hcgroup_helpers.h
Detected Declarations
struct test_envstruct sockmap_optionsstruct _teststruct msg_statsfunction test_startfunction test_failfunction test_passfunction test_resetfunction test_start_subtestfunction test_end_subtestfunction test_print_resultsfunction usagefunction sockmap_init_socketsfunction msg_loop_sendpagefunction msg_free_iovfunction msg_alloc_iovfunction msg_verify_date_prepfunction msg_verify_datafunction msg_loopfunction sentBpsfunction recvdBpsfunction sendmsg_testfunction forever_ping_pongfunction run_optionsfunction append_strfunction test_optionsfunction __test_execfunction test_execfunction test_send_onefunction test_send_manyfunction test_send_largefunction test_sendfunction test_txmsg_passfunction test_txmsg_redirfunction test_txmsg_redir_wait_sndmemfunction test_txmsg_dropfunction test_txmsg_ingress_redirfunction test_txmsg_cork_hangsfunction test_txmsg_pullfunction test_txmsg_popfunction test_txmsg_pushfunction test_txmsg_push_popfunction test_txmsg_applyfunction test_txmsg_corkfunction test_txmsg_ingress_parserfunction test_txmsg_ingress_parser2function populate_progsfunction check_whitelist
Annotated Snippet
struct test_env {
const char *type;
const char *subtest;
const char *prepend;
int test_num;
int subtest_num;
int succ_cnt;
int fail_cnt;
int fail_last;
};
struct test_env env;
struct sockmap_options {
int verbose;
bool base;
bool sendpage;
bool data_test;
bool drop_expected;
bool check_recved_len;
bool tx_wait_mem;
int iov_count;
int iov_length;
int rate;
char *map;
char *whitelist;
char *blacklist;
char *prepend;
};
struct _test {
char *title;
void (*tester)(int cg_fd, struct sockmap_options *opt);
};
static void test_start(void)
{
env.subtest_num++;
}
static void test_fail(void)
{
env.fail_cnt++;
}
static void test_pass(void)
{
env.succ_cnt++;
}
static void test_reset(void)
{
txmsg_start = txmsg_end = 0;
txmsg_start_pop = txmsg_pop = 0;
txmsg_start_push = txmsg_end_push = 0;
txmsg_pass = txmsg_drop = txmsg_redir = 0;
txmsg_apply = txmsg_cork = 0;
txmsg_ingress = txmsg_redir_skb = 0;
txmsg_omit_skb_parser = 0;
skb_use_parser = 0;
}
static int test_start_subtest(const struct _test *t, struct sockmap_options *o)
{
env.type = o->map;
env.subtest = t->title;
env.prepend = o->prepend;
env.test_num++;
env.subtest_num = 0;
env.fail_last = env.fail_cnt;
test_reset();
return 0;
}
static void test_end_subtest(void)
{
int error = env.fail_cnt - env.fail_last;
int type = strcmp(env.type, BPF_SOCKMAP_FILENAME);
if (!error)
test_pass();
fprintf(stdout, "#%2d/%2d %8s:%s:%s:%s\n",
env.test_num, env.subtest_num,
!type ? "sockmap" : "sockhash",
env.prepend ? : "",
env.subtest, error ? "FAIL" : "OK");
}
Annotation
- Immediate include surface: `stdio.h`, `stdlib.h`, `sys/socket.h`, `sys/ioctl.h`, `sys/select.h`, `netinet/in.h`, `arpa/inet.h`, `unistd.h`.
- Detected declarations: `struct test_env`, `struct sockmap_options`, `struct _test`, `struct msg_stats`, `function test_start`, `function test_fail`, `function test_pass`, `function test_reset`, `function test_start_subtest`, `function test_end_subtest`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.