tools/testing/selftests/bpf/progs/test_queue_stack_map.h
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/test_queue_stack_map.h
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/test_queue_stack_map.h- Extension
.h- Size
- 1176 bytes
- Lines
- 58
- 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
stddef.hstring.hlinux/bpf.hlinux/if_ether.hlinux/ip.hlinux/pkt_cls.hbpf/bpf_helpers.h
Detected Declarations
function _test
Annotated Snippet
// Copyright (c) 2018 Politecnico di Torino
#include <stddef.h>
#include <string.h>
#include <linux/bpf.h>
#include <linux/if_ether.h>
#include <linux/ip.h>
#include <linux/pkt_cls.h>
#include <bpf/bpf_helpers.h>
struct {
__uint(type, MAP_TYPE);
__uint(max_entries, 32);
__uint(map_flags, 0);
__uint(key_size, 0);
__uint(value_size, sizeof(__u32));
} map_in SEC(".maps");
struct {
__uint(type, MAP_TYPE);
__uint(max_entries, 32);
__uint(map_flags, 0);
__uint(key_size, 0);
__uint(value_size, sizeof(__u32));
} map_out SEC(".maps");
SEC("tc")
int _test(struct __sk_buff *skb)
{
void *data_end = (void *)(long)skb->data_end;
void *data = (void *)(long)skb->data;
struct ethhdr *eth = (struct ethhdr *)(data);
__u32 value;
int err;
if (eth + 1 > data_end)
return TC_ACT_SHOT;
struct iphdr *iph = (struct iphdr *)(eth + 1);
if (iph + 1 > data_end)
return TC_ACT_SHOT;
err = bpf_map_pop_elem(&map_in, &value);
if (err)
return TC_ACT_SHOT;
iph->daddr = value;
err = bpf_map_push_elem(&map_out, &iph->saddr, 0);
if (err)
return TC_ACT_SHOT;
return TC_ACT_OK;
}
char _license[] SEC("license") = "GPL";
Annotation
- Immediate include surface: `stddef.h`, `string.h`, `linux/bpf.h`, `linux/if_ether.h`, `linux/ip.h`, `linux/pkt_cls.h`, `bpf/bpf_helpers.h`.
- Detected declarations: `function _test`.
- 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.