diff --git a/pkg/tcpip/link/veth/veth.go b/pkg/tcpip/link/veth/veth.go index 2e382d344..8f96ebd4a 100644 --- a/pkg/tcpip/link/veth/veth.go +++ b/pkg/tcpip/link/veth/veth.go @@ -197,6 +197,13 @@ func (e *Endpoint) SetLinkAddress(addr tcpip.LinkAddress) { // WritePackets stores outbound packets into the channel. // Multiple concurrent calls are permitted. func (e *Endpoint) WritePackets(pkts stack.PacketBufferList) (int, tcpip.Error) { + e.veth.mu.RLock() + defer e.veth.mu.RUnlock() + + if e.veth.closed { + return 0, nil + } + n := 0 for _, pkt := range pkts.AsSlice() { // In order to properly loop back to the inbound side we must create a