tools/testing/selftests/bpf/progs/stack_arg_kfunc.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/stack_arg_kfunc.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/stack_arg_kfunc.c- Extension
.c- Size
- 3372 bytes
- Lines
- 167
- 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
vmlinux.hbpf/bpf_helpers.hbpf_kfuncs.h../test_kmods/bpf_testmod_kfunc.h
Detected Declarations
struct bpf_iter_testmod_seqstruct timer_map_valuefunction test_stack_arg_scalarfunction test_stack_arg_ptrfunction test_stack_arg_mixfunction test_stack_arg_dynptrfunction test_stack_arg_memfunction test_stack_arg_iterfunction test_stack_arg_const_strfunction test_stack_arg_timerfunction test_stack_arg_scalarfunction test_stack_arg_ptrfunction test_stack_arg_mixfunction test_stack_arg_dynptrfunction test_stack_arg_memfunction test_stack_arg_iterfunction test_stack_arg_const_strfunction test_stack_arg_timer
Annotated Snippet
struct bpf_iter_testmod_seq {
u64 :64;
u64 :64;
};
extern int bpf_iter_testmod_seq_new(struct bpf_iter_testmod_seq *it, s64 value, int cnt) __ksym;
extern void bpf_iter_testmod_seq_destroy(struct bpf_iter_testmod_seq *it) __ksym;
struct timer_map_value {
struct bpf_timer timer;
};
struct {
__uint(type, BPF_MAP_TYPE_ARRAY);
__uint(max_entries, 1);
__type(key, int);
__type(value, struct timer_map_value);
} kfunc_timer_map SEC(".maps");
SEC("tc")
int test_stack_arg_scalar(struct __sk_buff *skb)
{
return bpf_kfunc_call_stack_arg(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
}
SEC("tc")
int test_stack_arg_ptr(struct __sk_buff *skb)
{
struct prog_test_pass1 p = { .x0 = 10, .x1 = 20 };
return bpf_kfunc_call_stack_arg_ptr(1, 2, 3, 4, 5, 6, 7, 8, 9, &p);
}
SEC("tc")
int test_stack_arg_mix(struct __sk_buff *skb)
{
struct prog_test_pass1 p = { .x0 = 10 };
struct prog_test_pass1 q = { .x1 = 20 };
return bpf_kfunc_call_stack_arg_mix(1, 2, 3, 4, 5, 6, 7, &p, 8, &q);
}
/* 1+2+3+4+5+6+7+8+9+sizeof(pkt_v4) = 45+54 = 99 */
SEC("tc")
int test_stack_arg_dynptr(struct __sk_buff *skb)
{
struct bpf_dynptr ptr;
bpf_dynptr_from_skb(skb, 0, &ptr);
return bpf_kfunc_call_stack_arg_dynptr(1, 2, 3, 4, 5, 6, 7, 8, 9, &ptr);
}
/* 1 + 2 + 3 + 4 + 5 + (1 + 2 + ... + 16) = 15 + 136 = 151 */
SEC("tc")
int test_stack_arg_mem(struct __sk_buff *skb)
{
char buf[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
return bpf_kfunc_call_stack_arg_mem(1, 2, 3, 4, 5, buf, sizeof(buf));
}
/* 1+2+3+4+5+6+7+8+9+100 = 145 */
SEC("tc")
int test_stack_arg_iter(struct __sk_buff *skb)
{
struct bpf_iter_testmod_seq it;
u64 ret;
bpf_iter_testmod_seq_new(&it, 100, 10);
ret = bpf_kfunc_call_stack_arg_iter(1, 2, 3, 4, 5, 6, 7, 8, 9, &it);
bpf_iter_testmod_seq_destroy(&it);
return ret;
}
const char cstr[] = "hello";
/* 1+2+3+4+5+6+7+8+9 = 45 */
SEC("tc")
int test_stack_arg_const_str(struct __sk_buff *skb)
{
return bpf_kfunc_call_stack_arg_const_str(1, 2, 3, 4, 5, 6, 7, 8, 9,
cstr);
}
/* 1+2+3+4+5+6+7+8+9 = 45 */
SEC("tc")
int test_stack_arg_timer(struct __sk_buff *skb)
{
struct timer_map_value *val;
int key = 0;
Annotation
- Immediate include surface: `vmlinux.h`, `bpf/bpf_helpers.h`, `bpf_kfuncs.h`, `../test_kmods/bpf_testmod_kfunc.h`.
- Detected declarations: `struct bpf_iter_testmod_seq`, `struct timer_map_value`, `function test_stack_arg_scalar`, `function test_stack_arg_ptr`, `function test_stack_arg_mix`, `function test_stack_arg_dynptr`, `function test_stack_arg_mem`, `function test_stack_arg_iter`, `function test_stack_arg_const_str`, `function test_stack_arg_timer`.
- 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.