tools/testing/selftests/bpf/prog_tests/exceptions.c

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

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/bpf/prog_tests/exceptions.c
Extension
.c
Size
16221 bytes
Lines
418
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

if (load_ret != 0) {						  \
			if (!ASSERT_OK_PTR(strstr(log_buf, msg), "strstr")) {	  \
				printf("%s\n", log_buf);			  \
				goto done;					  \
			}							  \
		}								  \
		if (!load_ret && attach_err) {					  \
			if (!ASSERT_ERR_PTR(link = bpf_program__attach(prog), "attach err")) \
				goto done;					  \
		} else if (!load_ret) {						  \
			if (!ASSERT_OK_PTR(link = bpf_program__attach(prog), "attach ok"))  \
				goto done;					  \
			(void)(after_link);					  \
			bpf_link__destroy(link);				  \
		}								  \
	}

	if (test__start_subtest("non-throwing fentry -> exception_cb"))
		RUN_EXT(-EINVAL, true, ({
			prog = eskel->progs.pfentry;
			bpf_program__set_autoload(prog, true);
			if (!ASSERT_OK(bpf_program__set_attach_target(prog,
				       bpf_program__fd(skel->progs.exception_ext_mod_cb_runtime),
				       "exception_cb_mod"), "set_attach_target"))
				goto done;
		}), "Tracing programs cannot attach to exception callback", 0);

	if (test__start_subtest("throwing fentry -> exception_cb"))
		RUN_EXT(-EINVAL, true, ({
			prog = eskel->progs.throwing_fentry;
			bpf_program__set_autoload(prog, true);
			if (!ASSERT_OK(bpf_program__set_attach_target(prog,
				       bpf_program__fd(skel->progs.exception_ext_mod_cb_runtime),
				       "exception_cb_mod"), "set_attach_target"))
				goto done;
		}), "Tracing programs cannot attach to exception callback", 0);

	if (test__start_subtest("non-throwing fexit -> exception_cb"))
		RUN_EXT(-EINVAL, true, ({
			prog = eskel->progs.pfexit;
			bpf_program__set_autoload(prog, true);
			if (!ASSERT_OK(bpf_program__set_attach_target(prog,
				       bpf_program__fd(skel->progs.exception_ext_mod_cb_runtime),
				       "exception_cb_mod"), "set_attach_target"))
				goto done;
		}), "Tracing programs cannot attach to exception callback", 0);

	if (test__start_subtest("throwing fexit -> exception_cb"))
		RUN_EXT(-EINVAL, true, ({
			prog = eskel->progs.throwing_fexit;
			bpf_program__set_autoload(prog, true);
			if (!ASSERT_OK(bpf_program__set_attach_target(prog,
				       bpf_program__fd(skel->progs.exception_ext_mod_cb_runtime),
				       "exception_cb_mod"), "set_attach_target"))
				goto done;
		}), "Tracing programs cannot attach to exception callback", 0);

	if (test__start_subtest("throwing extension (with custom cb) -> exception_cb"))
		RUN_EXT(-EINVAL, true, ({
			prog = eskel->progs.throwing_exception_cb_extension;
			bpf_program__set_autoload(prog, true);
			if (!ASSERT_OK(bpf_program__set_attach_target(prog,
				       bpf_program__fd(skel->progs.exception_ext_mod_cb_runtime),
				       "exception_cb_mod"), "set_attach_target"))
				goto done;
		}), "Extension programs cannot attach to exception callback", 0);

	if (test__start_subtest("throwing extension -> global func in exception_cb"))
		RUN_EXT(0, false, ({
			prog = eskel->progs.throwing_exception_cb_extension;
			bpf_program__set_autoload(prog, true);
			if (!ASSERT_OK(bpf_program__set_attach_target(prog,
				       bpf_program__fd(skel->progs.exception_ext_mod_cb_runtime),
				       "exception_cb_mod_global"), "set_attach_target"))
				goto done;
		}), "", ({ RUN_SUCCESS(exception_ext_mod_cb_runtime, 131); }));

	if (test__start_subtest("throwing extension (with custom cb) -> global func in exception_cb"))
		RUN_EXT(0, false, ({
			prog = eskel->progs.throwing_extension;
			bpf_program__set_autoload(prog, true);
			if (!ASSERT_OK(bpf_program__set_attach_target(prog,
				       bpf_program__fd(skel->progs.exception_ext),
				       "exception_ext_global"), "set_attach_target"))
				goto done;
		}), "", ({ RUN_SUCCESS(exception_ext, 128); }));

	if (test__start_subtest("non-throwing fentry -> non-throwing subprog"))
		/* non-throwing fentry -> non-throwing subprog : OK */
		RUN_EXT(0, false, ({

Annotation

Implementation Notes