diff --git a/Cargo.lock b/Cargo.lock index 34c3cb1ce20..1fee2b3a911 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4948,8 +4948,8 @@ dependencies = [ [[package]] name = "ockam_ebpf" -version = "0.2.0" -source = "git+https://github.com/build-trust/ockam-ebpf.git#45aa1d7d3f37e3504ae55d2d0172d9a5b86db24c" +version = "0.4.0" +source = "git+https://github.com/build-trust/ockam-ebpf.git#d9a3ab82122ad643da394880159b12cc343896c0" dependencies = [ "reqwest", "url", diff --git a/implementations/rust/ockam/ockam_transport_tcp/Cargo.toml b/implementations/rust/ockam/ockam_transport_tcp/Cargo.toml index 49fe287bc29..5facc0303df 100644 --- a/implementations/rust/ockam/ockam_transport_tcp/Cargo.toml +++ b/implementations/rust/ockam/ockam_transport_tcp/Cargo.toml @@ -40,7 +40,7 @@ cfg-if = "1.0.0" log = "0.4.21" minicbor = { version = "0.25.1", default-features = false, features = ["derive"] } ockam_core = { path = "../ockam_core", version = "^0.120.0" } -ockam_ebpf = { git = "https://github.com/build-trust/ockam-ebpf.git", version = "0.2.0", optional = true } +ockam_ebpf = { git = "https://github.com/build-trust/ockam-ebpf.git", version = "0.4.0", optional = true } ockam_macros = { path = "../ockam_macros", version = "^0.35.0" } ockam_node = { path = "../ockam_node", version = "^0.132.0" } ockam_transport_core = { path = "../ockam_transport_core", version = "^0.97.0" } diff --git a/implementations/rust/ockam/ockam_transport_tcp/src/privileged_portal/ebpf_support.rs b/implementations/rust/ockam/ockam_transport_tcp/src/privileged_portal/ebpf_support.rs index 32bc87ffb42..266cba1c202 100644 --- a/implementations/rust/ockam/ockam_transport_tcp/src/privileged_portal/ebpf_support.rs +++ b/implementations/rust/ockam/ockam_transport_tcp/src/privileged_portal/ebpf_support.rs @@ -52,8 +52,7 @@ struct IfaceLink { struct OckamBpf { ebpf: Ebpf, - inlet_port_map: aya::maps::HashMap, - outlet_port_map: aya::maps::HashMap, + port_map: aya::maps::HashMap, } impl Default for TcpTransportEbpfSupport { @@ -219,21 +218,14 @@ impl TcpTransportEbpfSupport { warn!("failed to initialize eBPF logger: {}", e); } - let inlet_port_map = aya::maps::HashMap::<_, Port, Proto>::try_from( - ebpf.take_map("INLET_PORT_MAP").unwrap(), - ) - .map_err(map_map_error)?; - let outlet_port_map = aya::maps::HashMap::<_, Port, Proto>::try_from( - ebpf.take_map("OUTLET_PORT_MAP").unwrap(), - ) - .map_err(map_map_error)?; - - let bpf = OckamBpf { - ebpf, - inlet_port_map, - outlet_port_map, + let port_map = if let Some(map) = ebpf.take_map("PORT_MAP") { + aya::maps::HashMap::<_, Port, Proto>::try_from(map).map_err(map_map_error)? + } else { + return Err(Error::new(Origin::Core, Kind::Io, "PORT_MAP doesn't exist")); }; + let bpf = OckamBpf { ebpf, port_map }; + *bpf_lock = Some(bpf); info!("Initialized eBPF"); @@ -343,7 +335,7 @@ impl TcpTransportEbpfSupport { bpf.as_mut() .unwrap() - .inlet_port_map + .port_map .insert(port, self.ip_proto, 0) .map_err(|e| TransportError::AddingInletPort(e.to_string()))?; @@ -356,7 +348,7 @@ impl TcpTransportEbpfSupport { bpf.as_mut() .unwrap() - .inlet_port_map + .port_map .remove(&port) .map_err(|e| TransportError::RemovingInletPort(e.to_string()))?; @@ -369,7 +361,7 @@ impl TcpTransportEbpfSupport { bpf.as_mut() .unwrap() - .outlet_port_map + .port_map .insert(port, self.ip_proto, 0) .map_err(|e| TransportError::AddingOutletPort(e.to_string()))?; @@ -382,7 +374,7 @@ impl TcpTransportEbpfSupport { bpf.as_mut() .unwrap() - .outlet_port_map + .port_map .remove(&port) .map_err(|e| TransportError::RemovingOutletPort(e.to_string()))?;