1- #![ allow( warnings) ]
21use anyhow:: Context ;
32use chrono:: Local ;
43use cortexbrain_common:: formatters:: { format_ipv4, format_ipv6} ;
54use cortexbrain_common:: map_handlers:: load_perf_event_array_from_mapdata;
65use prost:: bytes:: BytesMut ;
6+ use std:: str:: FromStr ;
77use std:: sync:: Mutex ;
8- use std:: { str:: FromStr , sync:: Arc } ;
98use tonic:: { Request , Response , Status } ;
109use tracing:: info;
1110
12- use aya:: {
13- maps:: { MapData , PerfEventArray } ,
14- util:: online_cpus,
15- } ;
11+ use aya:: { maps:: MapData , util:: online_cpus} ;
1612use std:: result:: Result :: Ok ;
1713use tonic:: async_trait;
1814
@@ -39,7 +35,6 @@ use crate::constants::PIN_BLOCKLIST_MAP_PATH;
3935use crate :: helpers:: comm_to_string;
4036use aya:: maps:: Map ;
4137use cortexbrain_common:: buffer_type:: IpProtocols ;
42- use cortexbrain_common:: constants:: BPF_PATH ;
4338use std:: net:: Ipv4Addr ;
4439use tracing:: warn;
4540
@@ -104,7 +99,6 @@ pub trait EventSender: Send + Sync + 'static {
10499 let event = Ok ( map) ;
105100 let _ = tx. send ( event) . await ;
106101 }
107-
108102}
109103
110104// send event function. takes an HashMap and send that using mpsc event_tx
@@ -155,7 +149,7 @@ impl Default for AgentApi {
155149 let ( conn_tx, conn_rx) = mpsc:: channel ( 1024 ) ;
156150 let ( lat_tx, lat_rx) = mpsc:: channel ( 2048 ) ;
157151 let ( drop_tx, drop_rx) = mpsc:: channel ( 2048 ) ;
158- let ( tracked_veth_tx , tracked_veth_rx) = mpsc:: channel ( 1024 ) ;
152+ let ( veth_tx , tracked_veth_rx) = mpsc:: channel ( 1024 ) ;
159153
160154 let api = AgentApi {
161155 active_connection_event_rx : conn_rx. into ( ) ,
@@ -165,7 +159,7 @@ impl Default for AgentApi {
165159 dropped_packet_metrics_rx : Mutex :: new ( drop_rx) ,
166160 dropped_packet_metrics_tx : drop_tx. clone ( ) ,
167161 tracked_veth_rx : Mutex :: new ( tracked_veth_rx) ,
168- tracked_veth_tx : tracked_veth_tx . clone ( ) ,
162+ tracked_veth_tx : veth_tx . clone ( ) ,
169163 } ;
170164
171165 // For network metrics
@@ -441,12 +435,12 @@ impl Default for AgentApi {
441435 //read the events, this function is similar to the one used in identity/helpers.rs/display_events
442436 if events. read > 0 {
443437 for i in 0 ..events. read {
438+ info ! ( "Found veth events {}" , events. read) ;
444439 let data = & buffers[ i] ;
445440 if data. len ( ) >= std:: mem:: size_of :: < VethLog > ( ) {
446441 let veth: VethLog =
447442 unsafe { std:: ptr:: read ( data. as_ptr ( ) as * const _ ) } ;
448443 let veth_event = VethEvent {
449- event_id : todo ! ( ) ,
450444 name : String :: from_utf8_lossy ( unsafe {
451445 std:: slice:: from_raw_parts (
452446 veth. name . as_ptr ( ) as * const u8 ,
@@ -469,9 +463,18 @@ impl Default for AgentApi {
469463 netns : veth. netns ,
470464 pid : veth. pid ,
471465 } ;
466+ info ! (
467+ "Veth Event - name: {}, state: {}, dev_addr: {}, event_type: {}, netns: {}, pid: {}" ,
468+ veth_event. name,
469+ veth_event. state,
470+ veth_event. dev_addr,
471+ veth_event. event_type,
472+ veth_event. netns,
473+ veth_event. pid
474+ ) ;
472475 let mut evt = Vec :: new ( ) ;
473476 evt. push ( veth_event. clone ( ) ) ;
474- let _ = tracked_veth_tx . send ( Ok ( evt) ) . await ;
477+ let _ = veth_tx . send ( Ok ( evt) ) . await ;
475478 } else {
476479 warn ! (
477480 "Received time stamp metrics data too small: {} bytes" ,
0 commit comments