瀏覽代碼

Set attach type during load for BPF_PROG_TYPE_CGROUP_SKB

As per title, this patch sets `expected_attach_type` during load.
Kenjiro Nakayama 2 年之前
父節點
當前提交
29c10fafb7
共有 1 個文件被更改,包括 5 次插入0 次删除
  1. 5 0
      aya/src/programs/cgroup_skb.rs

+ 5 - 0
aya/src/programs/cgroup_skb.rs

@@ -62,6 +62,11 @@ pub struct CgroupSkb {
 impl CgroupSkb {
     /// Loads the program inside the kernel.
     pub fn load(&mut self) -> Result<(), ProgramError> {
+        self.data.expected_attach_type = match self.expected_attach_type {
+            Some(CgroupSkbAttachType::Ingress) => Some(BPF_CGROUP_INET_INGRESS),
+            Some(CgroupSkbAttachType::Egress) => Some(BPF_CGROUP_INET_EGRESS),
+            None => None,
+        };
         load_program(BPF_PROG_TYPE_CGROUP_SKB, &mut self.data)
     }