Skip to content

Commit c6c0e52

Browse files
nybidarigvisor-bot
authored andcommitted
Fix the link endpoint panic.
The panic was happening as the endpoint was trying to send packets with nil dispatcher. Do not send packets when dispatcher is nil. Before: http://sponge2/a609cccc-714a-4a83-b488-e52ea59618f9 After: http://sponge2/8cec0b14-7820-4937-8b28-2ecfaecfa773 PiperOrigin-RevId: 769833561
1 parent 54eb149 commit c6c0e52

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pkg/tcpip/link/pipe/pipe.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ type Endpoint struct {
5555
}
5656

5757
func (e *Endpoint) deliverPackets(pkts stack.PacketBufferList) {
58-
if !e.linked.IsAttached() {
58+
e.linked.mu.RLock()
59+
d := e.linked.dispatcher
60+
e.linked.mu.RUnlock()
61+
if d == nil {
5962
return
6063
}
6164

@@ -66,9 +69,6 @@ func (e *Endpoint) deliverPackets(pkts stack.PacketBufferList) {
6669
newPkt := stack.NewPacketBuffer(stack.PacketBufferOptions{
6770
Payload: pkt.ToBuffer(),
6871
})
69-
e.linked.mu.RLock()
70-
d := e.linked.dispatcher
71-
e.linked.mu.RUnlock()
7272
d.DeliverNetworkPacket(pkt.NetworkProtocolNumber, newPkt)
7373
newPkt.DecRef()
7474
}

0 commit comments

Comments
 (0)