From 3d00db10badc1b7996b4316d2ad7f85c47bd1011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Fri, 17 Oct 2025 10:31:41 +0200 Subject: [PATCH 1/2] style: improve DHCP + static IP warning Co-authored-by: Panagiotis "Ivory" Vasilopoulos --- src/executor/device.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/executor/device.rs b/src/executor/device.rs index fbe32872fc..2935713528 100644 --- a/src/executor/device.rs +++ b/src/executor/device.rs @@ -58,10 +58,9 @@ impl<'a> NetworkInterface<'a> { #[cfg(feature = "trace")] let mut device = Tracer::new(device, |timestamp, printer| trace!("{timestamp} {printer}")); - if hermit_var!("HERMIT_IP").is_some() { - warn!( - "A static IP address is specified with the environment variable HERMIT_IP, but the device is configured to use DHCPv4!" - ); + if let Some(hermit_ip) = hermit_var!("HERMIT_IP") { + warn!("HERMIT_IP was set to {hermit_ip}, but Hermit was built with DHCPv4."); + warn!("Ignoring HERMIT_IP."); } let ethernet_addr = EthernetAddress([mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]]); From 886ea5f05e68082b2dd9fa116e27bfc56770ef97 Mon Sep 17 00:00:00 2001 From: "Panagiotis \"Ivory\" Vasilopoulos" Date: Fri, 17 Oct 2025 10:35:19 +0200 Subject: [PATCH 2/2] style: align DHCP and non-DHCP log messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Martin Kröning --- src/executor/device.rs | 8 ++++---- src/executor/network.rs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/executor/device.rs b/src/executor/device.rs index 2935713528..2873ed0b08 100644 --- a/src/executor/device.rs +++ b/src/executor/device.rs @@ -66,7 +66,7 @@ impl<'a> NetworkInterface<'a> { let ethernet_addr = EthernetAddress([mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]]); let hardware_addr = HardwareAddress::Ethernet(ethernet_addr); - info!("MAC address {hardware_addr}"); + info!("MAC address: {hardware_addr}"); let capabilities = device.capabilities(); info!("{:?}", capabilities.checksum); info!("MTU: {} bytes", capabilities.max_transmission_unit); @@ -131,12 +131,12 @@ impl<'a> NetworkInterface<'a> { let hardware_addr = HardwareAddress::Ethernet(ethernet_addr); let ip_addr = IpCidr::from(Ipv4Cidr::from_netmask(myip, mymask).unwrap()); - info!("MAC address {hardware_addr}"); - info!("Configure network interface with address {ip_addr}"); - info!("Configure gateway with address {mygw}"); + info!("MAC address: {hardware_addr}"); let capabilities = device.capabilities(); info!("{:?}", capabilities.checksum); info!("MTU: {} bytes", capabilities.max_transmission_unit); + info!("IP address: {ip_addr}"); + info!("Gateway: {mygw}"); // use the current time based on the wall-clock time as seed let mut config = Config::new(hardware_addr); diff --git a/src/executor/network.rs b/src/executor/network.rs index 0b07ed6e1f..881d7bbb82 100644 --- a/src/executor/network.rs +++ b/src/executor/network.rs @@ -130,7 +130,7 @@ async fn dhcpv4_run() { None => {} Some(dhcpv4::Event::Configured(config)) => { info!("DHCP config acquired!"); - info!("IP address: {}", config.address); + info!("IP address: {}", config.address); nic.iface.update_ip_addrs(|addrs| { if let Some(dest) = addrs.iter_mut().next() { *dest = IpCidr::Ipv4(config.address); @@ -139,20 +139,20 @@ async fn dhcpv4_run() { } }); if let Some(router) = config.router { - info!("Default gateway: {router}"); + info!("Gateway: {router}"); nic.iface .routes_mut() .add_default_ipv4_route(router) .unwrap(); } else { - info!("Default gateway: None"); + info!("Gateway: None"); nic.iface.routes_mut().remove_default_ipv4_route(); } #[cfg(feature = "dns")] let mut dns_servers: Vec = Vec::new(); for (i, s) in config.dns_servers.iter().enumerate() { - info!("DNS server {i}: {s}"); + info!("DNS server {i}: {s}"); #[cfg(feature = "dns")] dns_servers.push(IpAddress::Ipv4(*s)); }