Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rust): disable ebpf logs #8613

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion implementations/rust/ockam/ockam_ebpf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ description = """
eBPF program used by Ockam TCP Portals
"""

[features]
default = []
logging = ["aya-log-ebpf"]

[dependencies]
aya-ebpf = "0.1.1"
aya-log-ebpf = "0.1.1"
aya-log-ebpf = { version = "0.1.1", optional = true }
network-types = "0.0.7"

[[bin]]
Expand Down
Binary file modified implementations/rust/ockam/ockam_ebpf/ockam_ebpf
Binary file not shown.
14 changes: 7 additions & 7 deletions implementations/rust/ockam/ockam_ebpf/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use aya_ebpf::bindings::TC_ACT_PIPE;
use aya_ebpf::macros::map;
use aya_ebpf::maps::HashMap;
use aya_ebpf::programs::TcContext;
use aya_log_ebpf::{error, trace, warn};

use crate::conversion::{convert_ockam_to_tcp, convert_tcp_to_ockam};
use crate::{error, trace, warn};

pub type Proto = u8;

Expand Down Expand Up @@ -140,7 +140,7 @@ fn handle_ingress_tcp_protocol(ctx: &TcContext, ipv4hdr: *mut Ipv4Hdr) -> Result
syn,
ack,
fin,
rst,
rst
);

convert_tcp_to_ockam(ctx, ipv4hdr, proto);
Expand Down Expand Up @@ -169,7 +169,7 @@ fn handle_ingress_tcp_protocol(ctx: &TcContext, ipv4hdr: *mut Ipv4Hdr) -> Result
syn,
ack,
fin,
rst,
rst
);

convert_tcp_to_ockam(ctx, ipv4hdr, proto);
Expand All @@ -193,7 +193,7 @@ fn handle_ingress_tcp_protocol(ctx: &TcContext, ipv4hdr: *mut Ipv4Hdr) -> Result
syn,
ack,
fin,
rst,
rst
);

Ok(TC_ACT_PIPE)
Expand Down Expand Up @@ -271,7 +271,7 @@ fn handle_egress_ockam_protocol(ctx: &TcContext, ipv4hdr: *mut Ipv4Hdr) -> Resul
syn,
ack,
fin,
rst,
rst
);

convert_ockam_to_tcp(ctx, ipv4hdr, tcphdr);
Expand Down Expand Up @@ -300,7 +300,7 @@ fn handle_egress_ockam_protocol(ctx: &TcContext, ipv4hdr: *mut Ipv4Hdr) -> Resul
syn,
ack,
fin,
rst,
rst
);

convert_ockam_to_tcp(ctx, ipv4hdr, tcphdr);
Expand All @@ -326,7 +326,7 @@ fn handle_egress_ockam_protocol(ctx: &TcContext, ipv4hdr: *mut Ipv4Hdr) -> Resul
syn,
ack,
fin,
rst,
rst
);

Ok(TC_ACT_PIPE)
Expand Down
6 changes: 6 additions & 0 deletions implementations/rust/ockam/ockam_ebpf/src/entrypoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ mod checksum_helpers;
mod common;
mod conversion;

#[cfg(feature = "logging")]
mod logger_aya;

#[cfg(not(feature = "logging"))]
mod logger_noop;

use crate::common::Direction;

#[classifier]
Expand Down
34 changes: 34 additions & 0 deletions implementations/rust/ockam/ockam_ebpf/src/logger_aya.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#[macro_export]
macro_rules! error {
($($x:expr),*) => {
aya_log_ebpf::error!{ $($x,)+ }
};
}

#[macro_export]
macro_rules! warn {
($($x:expr),*) => {
aya_log_ebpf::warn!{ $($x,)+ }
}
}

#[macro_export]
macro_rules! debug {
($($x:expr),*) => {
aya_log_ebpf::debug!{ $($x,)+ }
}
}

#[macro_export]
macro_rules! info {
($($x:expr),*) => {
aya_log_ebpf::info!{ $($x,)+ }
}
}

#[macro_export]
macro_rules! trace {
($($x:expr),*) => {
aya_log_ebpf::trace!{ $($x,)+ }
}
}
44 changes: 44 additions & 0 deletions implementations/rust/ockam/ockam_ebpf/src/logger_noop.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#[macro_export]
macro_rules! error {
($($x:expr),*) => {{
$(
_ = $x;
)*
}};
}

#[macro_export]
macro_rules! warn {
($($x:expr),*) => {{
$(
_ = $x;
)*
}};
}

#[macro_export]
macro_rules! debug {
($($x:expr),*) => {{
$(
_ = $x;
)*
}};
}

#[macro_export]
macro_rules! info {
($($x:expr),*) => {{
$(
_ = $x;
)*
}};
}

#[macro_export]
macro_rules! trace {
($($x:expr),*) => {{
$(
_ = $x;
)*
}};
}
Loading