Skip to content

Commit d17e546

Browse files
authored
Merge pull request #1990 from hermit-os/ip-logs
style: improve IP logs
2 parents 15ee5a2 + 886ea5f commit d17e546

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

src/executor/device.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,15 @@ impl<'a> NetworkInterface<'a> {
5858
#[cfg(feature = "trace")]
5959
let mut device = Tracer::new(device, |timestamp, printer| trace!("{timestamp} {printer}"));
6060

61-
if hermit_var!("HERMIT_IP").is_some() {
62-
warn!(
63-
"A static IP address is specified with the environment variable HERMIT_IP, but the device is configured to use DHCPv4!"
64-
);
61+
if let Some(hermit_ip) = hermit_var!("HERMIT_IP") {
62+
warn!("HERMIT_IP was set to {hermit_ip}, but Hermit was built with DHCPv4.");
63+
warn!("Ignoring HERMIT_IP.");
6564
}
6665

6766
let ethernet_addr = EthernetAddress([mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]]);
6867
let hardware_addr = HardwareAddress::Ethernet(ethernet_addr);
6968

70-
info!("MAC address {hardware_addr}");
69+
info!("MAC address: {hardware_addr}");
7170
let capabilities = device.capabilities();
7271
info!("{:?}", capabilities.checksum);
7372
info!("MTU: {} bytes", capabilities.max_transmission_unit);
@@ -132,12 +131,12 @@ impl<'a> NetworkInterface<'a> {
132131
let hardware_addr = HardwareAddress::Ethernet(ethernet_addr);
133132
let ip_addr = IpCidr::from(Ipv4Cidr::from_netmask(myip, mymask).unwrap());
134133

135-
info!("MAC address {hardware_addr}");
136-
info!("Configure network interface with address {ip_addr}");
137-
info!("Configure gateway with address {mygw}");
134+
info!("MAC address: {hardware_addr}");
138135
let capabilities = device.capabilities();
139136
info!("{:?}", capabilities.checksum);
140137
info!("MTU: {} bytes", capabilities.max_transmission_unit);
138+
info!("IP address: {ip_addr}");
139+
info!("Gateway: {mygw}");
141140

142141
// use the current time based on the wall-clock time as seed
143142
let mut config = Config::new(hardware_addr);

src/executor/network.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ async fn dhcpv4_run() {
130130
None => {}
131131
Some(dhcpv4::Event::Configured(config)) => {
132132
info!("DHCP config acquired!");
133-
info!("IP address: {}", config.address);
133+
info!("IP address: {}", config.address);
134134
nic.iface.update_ip_addrs(|addrs| {
135135
if let Some(dest) = addrs.iter_mut().next() {
136136
*dest = IpCidr::Ipv4(config.address);
@@ -139,20 +139,20 @@ async fn dhcpv4_run() {
139139
}
140140
});
141141
if let Some(router) = config.router {
142-
info!("Default gateway: {router}");
142+
info!("Gateway: {router}");
143143
nic.iface
144144
.routes_mut()
145145
.add_default_ipv4_route(router)
146146
.unwrap();
147147
} else {
148-
info!("Default gateway: None");
148+
info!("Gateway: None");
149149
nic.iface.routes_mut().remove_default_ipv4_route();
150150
}
151151

152152
#[cfg(feature = "dns")]
153153
let mut dns_servers: Vec<IpAddress> = Vec::new();
154154
for (i, s) in config.dns_servers.iter().enumerate() {
155-
info!("DNS server {i}: {s}");
155+
info!("DNS server {i}: {s}");
156156
#[cfg(feature = "dns")]
157157
dns_servers.push(IpAddress::Ipv4(*s));
158158
}

0 commit comments

Comments
 (0)