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

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

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

Loading…
Cancel
Save