Use map()

pull/263/head
Kenjiro Nakayama 3 years ago
parent 29c10fafb7
commit 5d228695a4

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

Loading…
Cancel
Save