Skip to content

Commit

Permalink
Use map()
Browse files Browse the repository at this point in the history
  • Loading branch information
nak3 committed May 20, 2022
1 parent 29c10fa commit 6207917
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions aya/src/programs/cgroup_skb.rs
Expand Up @@ -62,11 +62,10 @@ 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,
};
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)
}

Expand Down

0 comments on commit 6207917

Please sign in to comment.