From bdd59b89885bff676a73d990613c1b74955885b3 Mon Sep 17 00:00:00 2001 From: Ruben De Smet Date: Mon, 31 Jul 2023 12:25:57 +0200 Subject: [PATCH] Only skip default-gateway assignment with Medium::Ip --- embassy-net/src/lib.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/embassy-net/src/lib.rs b/embassy-net/src/lib.rs index 86a11e92..2fb34f43 100644 --- a/embassy-net/src/lib.rs +++ b/embassy-net/src/lib.rs @@ -583,9 +583,6 @@ impl SocketStack { impl Inner { #[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 Inner { 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();