Commit Graph

1 Commits

Author SHA1 Message Date
Roflin 29ce281a7f scripts: add a minimal raw-socket DHCP server for BBA bring-up
sudo ./scripts/mini-dhcpd.py enp0s31f6

Serves one address, logs every exchange, and does not touch the rest of the
system.  Needed because the Swiss DHCP timeout proves nothing while there is no
server on the segment to answer.

Deliberately AF_PACKET rather than a UDP socket on port 67.  A UDP socket only
sees frames the kernel accepts as well-formed IP/UDP, and one of the open
questions is whether the GC's frames arrive INTACT: libogc streams TX payload
with EXI_Dma and the GC's DMA-write engine is documented to have a 1-bit-shift
bug.  A corrupted DISCOVER would never reach a UDP socket and the server would
look "fine, just no client".  On a raw socket every frame from the adapter is
parsed by hand and anything that fails is reported as MALFORMED with the reason
and a hexdump -- which is exactly the evidence that would confirm or kill the
corruption hypothesis.

Replies go out as raw ethernet UNICAST to the client's MAC, so a successful
lease also demonstrates the new MACRAW MF filter accepts unicast to SHAR and
not just broadcast.

Self-tested without a network: a well-formed DISCOVER parses with the right
chaddr/xid, a corrupted magic cookie is reported as malformed rather than
ignored, frames from other MACs are skipped, and the generated OFFER is a valid
342-byte frame -- unicast to the client, correct IP checksum and total length,
ports 67->68, BOOTP padded to the 300-byte minimum, yiaddr as configured.
On-wire behaviour is NOT tested here; the devcontainer has only a veth.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-10-10 15:02:34 +02:00