diff --git a/aya/src/bpf.rs b/aya/src/bpf.rs index bb43c529..f3a9409d 100644 --- a/aya/src/bpf.rs +++ b/aya/src/bpf.rs @@ -435,7 +435,7 @@ impl<'a> EbpfLoader<'a> { } } - warn!("Object BTF couldn't be loaded in the kernel: {err}"); + warn!("object BTF couldn't be loaded in the kernel: {err}"); None } diff --git a/aya/src/maps/info.rs b/aya/src/maps/info.rs index 5c2dac9b..6a4bba13 100644 --- a/aya/src/maps/info.rs +++ b/aya/src/maps/info.rs @@ -143,7 +143,7 @@ impl MapInfo { /// for m in loaded_maps() { /// match m { /// Ok(map) => println!("{:?}", map.name_as_str()), -/// Err(e) => println!("Error iterating maps: {:?}", e), +/// Err(e) => println!("error iterating maps: {:?}", e), /// } /// } /// ``` diff --git a/aya/src/maps/ring_buf.rs b/aya/src/maps/ring_buf.rs index 85d3c8a8..c93a7118 100644 --- a/aya/src/maps/ring_buf.rs +++ b/aya/src/maps/ring_buf.rs @@ -73,7 +73,7 @@ use crate::{ /// let mut guard = poll.readable(); /// let ring_buf = guard.inner_mut(); /// while let Some(item) = ring_buf.next() { -/// println!("Received: {:?}", item); +/// println!("received: {:?}", item); /// } /// guard.clear_ready(); /// } diff --git a/aya/src/programs/info.rs b/aya/src/programs/info.rs index ef6b5378..7755d870 100644 --- a/aya/src/programs/info.rs +++ b/aya/src/programs/info.rs @@ -270,7 +270,7 @@ pub(crate) use impl_info; /// for p in loaded_programs() { /// match p { /// Ok(program) => println!("{}", String::from_utf8_lossy(program.name())), -/// Err(e) => println!("Error iterating programs: {:?}", e), +/// Err(e) => println!("error iterating programs: {:?}", e), /// } /// } /// ``` diff --git a/aya/src/programs/mod.rs b/aya/src/programs/mod.rs index fa1e41ec..06a82d69 100644 --- a/aya/src/programs/mod.rs +++ b/aya/src/programs/mod.rs @@ -1209,7 +1209,7 @@ impl_info!( /// /// for info in loaded_links() { /// if let Ok(info) = info { -/// println!("Loaded link: {}", info.id()); +/// println!("loaded link: {}", info.id()); /// } /// } /// ``` diff --git a/aya/src/sys/feature_probe.rs b/aya/src/sys/feature_probe.rs index 770590d0..230976f0 100644 --- a/aya/src/sys/feature_probe.rs +++ b/aya/src/sys/feature_probe.rs @@ -28,7 +28,7 @@ use crate::{ /// match is_program_supported(ProgramType::Xdp) { /// Ok(true) => println!("XDP supported :)"), /// Ok(false) => println!("XDP not supported :("), -/// Err(err) => println!("Uh oh! Unexpected error while probing: {:?}", err), +/// Err(err) => println!("unexpected error while probing: {:?}", err), /// } /// ``` /// @@ -169,7 +169,7 @@ pub fn is_program_supported(program_type: ProgramType) -> Result println!("hash_of_maps supported :)"), /// Ok(false) => println!("hash_of_maps not supported :("), -/// Err(err) => println!("Uh oh! Unexpected error while probing: {:?}", err), +/// Err(err) => println!("unexpected error while probing: {:?}", err), /// } /// ``` /// diff --git a/test/integration-test/src/tests/rbpf.rs b/test/integration-test/src/tests/rbpf.rs index 4c19fde6..faa7a034 100644 --- a/test/integration-test/src/tests/rbpf.rs +++ b/test/integration-test/src/tests/rbpf.rs @@ -67,7 +67,7 @@ fn use_map_with_rbpf() { "map_1" => 0, "map_2" => 1, "map_pin_by_name" => 2, - n => panic!("Unexpected map: {n}"), + n => panic!("unexpected map: {n}"), }; let fd = map_id as i32 | 0xCAFE00; diff --git a/test/integration-test/src/utils.rs b/test/integration-test/src/utils.rs index 1a8cc02b..bd1504d6 100644 --- a/test/integration-test/src/utils.rs +++ b/test/integration-test/src/utils.rs @@ -24,50 +24,50 @@ impl NetNsGuard { let pid = process::id(); let name = format!("aya-test-{pid}-{}", COUNTER.fetch_add(1, Ordering::Relaxed)); - // Create and enter netns - let ns = NetNs::new(&name).unwrap_or_else(|e| panic!("Failed to create netns {name}: {e}")); - let netns = Self { + let ns = NetNs::new(&name).unwrap_or_else(|e| panic!("failed to create netns {name}: {e}")); + + ns.enter() + .unwrap_or_else(|e| panic!("failed to enter network namespace {name}: {e}")); + println!("entered network namespace {name}"); + + let ns = Self { old_ns, ns: Some(ns), name, }; - let ns = netns.ns.as_ref().unwrap(); - ns.enter() - .unwrap_or_else(|e| panic!("Failed to enter network namespace {}: {e}", netns.name)); - println!("Entered network namespace {}", netns.name); - // By default, the loopback in a new netns is down. Set it up. let lo = CString::new("lo").unwrap(); unsafe { let idx = if_nametoindex(lo.as_ptr()); if idx == 0 { panic!( - "Interface `lo` not found in netns {}: {}", - netns.name, + "interface `lo` not found in netns {}: {}", + ns.name, io::Error::last_os_error() ); } netlink_set_link_up(idx as i32) - .unwrap_or_else(|e| panic!("Failed to set `lo` up in netns {}: {e}", netns.name)); + .unwrap_or_else(|e| panic!("failed to set `lo` up in netns {}: {e}", ns.name)); } - netns + ns } } impl Drop for NetNsGuard { fn drop(&mut self) { - // Avoid panic in panic - if let Err(e) = self.old_ns.enter() { - eprintln!("Failed to return to original netns: {e}"); + let Self { old_ns, ns, name } = self; + // Avoid panic in panic. + if let Err(e) = old_ns.enter() { + eprintln!("failed to return to original netns: {e}"); } - if let Some(ns) = self.ns.take() { + if let Some(ns) = ns.take() { if let Err(e) = ns.remove() { - eprintln!("Failed to remove netns {}: {e}", self.name); + eprintln!("failed to remove netns {name}: {e}"); } } - println!("Exited network namespace {}", self.name); + println!("exited network namespace {name}"); } }