Skip to content

Commit

Permalink
bridge: DeliverNetworkPacket has to take the read lock
Browse files Browse the repository at this point in the history
It doesn't change bridge attributes.

PiperOrigin-RevId: 654152787
  • Loading branch information
avagin authored and gvisor-bot committed Jul 19, 2024
1 parent 4cd5972 commit 84f1146
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/tcpip/stack/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit 84f1146

Please sign in to comment.