tools/testing/selftests/bpf/progs/xdpwall.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/xdpwall.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/xdpwall.c- Extension
.c- Size
- 7914 bytes
- Lines
- 365
- 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
stdbool.hstdint.hlinux/stddef.hlinux/if_ether.hlinux/in.hlinux/in6.hlinux/ip.hlinux/ipv6.hlinux/tcp.hlinux/udp.hlinux/bpf.hlinux/types.hbpf/bpf_endian.hbpf/bpf_helpers.h
Detected Declarations
struct v4_lpm_keystruct v4_lpm_valstruct fw_match_infostruct pkt_infoenum pkt_parse_errenum pkt_flagenum ip_typefunction filter_ipv6_addrfunction filter_ipv4_addrfunction filter_ipv4_lpmfunction filter_src_dst_ipfunction get_transport_hdrfunction tcphdr_only_contains_flagfunction set_tcp_flagsfunction parse_tcpfunction parse_udpfunction filter_tcp_portfunction filter_udp_portfunction filter_transport_hdrfunction parse_gue_v6function parse_ipv6_guefunction edgewall
Annotated Snippet
struct v4_lpm_key {
__u32 prefixlen;
__u32 src;
};
struct v4_lpm_val {
struct v4_lpm_key key;
__u8 val;
};
struct {
__uint(type, BPF_MAP_TYPE_HASH);
__uint(max_entries, 16);
__type(key, struct in6_addr);
__type(value, bool);
} v6_addr_map SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_HASH);
__uint(max_entries, 16);
__type(key, __u32);
__type(value, bool);
} v4_addr_map SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_LPM_TRIE);
__uint(max_entries, 16);
__uint(key_size, sizeof(struct v4_lpm_key));
__uint(value_size, sizeof(struct v4_lpm_val));
__uint(map_flags, BPF_F_NO_PREALLOC);
} v4_lpm_val_map SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_ARRAY);
__uint(max_entries, 16);
__type(key, int);
__type(value, __u8);
} tcp_port_map SEC(".maps");
struct {
__uint(type, BPF_MAP_TYPE_ARRAY);
__uint(max_entries, 16);
__type(key, int);
__type(value, __u16);
} udp_port_map SEC(".maps");
enum ip_type { V4 = 1, V6 = 2 };
struct fw_match_info {
__u8 v4_src_ip_match;
__u8 v6_src_ip_match;
__u8 v4_src_prefix_match;
__u8 v4_dst_prefix_match;
__u8 tcp_dp_match;
__u16 udp_sp_match;
__u16 udp_dp_match;
bool is_tcp;
bool is_tcp_syn;
};
struct pkt_info {
enum ip_type type;
union {
struct iphdr *ipv4;
struct ipv6hdr *ipv6;
} ip;
int sport;
int dport;
__u16 trans_hdr_offset;
__u8 proto;
__u8 flags;
};
static __always_inline struct ethhdr *parse_ethhdr(void *data, void *data_end)
{
struct ethhdr *eth = data;
if (eth + 1 > data_end)
return NULL;
return eth;
}
static __always_inline __u8 filter_ipv6_addr(const struct in6_addr *ipv6addr)
{
__u8 *leaf;
leaf = bpf_map_lookup_elem(&v6_addr_map, ipv6addr);
return leaf ? *leaf : 0;
Annotation
- Immediate include surface: `stdbool.h`, `stdint.h`, `linux/stddef.h`, `linux/if_ether.h`, `linux/in.h`, `linux/in6.h`, `linux/ip.h`, `linux/ipv6.h`.
- Detected declarations: `struct v4_lpm_key`, `struct v4_lpm_val`, `struct fw_match_info`, `struct pkt_info`, `enum pkt_parse_err`, `enum pkt_flag`, `enum ip_type`, `function filter_ipv6_addr`, `function filter_ipv4_addr`, `function filter_ipv4_lpm`.
- 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.