From 10d1a6a736ef2d983ff3a9a10e5157943aa6c140 Mon Sep 17 00:00:00 2001 From: Dmitry Savintsev Date: Wed, 3 Aug 2022 14:29:53 +0000 Subject: [PATCH 1/2] use aya-log's 'info' macro --- tcbpftest-ebpf/src/main.rs | 1 + tcbpftest/src/main.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/tcbpftest-ebpf/src/main.rs b/tcbpftest-ebpf/src/main.rs index 173892a..8dd66c5 100644 --- a/tcbpftest-ebpf/src/main.rs +++ b/tcbpftest-ebpf/src/main.rs @@ -105,6 +105,7 @@ unsafe fn try_tcbpftest(ctx: TcContext) -> Result { unsafe { EVENTS.output(&ctx, &log_entry, 0); } + info!(&ctx, "packet:"); Ok(0) } diff --git a/tcbpftest/src/main.rs b/tcbpftest/src/main.rs index 484d1a6..f5f6bcc 100644 --- a/tcbpftest/src/main.rs +++ b/tcbpftest/src/main.rs @@ -66,6 +66,7 @@ async fn main() -> Result<(), anyhow::Error> { for buf in buffers.iter_mut().take(events.read) { let ptr = buf.as_ptr() as *const PacketLog; let data = unsafe { ptr.read_unaligned() }; + /* println!( "LOG: LEN {}, CTX_LEN {}, UDP_LEN {}, SRC_IP {}, DEST_IP {}, ETH_PROTO 0x{:X}, ETH_PROTO2 0x{:X}, IP_PROTO {}, REMOTE_PORT {}, REMOTE_PORT2 {}, LOCAL_PORT {}, LOCAL_PORT2 {}", data.len, @@ -81,6 +82,7 @@ async fn main() -> Result<(), anyhow::Error> { data.local_port, data.local_port2, ); + */ } } }); From 3fc7d22293314599117e514bec575952b3f769fb Mon Sep 17 00:00:00 2001 From: Dmitry Savintsev Date: Wed, 3 Aug 2022 20:51:40 +0000 Subject: [PATCH 2/2] import aya-log crate --- tcbpftest-ebpf/Cargo.toml | 5 +++-- tcbpftest-ebpf/src/main.rs | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tcbpftest-ebpf/Cargo.toml b/tcbpftest-ebpf/Cargo.toml index 39c627f..3b5c116 100644 --- a/tcbpftest-ebpf/Cargo.toml +++ b/tcbpftest-ebpf/Cargo.toml @@ -5,7 +5,8 @@ edition = "2021" [dependencies] aya-bpf = { git = "http://github.com/aya-rs/aya", branch = "main" } -memoffset = "0.6" +aya-log-ebpf = { git = "https://github.com/aya-rs/aya-log", branch = "main" } +memoffset = "0.6.1" tcbpftest-common = { path = "../tcbpftest-common" } [[bin]] @@ -29,4 +30,4 @@ panic = "abort" codegen-units = 1 [workspace] -members = [] \ No newline at end of file +members = [] diff --git a/tcbpftest-ebpf/src/main.rs b/tcbpftest-ebpf/src/main.rs index 8dd66c5..3460e9f 100644 --- a/tcbpftest-ebpf/src/main.rs +++ b/tcbpftest-ebpf/src/main.rs @@ -9,6 +9,7 @@ use aya_bpf::{ }; use aya_bpf::bindings:: __sk_buff; use aya_bpf::helpers::bpf_skb_pull_data; +use aya_log_ebpf::info; use core::mem; use memoffset::offset_of;