tools/testing/selftests/bpf/progs/bloom_filter_map.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/bloom_filter_map.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/bloom_filter_map.c- Extension
.c- Size
- 1563 bytes
- Lines
- 84
- 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_misc.h
Detected Declarations
struct bpf_mapstruct map_bloom_typestruct callback_ctxfunction check_elemfunction inner_mapfunction check_bloom
Annotated Snippet
struct map_bloom_type {
__uint(type, BPF_MAP_TYPE_BLOOM_FILTER);
__type(value, __u32);
__uint(max_entries, 10000);
__uint(map_extra, 5);
} map_bloom SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_ARRAY_OF_MAPS);
__type(key, int);
__type(value, int);
__uint(max_entries, 1);
__array(values, struct map_bloom_type);
} outer_map SEC(".maps");
struct callback_ctx {
struct bpf_map *map;
};
int error = 0;
static __u64
check_elem(struct bpf_map *map, __u32 *key, __u32 *val,
struct callback_ctx *data)
{
int err;
err = bpf_map_peek_elem(data->map, val);
if (err) {
error |= 1;
return 1; /* stop the iteration */
}
return 0;
}
SEC("fentry/" SYS_PREFIX "sys_getpgid")
int inner_map(void *ctx)
{
struct bpf_map *inner_map;
struct callback_ctx data;
int key = 0;
inner_map = bpf_map_lookup_elem(&outer_map, &key);
if (!inner_map) {
error |= 2;
return 0;
}
data.map = inner_map;
bpf_for_each_map_elem(&map_random_data, check_elem, &data, 0);
return 0;
}
SEC("fentry/" SYS_PREFIX "sys_getpgid")
int check_bloom(void *ctx)
{
struct callback_ctx data;
data.map = (struct bpf_map *)&map_bloom;
bpf_for_each_map_elem(&map_random_data, check_elem, &data, 0);
return 0;
}
Annotation
- Immediate include surface: `linux/bpf.h`, `bpf/bpf_helpers.h`, `bpf_misc.h`.
- Detected declarations: `struct bpf_map`, `struct map_bloom_type`, `struct callback_ctx`, `function check_elem`, `function inner_map`, `function check_bloom`.
- 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.