tools/testing/selftests/bpf/xdp_features.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/xdp_features.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/xdp_features.c- Extension
.c- Size
- 16510 bytes
- Lines
- 720
- 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
uapi/linux/bpf.huapi/linux/netdev.hlinux/if_link.hsignal.hargp.hnet/if.hsys/socket.hnetinet/in.hnetinet/tcp.hunistd.harpa/inet.hbpf/bpf.hbpf/libbpf.hpthread.hnetwork_helpers.hbpf_util.hxdp_features.skel.hxdp_features.h
Detected Declarations
function test__failfunction sig_handlerfunction get_xdp_featurefunction parse_argfunction set_env_defaultfunction dut_run_echo_threadfunction dut_attach_xdp_progfunction recv_msgfunction dut_runfunction tester_collect_detected_capfunction send_and_recv_msgfunction send_echo_msgfunction tester_runfunction main
Annotated Snippet
void test__fail(void) { /* for network_helpers.c */ }
static int libbpf_print_fn(enum libbpf_print_level level,
const char *format, va_list args)
{
if (level == LIBBPF_DEBUG && !env.verbosity)
return 0;
return vfprintf(stderr, format, args);
}
static volatile bool exiting;
static void sig_handler(int sig)
{
exiting = true;
}
const char *argp_program_version = "xdp-features 0.0";
const char argp_program_doc[] =
"XDP features detection application.\n"
"\n"
"XDP features application checks the XDP advertised features match detected ones.\n"
"\n"
"USAGE: ./xdp-features [-vt] [-f <xdp-feature>] [-D <dut-data-ip>] [-T <tester-data-ip>] [-C <dut-ctrl-ip>] <iface-name>\n"
"\n"
"dut-data-ip, tester-data-ip, dut-ctrl-ip: IPv6 or IPv4-mapped-IPv6 addresses;\n"
"\n"
"XDP features\n:"
"- XDP_PASS\n"
"- XDP_DROP\n"
"- XDP_ABORTED\n"
"- XDP_REDIRECT\n"
"- XDP_NDO_XMIT\n"
"- XDP_TX\n";
static const struct argp_option opts[] = {
{ "verbose", 'v', NULL, 0, "Verbose debug output" },
{ "tester", 't', NULL, 0, "Tester mode" },
{ "feature", 'f', "XDP-FEATURE", 0, "XDP feature to test" },
{ "dut_data_ip", 'D', "DUT-DATA-IP", 0, "DUT IP data channel" },
{ "dut_ctrl_ip", 'C', "DUT-CTRL-IP", 0, "DUT IP control channel" },
{ "tester_data_ip", 'T', "TESTER-DATA-IP", 0, "Tester IP data channel" },
{},
};
static int get_xdp_feature(const char *arg)
{
if (!strcmp(arg, "XDP_PASS")) {
env.feature.action = XDP_PASS;
env.feature.drv_feature = NETDEV_XDP_ACT_BASIC;
} else if (!strcmp(arg, "XDP_DROP")) {
env.feature.drv_feature = NETDEV_XDP_ACT_BASIC;
env.feature.action = XDP_DROP;
} else if (!strcmp(arg, "XDP_ABORTED")) {
env.feature.drv_feature = NETDEV_XDP_ACT_BASIC;
env.feature.action = XDP_ABORTED;
} else if (!strcmp(arg, "XDP_TX")) {
env.feature.drv_feature = NETDEV_XDP_ACT_BASIC;
env.feature.action = XDP_TX;
} else if (!strcmp(arg, "XDP_REDIRECT")) {
env.feature.drv_feature = NETDEV_XDP_ACT_REDIRECT;
env.feature.action = XDP_REDIRECT;
} else if (!strcmp(arg, "XDP_NDO_XMIT")) {
env.feature.drv_feature = NETDEV_XDP_ACT_NDO_XMIT;
} else {
return -EINVAL;
}
return 0;
}
static char *get_xdp_feature_str(void)
{
switch (env.feature.action) {
case XDP_PASS:
return YELLOW("XDP_PASS");
case XDP_DROP:
return YELLOW("XDP_DROP");
case XDP_ABORTED:
return YELLOW("XDP_ABORTED");
case XDP_TX:
return YELLOW("XDP_TX");
case XDP_REDIRECT:
return YELLOW("XDP_REDIRECT");
default:
break;
}
if (env.feature.drv_feature == NETDEV_XDP_ACT_NDO_XMIT)
return YELLOW("XDP_NDO_XMIT");
Annotation
- Immediate include surface: `uapi/linux/bpf.h`, `uapi/linux/netdev.h`, `linux/if_link.h`, `signal.h`, `argp.h`, `net/if.h`, `sys/socket.h`, `netinet/in.h`.
- Detected declarations: `function test__fail`, `function sig_handler`, `function get_xdp_feature`, `function parse_arg`, `function set_env_default`, `function dut_run_echo_thread`, `function dut_attach_xdp_prog`, `function recv_msg`, `function dut_run`, `function tester_collect_detected_cap`.
- 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.