diff --git a/agent/crates/public/src/utils/net/windows.rs b/agent/crates/public/src/utils/net/windows.rs index ce9e1073fbb..be82f56e4f4 100644 --- a/agent/crates/public/src/utils/net/windows.rs +++ b/agent/crates/public/src/utils/net/windows.rs @@ -140,6 +140,7 @@ pub fn get_interface_by_index_from_win32(if_index: u32) -> Result { ); if result != 111 { + println!("{} {} GetAdaptersAddresses {}", file!(), line!(), result); return Err(Error::Windows(format!( "Get buffer len by GetAdaptersAddresses failed error code {}", result @@ -159,6 +160,7 @@ pub fn get_interface_by_index_from_win32(if_index: u32) -> Result { &mut buffer_len, ); if result != 0 { + println!("{} {} GetAdaptersAddresses {}", file!(), line!(), result); return Err(Error::Windows(format!( "Get adapter addresses by GetAdaptersAddresses failed error code {}", result @@ -170,6 +172,7 @@ pub fn get_interface_by_index_from_win32(if_index: u32) -> Result { while !current_adapter.is_null() { let mac_address = unsafe { let adapter_ref = &*current_adapter; + println!("{} {} adapter ifindex {}", file!(), line!(), adapter_ref.Anonymous1.Anonymous.IfIndex); if if_index != adapter_ref.Anonymous1.Anonymous.IfIndex { current_adapter = adapter_ref.Next; continue; @@ -326,6 +329,7 @@ pub fn route_get(dest_addr: IpAddr) -> Result { "failed to run GetBestInterfaceEx function with destination address={} because of win32 error code({}),\n{}", dest_addr, ret_code, WIN_ERROR_CODE_STR ); + println!("{} {} {}", file!(), line!(), err_msg); return Err(Error::Windows(err_msg)); } @@ -351,6 +355,7 @@ pub fn route_get(dest_addr: IpAddr) -> Result { "failed to run GetBestRoute2 function with destination address={} error: {}", dest_addr, err ); + println!("{} {} {}", file!(), line!(), err_msg); return Err(Error::Windows(err_msg)); } @@ -381,6 +386,7 @@ pub fn route_get(dest_addr: IpAddr) -> Result { (src_addr, gateway) } }; + println!("{} {} route_get({}) return {} {}", file!(), line!(), dest_addr, src_addr, best_if_index); Ok(Route { pref_src: Some(src_addr), diff --git a/agent/src/utils/environment.rs b/agent/src/utils/environment.rs index c4d4fb5dfaa..0c7ffbf4633 100644 --- a/agent/src/utils/environment.rs +++ b/agent/src/utils/environment.rs @@ -385,16 +385,22 @@ pub fn get_ctrl_ip_and_mac(dest: &IpAddr) -> Result<(IpAddr, MacAddr)> { "failed getting control ip and mac from {}, because: {:?}, wait 1 second", dest, tuple, ); + println!( + "failed getting control ip and mac from {}, because: {:?}, wait 1 second", + dest, tuple, + ); thread::sleep(Duration::from_secs(1)); continue; } let (ip, mac) = tuple.unwrap(); + println!("{} {} get_route_src_ip_and_mac return {} {}", file!(), line!(), ip, mac); let links = link_list(); if links.is_err() { warn!( "failed getting local interfaces, because: {:?}, wait 1 second", links ); + println!("{} {}", file!(), line!()); thread::sleep(Duration::from_secs(1)); continue; } @@ -403,7 +409,9 @@ pub fn get_ctrl_ip_and_mac(dest: &IpAddr) -> Result<(IpAddr, MacAddr)> { // interface of the default route. for link in links.unwrap().iter() { if link.mac_addr == mac { + println!("{} {} ", file!(), line!()); if !link.flags.contains(LinkFlags::UP) { + println!("{} {} {:?}", file!(), line!(), link); let dest = if dest.is_ipv4() { DNS_HOST_IPV4 } else { @@ -412,6 +420,7 @@ pub fn get_ctrl_ip_and_mac(dest: &IpAddr) -> Result<(IpAddr, MacAddr)> { let tuple = get_route_src_ip_and_mac(&dest); if tuple.is_err() { warn!("failed getting control ip and mac from {}, because: {:?}, wait 1 second", dest, tuple); + println!("failed getting control ip and mac from {}, because: {:?}, wait 1 second", dest, tuple); thread::sleep(Duration::from_secs(1)); // There are scenarios where multiple network cards use the same MAC address, so it is necessary to // continue checking the other network cards. @@ -419,6 +428,7 @@ pub fn get_ctrl_ip_and_mac(dest: &IpAddr) -> Result<(IpAddr, MacAddr)> { } return Ok(tuple.unwrap()); } + println!("{} {} ", file!(), line!()); break; } }