Only skip default-gateway assignment with Medium::Ip

This commit is contained in:
Ruben De Smet 2023-07-31 12:25:57 +02:00
parent 9f55228be0
commit bdd59b8988
No known key found for this signature in database
GPG key ID: 1AE26A210C14115B

View file

@ -583,9 +583,6 @@ impl SocketStack {
impl<D: Driver + 'static> Inner<D> {
#[cfg(feature = "proto-ipv4")]
fn apply_config_v4(&mut self, s: &mut SocketStack, config: StaticConfigV4) {
#[cfg(any(feature = "medium-ethernet", feature = "medium-ieee802154"))]
let medium = self.device.capabilities().medium;
debug!("Acquired IP configuration:");
debug!(" IP address: {}", config.address);
@ -600,8 +597,12 @@ impl<D: Driver + 'static> Inner<D> {
addrs.push(IpCidr::Ipv4(config.address)).unwrap();
});
#[cfg(feature = "medium-ethernet")]
if medium == Medium::Ethernet {
#[cfg(feature = "medium-ip")]
let skip_gateway = self.device.capabilities().medium != Medium::Ip;
#[cfg(not(feature = "medium-ip"))]
let skip_gateway = false;
if !skip_gateway {
if let Some(gateway) = config.gateway {
debug!(" Default gateway: {}", gateway);
s.iface.routes_mut().add_default_ipv4_route(gateway).unwrap();