tools/testing/selftests/bpf/progs/test_xdp_pull_data.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/test_xdp_pull_data.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/test_xdp_pull_data.c- Extension
.c- Size
- 883 bytes
- Lines
- 49
- 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.h
Detected Declarations
function xdp_find_sizesfunction xdp_pull_data_prog
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
int xdpf_sz;
int sinfo_sz;
int data_len;
int pull_len;
#define XDP_PACKET_HEADROOM 256
SEC("xdp.frags")
int xdp_find_sizes(struct xdp_md *ctx)
{
xdpf_sz = sizeof(struct xdp_frame);
sinfo_sz = __PAGE_SIZE - XDP_PACKET_HEADROOM -
(ctx->data_end - ctx->data);
return XDP_PASS;
}
SEC("xdp.frags")
int xdp_pull_data_prog(struct xdp_md *ctx)
{
__u8 *data_end = (void *)(long)ctx->data_end;
__u8 *data = (void *)(long)ctx->data;
__u8 *val_p;
int err;
if (data_len != data_end - data)
return XDP_DROP;
err = bpf_xdp_pull_data(ctx, pull_len);
if (err)
return XDP_DROP;
val_p = (void *)(long)ctx->data + 1024;
if (val_p + 1 > (void *)(long)ctx->data_end)
return XDP_DROP;
if (*val_p != 0xbb)
return XDP_DROP;
return XDP_PASS;
}
char _license[] SEC("license") = "GPL";
Annotation
- Immediate include surface: `vmlinux.h`, `bpf/bpf_helpers.h`.
- Detected declarations: `function xdp_find_sizes`, `function xdp_pull_data_prog`.
- 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.