Skip to content

Commit

Permalink
ci: test
Browse files Browse the repository at this point in the history
  • Loading branch information
SanjoDeundiak committed Oct 21, 2024
1 parent a976332 commit 0fe2d54
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 33 deletions.
49 changes: 27 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions implementations/rust/ockam/ockam_transport_tcp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ tokio-rustls = { version = "0.26", default-features = false, features = ["loggin
tracing = { version = "0.1", default-features = false }

[target.'cfg( target_os = "linux" )'.dependencies]
aya = { version = "=0.12.0", optional = true }
aya-log = { version = "=0.2.0", optional = true }
aya-log-common = { version = "=0.1.14", optional = true }
aya = { version = "=0.13.0", optional = true }
aya-log = { version = "=0.2.1", optional = true }
aya-log-common = { version = "=0.1.15", optional = true }

[target.'cfg( any(target_os = "linux", target_os = "macos") )'.dependencies]
env_logger = { version = "0.11", optional = true }
libc = { version = "0.2", optional = true }
nix = { version = "0.29", features = ["net"], optional = true }
nix = { version = "0.29", features = ["net", "user"], optional = true }
pnet = { version = "0.35.0", optional = true }
pnet_sys = { version = "0.35.0", optional = true }
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ use crate::ebpf_portal::{InletRegistry, OutletRegistry, RawSocketProcessor};
use aya::maps::{MapData, MapError};
use aya::programs::tc::SchedClassifierLink;
use aya::programs::{tc, Link, ProgramError, SchedClassifier, TcAttachType};
use aya::{Bpf, BpfError};
use aya_log::BpfLogger;
use aya::{Ebpf, EbpfError};
use aya_log::EbpfLogger;
use core::fmt::{Debug, Formatter};
use log::error;
use ockam_core::compat::collections::HashMap;
use ockam_core::errcode::{Kind, Origin};
use ockam_core::{Address, Error, Result};
Expand Down Expand Up @@ -41,7 +42,7 @@ struct IfaceLink {
}

struct OckamBpf {
bpf: Bpf,
bpf: Ebpf,

inlet_port_map: aya::maps::HashMap<MapData, Port, Proto>,
outlet_port_map: aya::maps::HashMap<MapData, Port, Proto>,
Expand Down Expand Up @@ -145,12 +146,12 @@ impl TcpTransportEbpfSupport {
// reach for `Bpf::load_file` instead.

let ebpf_binary = aya::include_bytes_aligned!("../../../ockam_ebpf/ockam_ebpf");
let mut bpf = Bpf::load(ebpf_binary).map_err(map_bpf_error)?;
let mut bpf = Ebpf::load(ebpf_binary).map_err(map_bpf_error)?;
// eBPF can be read from the filesystem in the runtime for development purposes
// let ebpf_binary = std::fs::read(PATH).unwrap();
// let mut bpf = Bpf::load(&ebpf_binary).map_err(map_bpf_error)?;

if let Err(e) = BpfLogger::init(&mut bpf) {
if let Err(e) = EbpfLogger::init(&mut bpf) {
// This can happen if you remove all log statements from your eBPF program.
warn!("failed to initialize eBPF logger for ingress: {}", e);
}
Expand Down Expand Up @@ -332,7 +333,8 @@ impl TcpTransportEbpfSupport {
}

#[track_caller]
fn map_bpf_error(bpf_error: BpfError) -> Error {
fn map_bpf_error(bpf_error: EbpfError) -> Error {
error!("Ebpf error: {}", bpf_error);
Error::new(Origin::Core, Kind::Io, bpf_error)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::ebpf_portal::{InternalProcessor, Port, RemoteWorker};
use crate::portal::InletSharedState;
use crate::{TcpInlet, TcpInletOptions, TcpOutletOptions, TcpTransport};
use core::fmt::Debug;
use nix::unistd::Uid;
use ockam_core::{Address, DenyAll, Result, Route};
use ockam_node::compat::asynchronous::resolve_peer;
use ockam_node::{ProcessorBuilder, WorkerBuilder};
Expand All @@ -21,6 +22,10 @@ impl TcpTransport {
outlet_route: impl Into<Route> + Clone + Debug,
options: TcpInletOptions,
) -> Result<TcpInlet> {
if !Uid::effective().is_root() {
panic!("You must run this executable with root permissions");
}

let outlet_route = outlet_route.into();

let next = outlet_route.next().cloned()?;
Expand Down Expand Up @@ -130,6 +135,10 @@ impl TcpTransport {
peer: HostnamePort,
options: TcpOutletOptions, // FIXME
) -> Result<()> {
if !Uid::effective().is_root() {
panic!("You must run this executable with root permissions");
}

// Resolve peer address as a host name and port
tracing::Span::current().record("peer", peer.to_string());

Expand Down
3 changes: 3 additions & 0 deletions implementations/rust/ockam/xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
//! - Linux
//! - Rust nightly
//! - Some dependencies to be installed
//!
//! Because of that crate with the eBPF code is kept out of the workspace.
//!
//! Example of a virtual machine to build it can be found in `ubuntu_x86.yaml`.
//!
//! Using ockam with eBPFs requires:
//! - Linux
//! - root (CAP_BPF)
//!
//! Example of a virtual machine to run ockam with eBPF can be found in `ubuntu_arm.yaml`.
//!
//! eBPF is a small architecture-independent object file that is small enough,
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel = "1.78"
channel = "1.80"
components = ["clippy", "rustfmt"]
profile = "minimal"
targets = ["thumbv7em-none-eabihf"]

0 comments on commit 0fe2d54

Please sign in to comment.