Try fix the usage of fd().

pull/106/head
pdliyan 8 months ago
parent c68f239ad0
commit 5d04aef980

@ -123,11 +123,11 @@ async fn main() -> Result<(), anyhow::Error> {
program.attach(cgroup)?; program.attach(cgroup)?;
{%- when "sk_msg" -%} {%- when "sk_msg" -%}
let sock_map: SockHash::<_, SockKey> = bpf.map("{{sock_map}}").unwrap().try_into()?; let sock_map: SockHash::<_, SockKey> = bpf.map("{{sock_map}}").unwrap().try_into()?;
let map_fd = sock_map.fd()?; let map_fd = sock_map.fd();
let prog: &mut SkMsg = bpf.program_mut("{{crate_name}}").unwrap().try_into()?; let prog: &mut SkMsg = bpf.program_mut("{{crate_name}}").unwrap().try_into()?;
prog.load()?; prog.load()?;
prog.attach(map_fd.into())?; prog.attach(map_fd)?;
// insert sockets to the map using sock_map.insert here, or from a sock_ops program // insert sockets to the map using sock_map.insert here, or from a sock_ops program
{%- when "xdp" -%} {%- when "xdp" -%}
let program: &mut Xdp = bpf.program_mut("{{crate_name}}").unwrap().try_into()?; let program: &mut Xdp = bpf.program_mut("{{crate_name}}").unwrap().try_into()?;

Loading…
Cancel
Save