diff --git a/README.md b/README.md index 504ab56..7cf6cb1 100644 --- a/README.md +++ b/README.md @@ -167,9 +167,11 @@ cargo run -p lanparty-gateway -- \ The gateway connects to the relay as `role = gateway`, completes the control-stream hello/welcome handshake, opens an AF_PACKET socket on the LAN interface with promiscuous packet membership, and bridges Ethernet frames -between the relay and wired LAN until shutdown. It never fragments Ethernet -frames; LAN frames whose encoded datagrams exceed the negotiated QUIC budget are -counted, dropped, and logged instead of stopping the bridge. +between the relay and wired LAN until shutdown. It captures whole LAN frames up +to the overlay payload-length ceiling before deciding whether they fit the +tunnel. It never fragments Ethernet frames; LAN frames whose encoded datagrams +exceed the negotiated QUIC budget are counted, dropped, and logged instead of +stopping the bridge. `--relay` accepts a DNS name or socket address; bare hosts default to UDP/443. It tracks remote-client source MACs seen from relay traffic and periodically emits small CAM refresh frames so the physical switch keeps those MACs diff --git a/crates/lanparty-gateway/src/lib.rs b/crates/lanparty-gateway/src/lib.rs index 17d9896..74acd19 100644 --- a/crates/lanparty-gateway/src/lib.rs +++ b/crates/lanparty-gateway/src/lib.rs @@ -32,8 +32,7 @@ use lanparty_obs::{DropReason, TunnelStats}; #[cfg(target_os = "linux")] use lanparty_obs::{FrameAction, FrameDirection, FrameLog}; use lanparty_proto::{ - EthernetFrame, FrameType, MAX_STANDARD_ETHERNET_FRAME_LEN, MacAddr, decode_datagram, - encode_datagram, validate_datagram_budget, + EthernetFrame, FrameType, MacAddr, decode_datagram, encode_datagram, validate_datagram_budget, }; use quinn::{ClientConfig, Endpoint, crypto::rustls::QuicClientConfig}; use rustls::pki_types::CertificateDer; @@ -56,6 +55,13 @@ const CAM_REFRESH_ETHERTYPE: u16 = 0x88b5; const CAM_REFRESH_PAYLOAD: &[u8] = b"lanparty-cam-refresh"; #[cfg(target_os = "linux")] const MIN_ETHERNET_FRAME_WITHOUT_FCS: usize = 60; +#[cfg(target_os = "linux")] +const LAN_CAPTURE_BUFFER_LEN: usize = u16::MAX as usize; +#[cfg(target_os = "linux")] +const _: () = assert!( + LAN_CAPTURE_BUFFER_LEN + > lanparty_proto::MAX_STANDARD_ETHERNET_FRAME_LEN + lanparty_proto::ETHERNET_HEADER_LEN +); #[derive(Debug, Parser)] #[command( @@ -658,7 +664,7 @@ fn gateway_frame_log_line( #[cfg(target_os = "linux")] async fn read_lan_ethernet(packet_socket: &AsyncFd) -> Result { loop { - let mut buffer = vec![0; MAX_STANDARD_ETHERNET_FRAME_LEN]; + let mut buffer = vec![0; LAN_CAPTURE_BUFFER_LEN]; let mut guard = packet_socket .readable() .await