You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@mesos.apache.org by "DevinLeamy (via GitHub)" <gi...@apache.org> on 2024/03/11 21:35:18 UTC
[PR] [ebpf][cgroups2] Update ebpf::cgroups2::attach() to load and attach. [mesos]
DevinLeamy opened a new pull request, #512:
URL: https://github.com/apache/mesos/pull/512
Correctly handling eBPF file descriptors requires some subtle knowledge about how loading and unloading eBPF programs works.
Specifically, to unload an eBPF program there cannot be any open file descriptors to the program and the program cannot be attached.
To avoid requiring users of the API to know that the file descriptor returned by `ebpf::load()` needs to be closed before the loaded program can be detached, we remove `ebpf::load()` from the public interface and update `ebpf::cgroups2::load()` to:
1. Load a program,
2. attach the program, and
3. close the loaded program's file descriptor, so detaching it will unload it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@mesos.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ebpf][cgroups2] Update ebpf::cgroups2::attach() to load and attach. [mesos]
Posted by "bmahler (via GitHub)" <gi...@apache.org>.
bmahler commented on code in PR #512:
URL: https://github.com/apache/mesos/pull/512#discussion_r1520498604
##########
src/linux/ebpf.cpp:
##########
@@ -152,6 +159,24 @@ Try<Nothing> attach(int fd, const string& cgroup)
}
+Try<Nothing> attach(const string& cgroup, const Program& program)
+{
+ Try<int> program_fd = ebpf::load(program);
+ if (program_fd.isError()) {
+ return Error("Failed to load eBPF program: " + program_fd.error());
+ }
+
+ Try<Nothing> _attach = attach(cgroup, *program_fd);
+ if (_attach.isError()) {
+ return Error("Failed to attach eBPF program: " + _attach.error());
Review Comment:
we're leaking the program fd in this branch
##########
src/linux/ebpf.cpp:
##########
@@ -65,6 +65,8 @@ void Program::append(vector<bpf_insn>&& instructions)
}
+// Load an eBPF program into the kernel and return the file
+// descriptor of the loaded program.
Review Comment:
This is still left in the header?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@mesos.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [ebpf][cgroups2] Update ebpf::cgroups2::attach() to load and attach. [mesos]
Posted by "bmahler (via GitHub)" <gi...@apache.org>.
bmahler closed pull request #512: [ebpf][cgroups2] Update ebpf::cgroups2::attach() to load and attach.
URL: https://github.com/apache/mesos/pull/512
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@mesos.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org