DevinLeamy commented on code in PR #519:
URL: https://github.com/apache/mesos/pull/519#discussion_r1532734374


##########
src/linux/cgroups2.cpp:
##########
@@ -295,4 +296,152 @@ Try<set<string>> enabled(const string& cgroup)
 
 } // namespace controllers {
 
+namespace devices {
+
+const int ALLOW_ACCESS = 1;
+
+const int DENY_ACCESS = 0;
+
+// Utility class to construct an eBPF program to whitelist or blacklist
+// select device accesses.
+class DeviceProgram
+{
+public:
+  DeviceProgram() : program{ebpf::Program(BPF_PROG_TYPE_CGROUP_DEVICE)}
+  {
+    program.append({
+        // r2: Type ('c', 'b', '?')
+        BPF_LDX_MEM(BPF_W, BPF_REG_2, BPF_REG_1, 0),
+        BPF_ALU32_IMM(BPF_AND, BPF_REG_2, 0xFFFF),
+        // r3: Access ('r', 'w', 'm')
+        BPF_LDX_MEM(BPF_W, BPF_REG_3, BPF_REG_1, 0),
+        BPF_ALU32_IMM(BPF_RSH, BPF_REG_3, 16),
+        // r4: Major Version
+        BPF_LDX_MEM(BPF_W, BPF_REG_4, BPF_REG_1, 4),
+        // r5: Minor Version
+        BPF_LDX_MEM(BPF_W, BPF_REG_5, BPF_REG_1, 8)});

Review Comment:
   Make this more clear.



-- 
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-unsubscr...@mesos.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to