tools/testing/selftests/bpf/benchs/bench_xdp_lb.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/benchs/bench_xdp_lb.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/benchs/bench_xdp_lb.c- Extension
.c- Size
- 30924 bytes
- Lines
- 1125
- 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
argp.hstring.harpa/inet.hlinux/if_ether.hlinux/ip.hlinux/ipv6.hlinux/in.hlinux/tcp.hlinux/udp.hbench.hbench_bpf_timing.hxdp_lb_bench.skel.hxdp_lb_bench_common.hbpf_util.h
Detected Declarations
struct test_scenarioenum scenario_idenum lru_miss_typefunction ip_checksumfunction htonl_v6function build_flow_keyfunction build_l4function build_packetfunction populate_vipfunction create_per_cpu_lru_mapsfunction ktime_get_nsfunction populate_lrufunction populate_mapsfunction build_expected_packetfunction print_hex_difffunction read_statfunction reset_statsfunction validate_countersfunction validate_scenariofunction XDP_DROPfunction find_scenariofunction xdp_lb_validatefunction xdp_lb_run_oncefunction xdp_lb_setupfunction xdp_lb_measurefunction xdp_lb_report_finalfunction parse_arg
Annotated Snippet
struct test_scenario {
const char *name;
const char *description;
int expected_retval;
bool expect_encap;
bool is_v6;
__u32 vip_addr;
__u32 src_addr;
__u32 tunnel_dst;
__u32 vip_addr_v6[4];
__u32 src_addr_v6[4];
__u32 tunnel_dst_v6[4];
__u16 dst_port;
__u16 src_port;
__u8 ip_proto;
__u32 vip_flags;
__u32 vip_num;
bool prepopulate_lru;
bool set_frag;
__u16 eth_proto;
bool encap_v6_outer;
__u32 flow_mask;
bool cold_lru;
bool set_syn;
bool set_rst;
bool set_ip_options;
__u32 fixed_batch_iters; /* 0 = auto-calibrate, >0 = use this value */
enum lru_miss_type lru_miss; /* expected LRU miss pattern */
};
static const struct test_scenario scenarios[NUM_SCENARIOS] = {
/* Single-flow baseline */
[S_TCP_V4_LRU_HIT] = {
S_BASE_ENCAP_V4, .ip_proto = IPPROTO_TCP,
.name = "tcp-v4-lru-hit",
.description = "IPv4 TCP, LRU hit, IPIP encap",
.vip_addr = IP4(10, 10, 1, 1), .dst_port = 80,
.src_addr = IP4(10, 10, 2, 1), .src_port = 12345,
.prepopulate_lru = true, .lru_miss = LRU_MISS_NONE,
},
[S_TCP_V4_CH] = {
S_BASE_ENCAP_V4, .ip_proto = IPPROTO_TCP,
.name = "tcp-v4-ch",
.description = "IPv4 TCP, CH (LRU bypass), IPIP encap",
.vip_addr = IP4(10, 10, 1, 2), .dst_port = 80,
.src_addr = IP4(10, 10, 2, 2), .src_port = 54321,
.vip_flags = F_LRU_BYPASS, .vip_num = 1,
.lru_miss = LRU_MISS_ALL,
},
[S_TCP_V6_LRU_HIT] = {
S_BASE_ENCAP_V6, .ip_proto = IPPROTO_TCP,
.name = "tcp-v6-lru-hit",
.description = "IPv6 TCP, LRU hit, IP6IP6 encap",
.vip_addr_v6 = IP6(0xfd000100, 0, 0, 1), .dst_port = 80,
.src_addr_v6 = IP6(0xfd000200, 0, 0, 1), .src_port = 12345,
.vip_num = 10,
.prepopulate_lru = true, .lru_miss = LRU_MISS_NONE,
},
[S_TCP_V6_CH] = {
S_BASE_ENCAP_V6, .ip_proto = IPPROTO_TCP,
.name = "tcp-v6-ch",
.description = "IPv6 TCP, CH (LRU bypass), IP6IP6 encap",
.vip_addr_v6 = IP6(0xfd000100, 0, 0, 2), .dst_port = 80,
.src_addr_v6 = IP6(0xfd000200, 0, 0, 2), .src_port = 54321,
.vip_flags = F_LRU_BYPASS, .vip_num = 12,
.lru_miss = LRU_MISS_ALL,
},
[S_UDP_V4_LRU_HIT] = {
S_BASE_ENCAP_V4, .ip_proto = IPPROTO_UDP,
.name = "udp-v4-lru-hit",
.description = "IPv4 UDP, LRU hit, IPIP encap",
.vip_addr = IP4(10, 10, 1, 1), .dst_port = 443,
.src_addr = IP4(10, 10, 3, 1), .src_port = 11111,
.vip_num = 2,
.prepopulate_lru = true, .lru_miss = LRU_MISS_NONE,
},
[S_UDP_V6_LRU_HIT] = {
S_BASE_ENCAP_V6, .ip_proto = IPPROTO_UDP,
.name = "udp-v6-lru-hit",
.description = "IPv6 UDP, LRU hit, IP6IP6 encap",
.vip_addr_v6 = IP6(0xfd000100, 0, 0, 1), .dst_port = 443,
.src_addr_v6 = IP6(0xfd000200, 0, 0, 3), .src_port = 22222,
.vip_num = 14,
.prepopulate_lru = true, .lru_miss = LRU_MISS_NONE,
},
[S_TCP_V4V6_LRU_HIT] = {
S_BASE_ENCAP_V4V6, .ip_proto = IPPROTO_TCP,
.name = "tcp-v4v6-lru-hit",
.description = "IPv4 TCP, LRU hit, IPv4-in-IPv6 encap",
.vip_addr = IP4(10, 10, 1, 4), .dst_port = 80,
Annotation
- Immediate include surface: `argp.h`, `string.h`, `arpa/inet.h`, `linux/if_ether.h`, `linux/ip.h`, `linux/ipv6.h`, `linux/in.h`, `linux/tcp.h`.
- Detected declarations: `struct test_scenario`, `enum scenario_id`, `enum lru_miss_type`, `function ip_checksum`, `function htonl_v6`, `function build_flow_key`, `function build_l4`, `function build_packet`, `function populate_vip`, `function create_per_cpu_lru_maps`.
- 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.