mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Clear pending packet queue when nic is removed.
Updates #6910 PiperOrigin-RevId: 428925334
This commit is contained in:
committed by
gVisor bot
parent
1012b95b22
commit
0917380792
@@ -316,9 +316,13 @@ func (n *nic) remove() tcpip.Error {
|
||||
ep.Close()
|
||||
}
|
||||
|
||||
// drain and drop any packets pending link resolution.
|
||||
n.linkResQueue.cancel()
|
||||
|
||||
// Prevent packets from going down to the link before shutting the link down.
|
||||
n.qDisc.Close()
|
||||
n.NetworkLinkEndpoint.Attach(nil)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,20 @@ func (f *packetsPendingLinkResolution) init(nic *nic) {
|
||||
f.mu.packets = make(map[<-chan struct{}][]pendingPacket)
|
||||
}
|
||||
|
||||
// cancel drains all pending packet queues and release all packet
|
||||
// references.
|
||||
func (f *packetsPendingLinkResolution) cancel() {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
for ch, pendingPackets := range f.mu.packets {
|
||||
for _, p := range pendingPackets {
|
||||
p.pkt.DecRef()
|
||||
}
|
||||
delete(f.mu.packets, ch)
|
||||
}
|
||||
f.mu.cancelChans = nil
|
||||
}
|
||||
|
||||
// dequeue any pending packets associated with ch.
|
||||
//
|
||||
// If err is nil, packets will be written and sent to the given remote link
|
||||
|
||||
Reference in New Issue
Block a user