bmahler commented on code in PR #501:
URL: https://github.com/apache/mesos/pull/501#discussion_r1518222165


##########
src/linux/ebpf.cpp:
##########
@@ -14,4 +14,90 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#include "linux/ebpf.hpp"
\ No newline at end of file
+#include "linux/ebpf.hpp"
+
+#include <linux/bpf.h>
+#include <sys/syscall.h>
+
+#include <string>
+#include <vector>
+
+#include "stout/check.hpp"
+#include "stout/error.hpp"
+#include "stout/try.hpp"
+
+using std::string;
+using std::vector;
+
+namespace ebpf {
+
+Try<int, ErrnoError> bpf(int cmd, bpf_attr* attr, size_t size)
+{
+  // We retry the system call `attempts` times. The default is 5, as per
+  // what's done by libbpf:
+  // https://github.com/libbpf/libbpf/blob/master/src/bpf.h#L71-L75
+  int result, attempts = 5;
+  do {
+    result = (int)syscall(__NR_bpf, cmd, attr, size);
+  } while (result == EAGAIN && --attempts > 0);

Review Comment:
   this needs to check errno



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to