-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/75083/#review226663
-----------------------------------------------------------


Ship it!




```
diff --git a/src/linux/ebpf.cpp b/src/linux/ebpf.cpp
index bfe6b7bcd..50f2c6743 100644
--- a/src/linux/ebpf.cpp
+++ b/src/linux/ebpf.cpp
@@ -107,21 +107,23 @@ Try<int> load(const Program& program)
 
 namespace cgroups2 {
 
-Try<int> bpf_get_fd_by_id(uint32_t prog_id) {
+Try<int> bpf_get_fd_by_id(uint32_t prog_id)
+{
   bpf_attr attr;
   memset(&attr, 0, sizeof(attr));
   attr.prog_id = prog_id;
 
-  Try<int, ErrnoError> _replace_program_fd =
-    bpf(BPF_PROG_GET_FD_BY_ID, &attr, sizeof(attr));
+  Try<int, ErrnoError> fd = bpf(BPF_PROG_GET_FD_BY_ID, &attr, sizeof(attr));
 
-  if (_replace_program_fd.isError()) {
+  if (fd.isError()) {
     return Error("bpf syscall to BPF_PROG_GET_FD_BY_ID failed: " +
-                _replace_program_fd.error().message);
+                 fd.error().message);
   }
-  return *_replace_program_fd;
+
+  return *fd;
 }
 
+
 // Attaches the eBPF program identified by the provided fd to a cgroup.
 //
 // TODO(dleamy): This currently does not replace existing programs attached
diff --git a/src/tests/containerizer/cgroups2_tests.cpp 
b/src/tests/containerizer/cgroups2_tests.cpp
index 48e082bb9..e4796b6ca 100644
--- a/src/tests/containerizer/cgroups2_tests.cpp
+++ b/src/tests/containerizer/cgroups2_tests.cpp
@@ -758,7 +758,9 @@ INSTANTIATE_TEST_CASE_P(
         }
       ));
 
-TEST_F(Cgroups2Test, ROOT_CGROUPS2_GetBpfFdById) {
+
+TEST_F(Cgroups2Test, ROOT_CGROUPS2_GetBpfFdById)
+{
   const string& cgroup = TEST_CGROUP;
 
   ASSERT_SOME(cgroups2::create(cgroup));

```

- Benjamin Mahler


On July 11, 2024, 3:25 p.m., Jason Zhou wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/75083/
> -----------------------------------------------------------
> 
> (Updated July 11, 2024, 3:25 p.m.)
> 
> 
> Review request for mesos and Benjamin Mahler.
> 
> 
> Repository: mesos
> 
> 
> Description
> -------
> 
> Introduces a helper function to help abstract away the logic for getting bpf 
> program file descriptor by its program id.
> 
> 
> Diffs
> -----
> 
>   src/linux/ebpf.hpp 5bf9d34d4ae5105ef36005955da09101d3c54c7a 
>   src/linux/ebpf.cpp 3f7f74df25dbf35720cd5f6c19644173552d5b82 
>   src/tests/containerizer/cgroups2_tests.cpp 
> cb1e229f7f40aa71f57417c33fccb2cfb313a1f5 
> 
> 
> Diff: https://reviews.apache.org/r/75083/diff/2/
> 
> 
> Testing
> -------
> 
> Added an explicit test for get_fd_by_id where we use the function to get the 
> file descriptor for the bpf detach call.
> tests passed.
> 
> 
> Thanks,
> 
> Jason Zhou
> 
>

Reply via email to