From 78a035f0eadb837392f5aff34b6644d1d04a51cb Mon Sep 17 00:00:00 2001 From: Gartox Date: Mon, 4 Sep 2023 12:22:55 +0200 Subject: [PATCH] Fix TCP accept and accept packet from null mac address --- src/smolnetd/link/ethernet.rs | 7 ++++++- src/smolnetd/scheme/tcp.rs | 5 +---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/smolnetd/link/ethernet.rs b/src/smolnetd/link/ethernet.rs index 69732fa935..b008c01434 100644 --- a/src/smolnetd/link/ethernet.rs +++ b/src/smolnetd/link/ethernet.rs @@ -31,6 +31,8 @@ enum ArpState { type PacketBuffer = smoltcp::storage::PacketBuffer<'static, IpAddress>; +const EMPTY_MAC: EthernetAddress = EthernetAddress([0;6]); + pub struct EthernetLink { name: Rc, neighbor_cache: BTreeMap, @@ -333,11 +335,14 @@ impl LinkDevice for EthernetLink { continue; }; - if !repr.dst_addr.is_broadcast() && repr.dst_addr != self.hardware_address { + // We let EMPTY_MAC pass because somehow this is the mac used when net=redir is used + if !repr.dst_addr.is_broadcast() && repr.dst_addr != EMPTY_MAC && repr.dst_addr != self.hardware_address { // Drop packets which are not for us continue; } + error!("Incomming packet {}, {}", repr.dst_addr, repr.ethertype); + match repr.ethertype { EthernetProtocol::Ipv4 => { self.input_buffer = input_buffer; diff --git a/src/smolnetd/scheme/tcp.rs b/src/smolnetd/scheme/tcp.rs index 5f9f9a3c26..9d3dbb0425 100644 --- a/src/smolnetd/scheme/tcp.rs +++ b/src/smolnetd/scheme/tcp.rs @@ -226,10 +226,7 @@ impl<'a> SchemeSocket for TcpSocket<'a> { { let tcp_socket = socket_set.get_mut::(new_socket_handle); tcp_socket - .listen( - local_endpoint - .expect("Socket was active so local endpoint must be set"), - ) + .listen(listen_enpoint) .expect("Can't listen on local endpoint"); } // We got a new connection to the socket so acquire the port