diff --git a/agent/src/config/handler.rs b/agent/src/config/handler.rs index 40f0f0193b6..cbc6b3d3456 100644 --- a/agent/src/config/handler.rs +++ b/agent/src/config/handler.rs @@ -83,7 +83,7 @@ use public::{ netns::{self, NsFile}, }; -use crate::utils::cgroups::is_kernel_available_for_cgroups; +use crate::{trident::AgentId, utils::cgroups::is_kernel_available_for_cgroups}; #[cfg(target_os = "windows")] use public::utils::net::links_by_name_regex; use public::utils::net::MacAddr; @@ -2239,15 +2239,9 @@ impl ConfigHandler { callbacks } - pub fn load_plugin( - &mut self, - rt: &Arc, - session: &Arc, - ctrl_ip: &str, - ctrl_mac: &str, - ) { + pub fn load_plugin(&mut self, rt: &Arc, session: &Arc, agent_id: &AgentId) { self.candidate_config - .fill_plugin_prog_from_server(rt, session, ctrl_ip, ctrl_mac); + .fill_plugin_prog_from_server(rt, session, agent_id); self.current_config .store(Arc::new(self.candidate_config.clone())); } @@ -2274,8 +2268,7 @@ impl ModuleConfig { &mut self, rt: &Arc, session: &Arc, - ctrl_ip: &str, - ctrl_mac: &str, + agent_id: &AgentId, ) { let mut wasm = vec![]; #[cfg(target_os = "windows")] @@ -2285,7 +2278,7 @@ impl ModuleConfig { rt.block_on(async { for i in self.yaml_config.wasm_plugins.iter() { match session - .get_plugin(i.as_str(), trident::PluginType::Wasm, ctrl_ip, ctrl_mac) + .get_plugin(i.as_str(), trident::PluginType::Wasm, agent_id) .await { Ok(prog) => wasm.push((i.clone(), prog)), @@ -2301,7 +2294,7 @@ impl ModuleConfig { rt.block_on(async { for i in self.yaml_config.so_plugins.iter() { match session - .get_plugin(i.as_str(), trident::PluginType::So, ctrl_ip, ctrl_mac) + .get_plugin(i.as_str(), trident::PluginType::So, agent_id) .await { Ok(prog) => match load_plugin(prog.as_slice(), i) { diff --git a/agent/src/flow_generator/flow_map.rs b/agent/src/flow_generator/flow_map.rs index d1a5406f02e..4aca5808233 100644 --- a/agent/src/flow_generator/flow_map.rs +++ b/agent/src/flow_generator/flow_map.rs @@ -1639,7 +1639,7 @@ impl FlowMap { let (l7_perf_stats, l7_protocol) = perf.copy_and_reset_l7_perf_data(l7_timeout_count as u32); - let mut flow_perf_stats = flow.flow_perf_stats.as_mut().unwrap(); + let flow_perf_stats = flow.flow_perf_stats.as_mut().unwrap(); flow_perf_stats.l7.sequential_merge(&l7_perf_stats); flow_perf_stats.l7_protocol = l7_protocol; l7_stats.stats = l7_perf_stats; @@ -1726,7 +1726,7 @@ impl FlowMap { let (l7_perf_stats, l7_protocol) = perf.copy_and_reset_l7_perf_data(l7_timeout_count as u32); - let mut flow_perf_stats = flow.flow_perf_stats.as_mut().unwrap(); + let flow_perf_stats = flow.flow_perf_stats.as_mut().unwrap(); flow_perf_stats.l7.sequential_merge(&l7_perf_stats); flow_perf_stats.l7_protocol = l7_protocol; if flow.flow_key.proto == IpProtocol::Tcp diff --git a/agent/src/rpc/session.rs b/agent/src/rpc/session.rs index 256efd2c992..05bf0e205bb 100644 --- a/agent/src/rpc/session.rs +++ b/agent/src/rpc/session.rs @@ -27,9 +27,12 @@ use log::{debug, error, info}; use parking_lot::RwLock; use tonic::transport::{Channel, Endpoint}; -use crate::common::{DEFAULT_CONTROLLER_PORT, DEFAULT_CONTROLLER_TLS_PORT}; -use crate::exception::ExceptionHandler; -use crate::utils::stats::{self, AtomicTimeStats, StatsOption}; +use crate::{ + common::{DEFAULT_CONTROLLER_PORT, DEFAULT_CONTROLLER_TLS_PORT}, + exception::ExceptionHandler, + trident::AgentId, + utils::stats::{self, AtomicTimeStats, StatsOption}, +}; use public::proto::trident::{self, Exception, Status}; use public::{ counter::{Countable, Counter, CounterType, CounterValue, RefCountable}, @@ -443,13 +446,12 @@ impl Session { &self, name: &str, plugin_type: PluginType, - ctrl_ip: &str, - ctrl_mac: &str, + agent_id: &AgentId, ) -> Result> { let s = self .plugin(trident::PluginRequest { - ctrl_ip: Some(ctrl_ip.into()), - ctrl_mac: Some(ctrl_mac.into()), + ctrl_ip: Some(agent_id.ip.to_string()), + ctrl_mac: Some(agent_id.mac.to_string()), plugin_type: Some(plugin_type as i32), plugin_name: Some(name.into()), }) diff --git a/agent/src/trident.rs b/agent/src/trident.rs index 9105abe683c..661a034d633 100644 --- a/agent/src/trident.rs +++ b/agent/src/trident.rs @@ -704,12 +704,8 @@ impl Trident { api_watcher.stop(); } - config_handler.load_plugin( - &runtime, - &session, - ctrl_ip.to_string().as_str(), - ctrl_mac.to_string().as_str(), - ); + let agent_id = synchronizer.agent_id.read().clone(); + config_handler.load_plugin(&runtime, &session, &agent_id); let mut comp = Components::new( &version_info,