Skip to content

test(discover): repeat the flood's replies until discover is done - #27

Merged
boeboe merged 1 commit into
mainfrom
fix/hostile-discover-flaky
Nov 14, 2026
Merged

boeboe merged 1 commit into
mainfrom
fix/hostile-discover-flaky

Conversation

@boeboe

@boeboe boeboe commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Fixes #26 (TestHostileDiscoverFlood finds 0 devices).

Cause

  • The device sends 500 junk datagrams of up to 1400 bytes and then the replies of 40 devices, once each (×5 duplicates).
  • In kernel memory the junk is several times Linux's default UDP receive buffer (net.core.rmem_default, about 208 KiB).
  • When the command's reader runs late on a busy runner, the kernel drops everything after the junk, the replies included. discover then waited the full --wait 2s and found 0. The failed job ran on ubuntu-24.04 (Go 1.26, no race). The race jobs pass because instrumentation slows the sender down.
  • On macOS (768 KiB buffer) it doesn't reproduce: 100 runs pass idle and under load, with no "full socket buffers" drops.
  • A standalone probe with Linux's buffer size on loopback:
Reader late by Datagrams read (of 700) Replies read (of 200)
0 ms 700 200
10 ms 441 137
50 ms 304 0

Change

Test only. The devices repeat their replies every 20 ms (more duplicates) until the command returns. The flood, the --max-devices 10 limit, the 5 s duration bound and the duplicate-counting part of the test are unchanged.

The command itself can't avoid this: a UDP reply that the kernel drops never reaches it, and a larger SO_RCVBUF is capped by net.core.rmem_max on Linux. No release is needed, because the binary is unchanged.

Verification

  • The test passes 30× idle (about 0.3 s each) and 80× at 1 and 2 CPUs under CPU load.
  • make check passes locally (coverage 96.1%).

🤖 Generated with Claude Code

TestHostileDiscoverFlood sent 500 junk datagrams and then the replies of
40 devices once. The junk is several times Linux's default UDP receive
buffer (about 208 KiB): when the command's reader runs late on a busy
runner, the kernel drops everything after the junk, the replies
included, and discover found 0 of 10 (ethernetipctl#26, ubuntu-24.04,
Go 1.26 job). A probe with that buffer size and a reader 50 ms late read
304 junk datagrams and 0 of 200 replies. The devices now repeat their
replies every 20 ms until the command returns; the flood, the
--max-devices limit and the duration bound are unchanged.

Fixes #26

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@boeboe
boeboe merged commit b370d88 into main Nov 14, 2026
16 checks passed
@boeboe
boeboe deleted the fix/hostile-discover-flaky branch November 14, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test: cmd TestHostileDiscoverFlood finds 0 devices

1 participant