tools/testing/selftests/bpf/progs/test_sockmap_pass_prog.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/test_sockmap_pass_prog.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/test_sockmap_pass_prog.c- Extension
.c- Size
- 1149 bytes
- Lines
- 62
- 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
linux/bpf.hbpf/bpf_helpers.hbpf/bpf_endian.h
Detected Declarations
function prog_skb_verdictfunction prog_skb_verdict_clonefunction prog_skb_parserfunction prog_skb_verdict_ingressfunction prog_skb_verdict_ingress_strp
Annotated Snippet
#include <linux/bpf.h>
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_endian.h>
struct {
__uint(type, BPF_MAP_TYPE_SOCKMAP);
__uint(max_entries, 20);
__type(key, int);
__type(value, int);
} sock_map_rx SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_SOCKMAP);
__uint(max_entries, 20);
__type(key, int);
__type(value, int);
} sock_map_tx SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_SOCKMAP);
__uint(max_entries, 20);
__type(key, int);
__type(value, int);
} sock_map_msg SEC(".maps");
SEC("sk_skb/stream_verdict")
int prog_skb_verdict(struct __sk_buff *skb)
{
return SK_PASS;
}
int clone_called;
SEC("sk_skb/stream_verdict")
int prog_skb_verdict_clone(struct __sk_buff *skb)
{
clone_called = 1;
return SK_PASS;
}
SEC("sk_skb/stream_parser")
int prog_skb_parser(struct __sk_buff *skb)
{
return SK_PASS;
}
SEC("sk_skb/stream_verdict")
int prog_skb_verdict_ingress(struct __sk_buff *skb)
{
int one = 1;
return bpf_sk_redirect_map(skb, &sock_map_rx, one, BPF_F_INGRESS);
}
SEC("sk_skb/stream_parser")
int prog_skb_verdict_ingress_strp(struct __sk_buff *skb)
{
return skb->len;
}
char _license[] SEC("license") = "GPL";
Annotation
- Immediate include surface: `linux/bpf.h`, `bpf/bpf_helpers.h`, `bpf/bpf_endian.h`.
- Detected declarations: `function prog_skb_verdict`, `function prog_skb_verdict_clone`, `function prog_skb_parser`, `function prog_skb_verdict_ingress`, `function prog_skb_verdict_ingress_strp`.
- 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.