tools/testing/selftests/bpf/progs/verifier_xdp.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/verifier_xdp.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/verifier_xdp.c- Extension
.c- Size
- 1555 bytes
- Lines
- 60
- 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
function __retvalfunction __retval
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* Converted from tools/testing/selftests/bpf/verifier/xdp.c */
#include <linux/bpf.h>
#include <bpf/bpf_helpers.h>
#include "bpf_misc.h"
struct {
__uint(type, BPF_MAP_TYPE_ARRAY);
__uint(max_entries, 1);
__type(key, int);
__type(value, __u64);
__uint(map_flags, BPF_F_RDONLY_PROG);
} map_array_ro SEC(".maps");
SEC("xdp")
__description("XDP, using ifindex from netdev")
__success __retval(1)
__naked void xdp_using_ifindex_from_netdev(void)
{
asm volatile (" \
r0 = 0; \
r2 = *(u32*)(r1 + %[xdp_md_ingress_ifindex]); \
if r2 < 1 goto l0_%=; \
r0 = 1; \
l0_%=: exit; \
" :
: __imm_const(xdp_md_ingress_ifindex, offsetof(struct xdp_md, ingress_ifindex))
: __clobber_all);
}
SEC("xdp")
__description("XDP, using xdp_store_bytes from RO map")
__success __retval(0)
__naked void xdp_store_bytes_from_ro_map(void)
{
asm volatile (" \
r6 = r1; \
r1 = 0; \
*(u64*)(r10 - 8) = r1; \
r2 = r10; \
r2 += -8; \
r1 = %[map_array_ro] ll; \
call %[bpf_map_lookup_elem]; \
if r0 == 0 goto l0_%=; \
r1 = r6; \
r2 = 0; \
r3 = r0; \
r4 = 8; \
call %[bpf_xdp_store_bytes]; \
l0_%=: exit; \
" :
: __imm(bpf_map_lookup_elem),
__imm(bpf_xdp_store_bytes),
__imm_addr(map_array_ro)
: __clobber_all);
}
char _license[] SEC("license") = "GPL";
Annotation
- Immediate include surface: `linux/bpf.h`, `bpf/bpf_helpers.h`, `bpf_misc.h`.
- Detected declarations: `function __retval`, `function __retval`.
- 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.