tools/testing/selftests/bpf/prog_tests/flow_dissector_classification.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/flow_dissector_classification.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/flow_dissector_classification.c- Extension
.c- Size
- 19611 bytes
- Lines
- 798
- 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.hstdlib.hstdio.hbpf/bpf.hlinux/bpf.hbpf/libbpf.harpa/inet.hasm/byteorder.hnetinet/udp.hpoll.hstring.hsys/ioctl.hsys/socket.hsys/time.hunistd.htest_progs.hnetwork_helpers.hbpf_util.hbpf_flow.skel.h
Detected Declarations
struct grehdrstruct guehdrstruct test_configurationstruct test_ctxfunction util_gettimefunction build_ipv4_headerfunction ipv6_set_dsfieldfunction build_ipv6_headerfunction build_udp_headerfunction build_gue_headerfunction build_gre_headerfunction l3_lengthfunction build_packetfunction setup_txfunction setup_rxfunction do_txfunction do_pollfunction do_rxfunction run_testfunction attach_and_configure_programfunction detach_programfunction set_port_dropfunction remove_filterfunction ipv4_setupfunction ipv6_setupfunction port_range_setupfunction set_addressesfunction unset_addressesfunction ipip_setupfunction ipip_shutdownfunction gre_setupfunction gre_shutdownfunction test_global_initfunction test_global_shutdownfunction test_flow_dissector_classification
Annotated Snippet
struct grehdr {
uint16_t unused;
uint16_t protocol;
} __packed;
struct guehdr {
union {
struct {
#if defined(__LITTLE_ENDIAN_BITFIELD)
__u8 hlen : 5, control : 1, version : 2;
#elif defined(__BIG_ENDIAN_BITFIELD)
__u8 version : 2, control : 1, hlen : 5;
#else
#error "Please fix <asm/byteorder.h>"
#endif
__u8 proto_ctype;
__be16 flags;
};
__be32 word;
};
};
static char buf[ETH_DATA_LEN];
struct test_configuration {
char name[SUBTEST_NAME_MAX_LEN];
int (*test_setup)(void);
void (*test_teardown)(void);
int source_ports[MAX_SOURCE_PORTS];
int cfg_l3_inner;
struct sockaddr_in in_saddr4;
struct sockaddr_in in_daddr4;
struct sockaddr_in6 in_saddr6;
struct sockaddr_in6 in_daddr6;
int cfg_l3_outer;
struct sockaddr_in out_saddr4;
struct sockaddr_in out_daddr4;
struct sockaddr_in6 out_saddr6;
struct sockaddr_in6 out_daddr6;
int cfg_encap_proto;
uint8_t cfg_dsfield_inner;
uint8_t cfg_dsfield_outer;
int cfg_l3_extra;
struct sockaddr_in extra_saddr4;
struct sockaddr_in extra_daddr4;
struct sockaddr_in6 extra_saddr6;
struct sockaddr_in6 extra_daddr6;
};
static unsigned long util_gettime(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
}
static void build_ipv4_header(void *header, uint8_t proto, uint32_t src,
uint32_t dst, int payload_len, uint8_t tos)
{
struct iphdr *iph = header;
iph->ihl = 5;
iph->version = 4;
iph->tos = tos;
iph->ttl = 8;
iph->tot_len = htons(sizeof(*iph) + payload_len);
iph->id = htons(1337);
iph->protocol = proto;
iph->saddr = src;
iph->daddr = dst;
iph->check = build_ip_csum((void *)iph);
}
static void ipv6_set_dsfield(struct ipv6hdr *ip6h, uint8_t dsfield)
{
uint16_t val, *ptr = (uint16_t *)ip6h;
val = ntohs(*ptr);
val &= 0xF00F;
val |= ((uint16_t)dsfield) << 4;
*ptr = htons(val);
}
static void build_ipv6_header(void *header, uint8_t proto,
const struct sockaddr_in6 *src,
const struct sockaddr_in6 *dst, int payload_len,
uint8_t dsfield)
{
struct ipv6hdr *ip6h = header;
Annotation
- Immediate include surface: `stdbool.h`, `stdlib.h`, `stdio.h`, `bpf/bpf.h`, `linux/bpf.h`, `bpf/libbpf.h`, `arpa/inet.h`, `asm/byteorder.h`.
- Detected declarations: `struct grehdr`, `struct guehdr`, `struct test_configuration`, `struct test_ctx`, `function util_gettime`, `function build_ipv4_header`, `function ipv6_set_dsfield`, `function build_ipv6_header`, `function build_udp_header`, `function build_gue_header`.
- 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.