Fix sk_msg tests

These were broken by #89 which pulled in
https://github.com/aya-rs/aya/pull/397 and other changes which were not
reflected in the templates.
pull/90/head
Tamir Duberstein 1 year ago
parent b45787c353
commit 3013ab506d
No known key found for this signature in database

@ -8,7 +8,7 @@ default = []
user = ["aya"] user = ["aya"]
[dependencies] [dependencies]
aya = { version = ">=0.11", optional = true } aya = { git = "https://github.com/aya-rs/aya", optional = true }
[lib] [lib]
path = "src/lib.rs" path = "src/lib.rs"

@ -10,7 +10,7 @@ use aya::programs::UProbe;
{%- when "sock_ops" -%} {%- when "sock_ops" -%}
use aya::programs::SockOps; use aya::programs::SockOps;
{%- when "sk_msg" -%} {%- when "sk_msg" -%}
use aya::maps::{MapRefMut,SockHash}; use aya::maps::SockHash;
use aya::programs::SkMsg; use aya::programs::SkMsg;
use {{crate_name}}_common::SockKey; use {{crate_name}}_common::SockKey;
{%- when "xdp" -%} {%- when "xdp" -%}
@ -112,10 +112,12 @@ async fn main() -> Result<(), anyhow::Error> {
program.load()?; program.load()?;
program.attach(cgroup)?; program.attach(cgroup)?;
{%- when "sk_msg" -%} {%- when "sk_msg" -%}
let sock_map = SockHash::<MapRefMut, SockKey>::try_from(bpf.map_mut("{{sock_map}}")?)?; let sock_map: SockHash::<_, SockKey> = bpf.map("{{sock_map}}").unwrap().try_into()?;
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(&sock_map)?; 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