tools/testing/selftests/bpf/progs/test_xdp_update_frags.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/test_xdp_update_frags.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/test_xdp_update_frags.c- Extension
.c- Size
- 1000 bytes
- Lines
- 43
- 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.hlinux/if_ether.hbpf/bpf_helpers.h
Detected Declarations
function xdp_adjust_frags
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*/
#include <linux/bpf.h>
#include <linux/if_ether.h>
#include <bpf/bpf_helpers.h>
int _version SEC("version") = 1;
SEC("xdp.frags")
int xdp_adjust_frags(struct xdp_md *xdp)
{
__u8 *data_end = (void *)(long)xdp->data_end;
__u8 *data = (void *)(long)xdp->data;
__u8 val[16] = {};
__u32 offset;
int err;
if (data + sizeof(__u32) > data_end)
return XDP_DROP;
offset = *(__u32 *)data;
err = bpf_xdp_load_bytes(xdp, offset, val, sizeof(val));
if (err < 0)
return XDP_DROP;
if (val[0] != 0xaa || val[15] != 0xaa) /* marker */
return XDP_DROP;
val[0] = 0xbb; /* update the marker */
val[15] = 0xbb;
err = bpf_xdp_store_bytes(xdp, offset, val, sizeof(val));
if (err < 0)
return XDP_DROP;
return XDP_PASS;
}
char _license[] SEC("license") = "GPL";
Annotation
- Immediate include surface: `linux/bpf.h`, `linux/if_ether.h`, `bpf/bpf_helpers.h`.
- Detected declarations: `function xdp_adjust_frags`.
- 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.