Repository navigation
Forget the host neighbor entry of a reused guest address - #553
Merged
Merged
Conversation
Guest addresses are picked at random from the subnet and reused. The host kept the previous owner's neighbor entry, so the first connection to a new guest on that address was sent to a MAC nobody owned until the entry timed out, about ten seconds later. Delete the entry when the address is allocated.
sjmiller609
approved these changes
Nov 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The first connection from the host to a new guest could stall for about ten seconds when the guest was given an address that an earlier guest had used.
CreateAllocationnow deletes the host's neighbor entry for the address it hands out.Why it happened
Guest addresses are picked at random from the subnet and reused once released. The host's neighbor (ARP) entry for a released address stays behind and still points at the previous guest's MAC. Linux keeps using a stale entry while it re-verifies it, so the first packets to the new guest go to a MAC nobody owns. The entry is only dropped once the delay and probe timers have run out, about 8 s later, and a TCP connect then gets through on its next SYN retransmit.
A guest forked from a snapshot is the worst case, because it sends nothing until the host contacts it. A cold-booted guest usually repairs the entry itself when it first resolves the gateway. On a host with fewer than
gc_thresh1(128) neighbor entries the kernel never garbage-collects them, so a stale entry can sit there for hours.What changes
CreateAllocationremoves the bridge's neighbor entry for the address it has just reserved, before it creates the TAP. A missing entry is the normal case and is not an error. A failure is logged and does not fail the allocation. Restore from standby is unchanged: the guest keeps its address and MAC.Testing
CreateAllocationclears the one it hands out and leaves the rest. Each fails when the call or the delete is removed.The address a guest gets is random, so the host run could not force a reuse. The tests above are what cover the fixed path.
Note
Medium Risk
Changes the Linux network allocation hot path and kernel neighbor table, but neighbor delete failures are non-blocking and covered by integration tests.
Overview
CreateAllocation now drops the bridge’s stale neighbor (ARP) entry for a newly reserved guest IP before creating the TAP, so the host does not keep forwarding to the previous guest’s MAC when addresses are reused—avoiding multi-second stalls on first contact (especially snapshot forks).
On Linux, new
forgetNeighborusesnetlink.NeighDel(missing entry is ignored); failures are logged and do not fail allocation. On macOS it is a no-op. Restore-from-standby is unchanged.Adds root-required Linux tests that exercise
forgetNeighborand verifyCreateAllocationclears only the allocated address’s stale neighbor among candidates on a /29.Reviewed by Cursor Bugbot for commit 48f08f6. Bugbot is set up for automated code reviews on this repo. Configure here.