From 84f1146368c821fb760d7c497663a332e8dee9f8 Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Fri, 19 Jul 2024 16:01:00 -0700 Subject: [PATCH] bridge: DeliverNetworkPacket has to take the read lock It doesn't change bridge attributes. PiperOrigin-RevId: 654152787 --- pkg/tcpip/stack/bridge.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/tcpip/stack/bridge.go b/pkg/tcpip/stack/bridge.go index 9fe9e91387..72cd5913f0 100644 --- a/pkg/tcpip/stack/bridge.go +++ b/pkg/tcpip/stack/bridge.go @@ -36,7 +36,7 @@ func (p *bridgePort) ParseHeader(pkt *PacketBuffer) bool { // DeliverNetworkPacket implements stack.NetworkDispatcher. func (p *bridgePort) DeliverNetworkPacket(protocol tcpip.NetworkProtocolNumber, pkt *PacketBuffer) { bridge := p.bridge - bridge.mu.Lock() + bridge.mu.RLock() // Send the packet to all other ports. for _, port := range bridge.ports { @@ -52,7 +52,7 @@ func (p *bridgePort) DeliverNetworkPacket(protocol tcpip.NetworkProtocolNumber, } d := bridge.dispatcher - bridge.mu.Unlock() + bridge.mu.RUnlock() if d != nil { // The dispatcher may acquire Stack.mu in DeliverNetworkPacket(), which is // ordered above bridge.mu. So call DeliverNetworkPacket() without holding