*: downcase log strings

reviewable/pr1357/r15
Tamir Duberstein 2 weeks ago
parent 742f700dcc
commit 75edc3d294
No known key found for this signature in database

@ -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 None
} }

@ -143,7 +143,7 @@ impl MapInfo {
/// for m in loaded_maps() { /// for m in loaded_maps() {
/// match m { /// match m {
/// Ok(map) => println!("{:?}", map.name_as_str()), /// Ok(map) => println!("{:?}", map.name_as_str()),
/// Err(e) => println!("Error iterating maps: {:?}", e), /// Err(e) => println!("error iterating maps: {:?}", e),
/// } /// }
/// } /// }
/// ``` /// ```

@ -73,7 +73,7 @@ use crate::{
/// let mut guard = poll.readable(); /// let mut guard = poll.readable();
/// let ring_buf = guard.inner_mut(); /// let ring_buf = guard.inner_mut();
/// while let Some(item) = ring_buf.next() { /// while let Some(item) = ring_buf.next() {
/// println!("Received: {:?}", item); /// println!("received: {:?}", item);
/// } /// }
/// guard.clear_ready(); /// guard.clear_ready();
/// } /// }

@ -270,7 +270,7 @@ pub(crate) use impl_info;
/// for p in loaded_programs() { /// for p in loaded_programs() {
/// match p { /// match p {
/// Ok(program) => println!("{}", String::from_utf8_lossy(program.name())), /// Ok(program) => println!("{}", String::from_utf8_lossy(program.name())),
/// Err(e) => println!("Error iterating programs: {:?}", e), /// Err(e) => println!("error iterating programs: {:?}", e),
/// } /// }
/// } /// }
/// ``` /// ```

@ -1209,7 +1209,7 @@ impl_info!(
/// ///
/// for info in loaded_links() { /// for info in loaded_links() {
/// if let Ok(info) = info { /// if let Ok(info) = info {
/// println!("Loaded link: {}", info.id()); /// println!("loaded link: {}", info.id());
/// } /// }
/// } /// }
/// ``` /// ```

@ -28,7 +28,7 @@ use crate::{
/// match is_program_supported(ProgramType::Xdp) { /// match is_program_supported(ProgramType::Xdp) {
/// Ok(true) => println!("XDP supported :)"), /// Ok(true) => println!("XDP supported :)"),
/// Ok(false) => println!("XDP not 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<bool, ProgramEr
/// match is_map_supported(MapType::HashOfMaps) { /// match is_map_supported(MapType::HashOfMaps) {
/// Ok(true) => println!("hash_of_maps supported :)"), /// Ok(true) => println!("hash_of_maps supported :)"),
/// Ok(false) => println!("hash_of_maps not 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),
/// } /// }
/// ``` /// ```
/// ///

@ -67,7 +67,7 @@ fn use_map_with_rbpf() {
"map_1" => 0, "map_1" => 0,
"map_2" => 1, "map_2" => 1,
"map_pin_by_name" => 2, "map_pin_by_name" => 2,
n => panic!("Unexpected map: {n}"), n => panic!("unexpected map: {n}"),
}; };
let fd = map_id as i32 | 0xCAFE00; let fd = map_id as i32 | 0xCAFE00;

@ -24,50 +24,50 @@ impl NetNsGuard {
let pid = process::id(); let pid = process::id();
let name = format!("aya-test-{pid}-{}", COUNTER.fetch_add(1, Ordering::Relaxed)); 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 ns = NetNs::new(&name).unwrap_or_else(|e| panic!("Failed to create netns {name}: {e}"));
let netns = Self { ns.enter()
.unwrap_or_else(|e| panic!("failed to enter network namespace {name}: {e}"));
println!("entered network namespace {name}");
let ns = Self {
old_ns, old_ns,
ns: Some(ns), ns: Some(ns),
name, 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. // By default, the loopback in a new netns is down. Set it up.
let lo = CString::new("lo").unwrap(); let lo = CString::new("lo").unwrap();
unsafe { unsafe {
let idx = if_nametoindex(lo.as_ptr()); let idx = if_nametoindex(lo.as_ptr());
if idx == 0 { if idx == 0 {
panic!( panic!(
"Interface `lo` not found in netns {}: {}", "interface `lo` not found in netns {}: {}",
netns.name, ns.name,
io::Error::last_os_error() io::Error::last_os_error()
); );
} }
netlink_set_link_up(idx as i32) 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 { impl Drop for NetNsGuard {
fn drop(&mut self) { fn drop(&mut self) {
// Avoid panic in panic let Self { old_ns, ns, name } = self;
if let Err(e) = self.old_ns.enter() { // Avoid panic in panic.
eprintln!("Failed to return to original netns: {e}"); 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() { 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}");
} }
} }

Loading…
Cancel
Save