Repository: libbpf/libbpf-rs (language: rust)

Issue:
Get/set bpf program flags
Implement the ability to get and set program flags. This should be a wrapper around the libbpf library's

`__u32 bpf_program__flags(const struct bpf_program *prog);`

and

`int bpf_program__set_flags(struct bpf_program *prog, __u32 flags);`

(https://github.com/libbpf/libbpf/blob/master/src/libbpf.c#L8538-L8550). 

The libbpf-rs code for interacting with programs is located at libbpf-rs/src/program.rs




Discussion / hints:
@kckeiks, would this be something you're interested in? 
Yeah I can do this one and #200 

Fix patch:
diff --git a/libbpf-rs/src/program.rs b/libbpf-rs/src/program.rs
index 60fc0c21..56732f0c 100644
--- a/libbpf-rs/src/program.rs
+++ b/libbpf-rs/src/program.rs
@@ -70,6 +70,11 @@ impl OpenProgram {
         };
         util::parse_ret(ret)
     }
+
+    pub fn set_flags(&self, flags: u32) -> Result<()> {
+        let ret = unsafe { libbpf_sys::bpf_program__set_flags(self.ptr, flags) };
+        util::parse_ret(ret)
+    }
 }
 
 /// Type of a [`Program`]. Maps to `enum bpf_prog_type` in kernel uapi.
@@ -203,6 +208,11 @@ impl Program {
         unsafe { libbpf_sys::bpf_program__fd(self.ptr) }
     }
 
+    /// Returns flags that have been set for the program.
+    pub fn flags(&self) -> u32 {
+        unsafe { libbpf_sys::bpf_program__flags(self.ptr) }
+    }
+
     pub fn attach_type(&self) -> ProgramAttachType {
         match ProgramAttachType::try_from(unsafe {
             libbpf_sys::bpf_program__get_expected_attach_type(self.ptr)


Test patch: