From 356dd12e7fa3f886e023e426bbd196af5f133740 Mon Sep 17 00:00:00 2001 From: Thomas Eizinger Date: Sun, 28 Jul 2024 07:05:37 +0100 Subject: [PATCH] chore(connlib): remove duplicate `Device::poll_read` function (#6072) The `Device` implementation is no longer platform-specific so we can delete the duplicated `poll_read` function. --- rust/connlib/tunnel/src/device_channel.rs | 35 ----------------------- 1 file changed, 35 deletions(-) diff --git a/rust/connlib/tunnel/src/device_channel.rs b/rust/connlib/tunnel/src/device_channel.rs index 9a96ae99f..911e7a119 100644 --- a/rust/connlib/tunnel/src/device_channel.rs +++ b/rust/connlib/tunnel/src/device_channel.rs @@ -26,41 +26,6 @@ impl Device { } } - #[cfg(target_family = "unix")] - pub(crate) fn poll_read<'b>( - &mut self, - buf: &'b mut [u8], - cx: &mut Context<'_>, - ) -> Poll>> { - use ip_packet::Packet as _; - - let Some(tun) = self.tun.as_mut() else { - self.waker = Some(cx.waker().clone()); - return Poll::Pending; - }; - - let n = std::task::ready!(tun.poll_read(&mut buf[20..], cx))?; - - if n == 0 { - return Poll::Ready(Err(io::Error::new( - io::ErrorKind::UnexpectedEof, - "device is closed", - ))); - } - - let packet = MutableIpPacket::new(&mut buf[..(n + 20)]).ok_or_else(|| { - io::Error::new( - io::ErrorKind::InvalidInput, - "received bytes are not an IP packet", - ) - })?; - - tracing::trace!(target: "wire::dev::recv", dst = %packet.destination(), src = %packet.source(), bytes = %packet.packet().len()); - - Poll::Ready(Ok(packet)) - } - - #[cfg(target_family = "windows")] pub(crate) fn poll_read<'b>( &mut self, buf: &'b mut [u8],