Return from EthernetInterface::poll() on errors, don't swallow them.

We still print them into our debug log though, because it has more
context; the caller may opt to ignore any poll errors and only
use the smoltcp debug log as a, well, debugging aid, or it could
print user-visible warnings to alert the user to unusual network
conditions.
This commit is contained in:
whitequark 2017-08-30 10:20:11 +00:00
parent 7b3574e6ee
commit 5a066fbc6c
1 changed files with 6 additions and 4 deletions

View File

@ -142,7 +142,7 @@ impl<'a, 'b, 'c, DeviceT: Device + 'a> Interface<'a, 'b, 'c, DeviceT> {
Ok(response) => response,
Err(err) => {
net_debug!("cannot process ingress packet: {}", err);
continue
return Err(err)
}
};
processed_any = true;
@ -151,7 +151,7 @@ impl<'a, 'b, 'c, DeviceT: Device + 'a> Interface<'a, 'b, 'c, DeviceT> {
Ok(()) => (),
Err(err) => {
net_debug!("cannot dispatch response packet: {}", err);
continue
return Err(err)
}
}
}
@ -185,8 +185,10 @@ impl<'a, 'b, 'c, DeviceT: Device + 'a> Interface<'a, 'b, 'c, DeviceT> {
};
match (device_result, socket_result) {
(Ok(()), Err(Error::Exhausted)) => (), // nothing to transmit
(Err(err), _) | (_, Err(err)) =>
net_debug!("cannot dispatch egress packet: {}", err),
(Err(err), _) | (_, Err(err)) => {
net_debug!("cannot dispatch egress packet: {}", err);
return Err(err)
}
(Ok(()), Ok(())) => ()
}
}