Переглянути джерело

Merge pull request #263 from nak3/cgroup-skb-attach-type

Set attach type during load for BPF_PROG_TYPE_CGROUP_SKB
Alessandro Decina 2 роки тому
батько
коміт
63b6286bd9
1 змінених файлів з 6 додано та 0 видалено
  1. 6 0
      aya/src/programs/cgroup_skb.rs

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

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