fix: easytier drain unused host packets to prevent data-plane stalls (#3400)

Consume raw host/TUN packet egress for each running instance so the bounded EasyTier packet sink cannot backpressure the data plane. Stop receiving when the instance closes or the adapter is canceled, and document packet ownership.
This commit is contained in:
Chikage0o0 authored and GitHub committed 2026-11-05 21:41:32 +08:00
1 parent f1f640b12f
commit 9002a4fed3
1 file changed
+12
+12
View File
@@ -315,9 +315,21 @@ func (e *EasyTier) init() error {
return err
}
log.Infoln("[EasyTier](%s) instance %s running", e.Name(), instance.ID())
go e.drainHostPackets(instance)
return nil
}
// The outbound uses the core's netstack, not a host TUN device. Drain unused
// raw IP packets so the bounded host packet queue cannot stall the data plane.
// ReceivePacket unblocks when the instance closes or the adapter is canceled.
func (e *EasyTier) drainHostPackets(instance *corehost.Instance) {
for {
if _, err := instance.ReceivePacket(e.ctx); err != nil {
return
}
}
}
func (e *EasyTier) currentInstance() (*corehost.Instance, error) {
e.mu.Lock()
defer e.mu.Unlock()