tools/testing/selftests/bpf/flow_dissector_load.c

Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/flow_dissector_load.c

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/bpf/flow_dissector_load.c
Extension
.c
Size
2349 bytes
Lines
112
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.

Dependency Surface

Detected Declarations

Annotated Snippet

switch (c) {
		case 'a':
			if (detach)
				error(1, 0, "attach/detach are exclusive");
			attach = true;
			break;
		case 'd':
			if (attach)
				error(1, 0, "attach/detach are exclusive");
			detach = true;
			break;
		case 'p':
			if (cfg_path_name)
				error(1, 0, "only one path can be given");

			cfg_path_name = optarg;
			break;
		case 's':
			if (cfg_prog_name)
				error(1, 0, "only one prog can be given");

			cfg_prog_name = optarg;
			break;
		}
	}

	if (detach)
		cfg_attach = false;

	if (cfg_attach && !cfg_path_name)
		error(1, 0, "must provide a path to the BPF program");

	if (cfg_attach && !cfg_prog_name)
		error(1, 0, "must provide a section name");
}

int main(int argc, char **argv)
{
	parse_opts(argc, argv);
	if (cfg_attach)
		load_and_attach_program();
	else
		detach_program();
	return 0;
}

Annotation

Implementation Notes