1
0
forked from wrenn/wrenn

Cap network slot allocator at 32767 to match veth IP space

The veth addressing uses 10.12.0.0/16 with 2 IPs per slot. At slot
index 32768, vethOffset=65536 overflows byte arithmetic and wraps back
to 10.12.0.0, causing silent IP collisions with existing sandboxes.
Cap the allocator at 32767, which is the actual addressable limit.
This commit is contained in:
2026-04-16 14:57:44 +06:00
parent 451d0819cc
commit 44c32587e3

View File

@ -24,7 +24,7 @@ func (a *SlotAllocator) Allocate() (int, error) {
a.mu.Lock() a.mu.Lock()
defer a.mu.Unlock() defer a.mu.Unlock()
for i := 1; i <= 65534; i++ { for i := 1; i <= 32767; i++ {
if !a.inUse[i] { if !a.inUse[i] {
a.inUse[i] = true a.inUse[i] = true
return i, nil return i, nil