fix(gateway): reject LAN interfaces without carrier

A gateway with the selected Ethernet cable unplugged can still open an
AF_PACKET socket and join the relay room. That makes clients see a connected LAN
gateway even though DHCP and LAN discovery cannot make the physical round trip.

Check the selected Linux interface's sysfs carrier file before creating the raw
socket. If sysfs reports carrier 0, fail before the gateway joins the relay.
Missing or unrecognized carrier files remain allowed so this does not reject
interfaces where the kernel cannot expose link state in that form. README and
TESTING now document the preflight and the operator fix.

Test Plan:
All cargo commands used these environment variables:
RUSTUP_HOME=/tmp/softlan-vpn-rustup
CARGO_HOME=/tmp/softlan-vpn-cargo

- cargo test -p lanparty-gateway \
  packet::tests::detects_disconnected_interfaces_from_sysfs_carrier
- cargo test -p lanparty-gateway
- cargo fmt --check
- cargo test --workspace
- cargo clippy --workspace --all-targets -- -D warnings
- git diff --check

Refs: PLAN.md wired Ethernet gateway requirement
This commit is contained in:
2026-05-22 04:48:12 +02:00
parent ac03bf1616
commit 217469edf0
3 changed files with 75 additions and 7 deletions
+6 -1
View File
@@ -72,7 +72,8 @@ sudo ./target/release/lanparty-gateway \
--iface eth0
```
Use the real wired LAN interface name for `--iface`. Do not use Wi-Fi.
Use the real wired LAN interface name for `--iface`. Do not use Wi-Fi. The
gateway fails before joining the relay if sysfs reports no Ethernet carrier.
Expected gateway output:
@@ -219,6 +220,10 @@ drop_reason=ControlPlaneEtherType
If the client says `Waiting for LAN gateway`, check that the gateway uses the
same room code and is connected to the same relay.
If the gateway fails with `reports no carrier`, plug the selected Ethernet
interface into the LAN party switch, bring the interface up, and restart the
gateway.
If startup fails before the relay connection while preparing the TAP adapter,
check that the terminal is elevated, TAP-Windows6 is installed, and
`--tap-instance-id` selects the intended adapter when more than one TAP adapter