pull/545/head
epompeii 2 years ago
parent 6dfb9d82af
commit 85714d5cf3

@ -212,7 +212,7 @@ impl Xdp {
frags = m
} else {
return Err(Error::new_spanned(
"mutlibuffer",
s,
"invalid value. should be 'true' or 'false'",
));
}
@ -626,7 +626,7 @@ impl Lsm {
sleepable = m
} else {
return Err(Error::new_spanned(
"mutlibuffer",
s,
"invalid value. should be 'true' or 'false'",
));
}

@ -183,7 +183,7 @@ pub enum ProgramSection {
},
Xdp {
name: String,
frags_supported: bool,
frags: bool,
},
SkMsg {
name: String,
@ -231,7 +231,7 @@ pub enum ProgramSection {
},
Lsm {
name: String,
sleepable_supported: bool,
sleepable: bool,
},
BtfTracePoint {
name: String,
@ -314,14 +314,8 @@ impl FromStr for ProgramSection {
"kretprobe" => KRetProbe { name },
"uprobe" => UProbe { name },
"uretprobe" => URetProbe { name },
"xdp" => Xdp {
name,
frags_supported: false,
},
"xdp.frags" => Xdp {
name,
frags_supported: true,
},
"xdp" => Xdp { name, frags: false },
"xdp.frags" => Xdp { name, frags: true },
"tp_btf" => BtfTracePoint { name },
_ if kind.starts_with("tracepoint") || kind.starts_with("tp") => {
// tracepoint sections are named `tracepoint/category/event_name`,
@ -475,11 +469,11 @@ impl FromStr for ProgramSection {
"raw_tp" | "raw_tracepoint" => RawTracePoint { name },
"lsm" => Lsm {
name,
sleepable_supported: false,
sleepable: false,
},
"lsm.s" => Lsm {
name,
sleepable_supported: true,
sleepable: true,
},
"fentry" => FEntry { name },
"fexit" => FExit { name },
@ -1846,7 +1840,7 @@ mod tests {
assert_matches!(
obj.programs.get("foo"),
Some(Program {
section: ProgramSection::Xdp { .. },
section: ProgramSection::Xdp { frags: false, .. },
..
})
);
@ -1867,10 +1861,7 @@ mod tests {
assert_matches!(
obj.programs.get("foo"),
Some(Program {
section: ProgramSection::Xdp {
frags_supported: true,
..
},
section: ProgramSection::Xdp { frags: true, .. },
..
})
);
@ -1928,7 +1919,10 @@ mod tests {
assert_matches!(
obj.programs.get("foo"),
Some(Program {
section: ProgramSection::Lsm { .. },
section: ProgramSection::Lsm {
sleepable: false,
..
},
..
})
);
@ -1950,7 +1944,7 @@ mod tests {
obj.programs.get("foo"),
Some(Program {
section: ProgramSection::Lsm {
sleepable_supported: true,
sleepable: true,
..
},
..

@ -478,12 +478,10 @@ impl<'a> BpfLoader<'a> {
data: ProgramData::new(prog_name, obj, btf_fd, verifier_log_level),
})
}
ProgramSection::Xdp {
frags_supported, ..
} => {
ProgramSection::Xdp { frags, .. } => {
let mut data =
ProgramData::new(prog_name, obj, btf_fd, verifier_log_level);
if *frags_supported {
if *frags {
data.flags = BPF_F_XDP_HAS_FRAGS;
}
Program::Xdp(Xdp { data })
@ -551,13 +549,10 @@ impl<'a> BpfLoader<'a> {
data: ProgramData::new(prog_name, obj, btf_fd, verifier_log_level),
})
}
ProgramSection::Lsm {
sleepable_supported,
..
} => {
ProgramSection::Lsm { sleepable, .. } => {
let mut data =
ProgramData::new(prog_name, obj, btf_fd, verifier_log_level);
if *sleepable_supported {
if *sleepable {
data.flags = BPF_F_SLEEPABLE;
}
Program::Lsm(Lsm { data })

Loading…
Cancel
Save