tools/testing/selftests/bpf/progs/xsk_xdp_progs.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/xsk_xdp_progs.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/xsk_xdp_progs.c- Extension
.c- Size
- 2992 bytes
- Lines
- 126
- 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.hlinux/if_ether.hlinux/ip.hlinux/errno.hxsk_xdp_common.h
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
if (ret == -EOPNOTSUPP) {
/* Set adjust_value to -EOPNOTSUPP to indicate to userspace that this case
* is unsupported
*/
adjust_value = -EOPNOTSUPP;
return bpf_redirect_map(&xsk, 0, XDP_DROP);
}
return XDP_DROP;
}
curr_buff_len = bpf_xdp_get_buff_len(xdp);
if (curr_buff_len != buff_len + adjust_value)
return XDP_DROP;
if (curr_buff_len > buff_len) {
__u32 *pkt_data = (void *)(long)xdp->data;
__u32 len, words_to_end, seq_num;
len = curr_buff_len - PKT_HDR_ALIGN;
words_to_end = len / sizeof(*pkt_data) - 1;
seq_num = words_to_end;
/* Convert sequence number to network byte order. Store this in the last 4 bytes of
* the packet. Use 'adjust_value' to determine the position at the end of the
* packet for storing the sequence number.
*/
seq_num = __constant_htonl(words_to_end);
bpf_xdp_store_bytes(xdp, curr_buff_len - sizeof(seq_num), &seq_num,
sizeof(seq_num));
}
return bpf_redirect_map(&xsk, 0, XDP_DROP);
}
char _license[] SEC("license") = "GPL";
Annotation
- Immediate include surface: `linux/bpf.h`, `bpf/bpf_helpers.h`, `linux/if_ether.h`, `linux/ip.h`, `linux/errno.h`, `xsk_xdp_common.h`.
- 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.