diff --git a/.github/include/aot_skip.txt b/.github/include/aot_skip.txt index c6f6fdef9c80..79b06bcc1be9 100644 --- a/.github/include/aot_skip.txt +++ b/.github/include/aot_skip.txt @@ -107,10 +107,13 @@ aot.other.symbolize enum in tuple map value aot.probe.fentry aot.probe.fentry args aot.probe.fentry args as a pointer +aot.probe.fentry_error_missing_probes aot.probe.fentry func builtin +aot.probe.fentry_ignore_missing_probes aot.probe.fentry_module aot.probe.fentry_module_wildcard aot.probe.fentry_multiple_attach_point_multiple_functions +aot.probe.fentry_warn_missing_probes aot.probe.fentry_wildcard aot.probe.fexit aot.probe.kfunc diff --git a/src/attached_probe.cpp b/src/attached_probe.cpp index a23ee21378fb..f51871e58d58 100644 --- a/src/attached_probe.cpp +++ b/src/attached_probe.cpp @@ -95,6 +95,9 @@ std::string progtypeName(libbpf::bpf_prog_type t) void AttachedProbe::attach_fentry() { + if (progfd_ < 0) + return; + tracing_fd_ = bpf_raw_tracepoint_open(nullptr, progfd_); if (tracing_fd_ < 0) { throw FatalUserException("Error attaching probe: " + probe_.name); diff --git a/src/bpfprogram.cpp b/src/bpfprogram.cpp index 9e2d2d1f8304..5b623468bc0e 100644 --- a/src/bpfprogram.cpp +++ b/src/bpfprogram.cpp @@ -63,24 +63,29 @@ void BpfProgram::set_attach_target(const Probe &probe, const std::string &mod = probe.path; const std::string &fun = probe.attach_point; + const std::string attach_target = !mod.empty() ? mod + ":" + fun : fun; const std::string &btf_fun = probe.type == ProbeType::iter ? "bpf_iter_" + fun : fun; if (btf.get_btf_id(btf_fun, mod) < 0) { - std::string msg = "No BTF found for " + mod + ":" + fun; + const std::string msg = "No BTF found for " + attach_target; if (probe.orig_name != probe.name && config.get(ConfigKeyMissingProbes::default_) != ConfigMissingProbes::error) { + // One attach point in a multi-attachpoint probe failed and the user + // requested not to error out. Show a warning (if requested) and continue + // but disable auto-loading of the program as it would make the entire BPF + // object loading fail. if (config.get(ConfigKeyMissingProbes::default_) == ConfigMissingProbes::warn) LOG(WARNING) << msg << ", skipping."; + bpf_program__set_autoload(bpf_prog_, false); } else { // explicit match failed, fail hard throw FatalUserException(msg); } } - const std::string &attach_target = !mod.empty() ? mod + ":" + fun : fun; bpf_program__set_attach_target(bpf_prog_, 0, attach_target.c_str()); } diff --git a/tests/runtime/probe b/tests/runtime/probe index 1e95847bd263..b7f449bc6378 100644 --- a/tests/runtime/probe +++ b/tests/runtime/probe @@ -68,6 +68,19 @@ REQUIRES_FEATURE fentry REQUIRES_FEATURE btf AFTER ./testprogs/fentry_args 1111 2222 +NAME fentry_warn_missing_probes +PROG fentry:vfs_read,fentry:nonsense { exit(); } +EXPECT WARNING: No BTF found for nonsense, skipping. + +NAME fentry_ignore_missing_probes +PROG config = { missing_probes = "ignore" } fentry:vfs_read,fentry:nonsense { exit(); } +EXPECT_NONE WARNING: No BTF found for nonsense, skipping. + +NAME fentry_error_missing_probes +PROG config = { missing_probes = "error" } fentry:vfs_read,fentry:nonsense { exit(); } +EXPECT ERROR: No BTF found for nonsense +WILL_FAIL + # Sanity check for kfunc/kretfunc alias NAME kfunc PROG kfunc:vfs_read { printf("SUCCESS %d\n", pid); exit(); }