mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
xdp: fix race found by gotsan
PiperOrigin-RevId: 592983574
This commit is contained in:
committed by
gVisor bot
parent
2846aacb51
commit
149350e5c4
@@ -289,14 +289,13 @@ func (ep *endpoint) WritePackets(pkts stack.PacketBufferList) (int, tcpip.Error)
|
||||
}
|
||||
|
||||
// Allocate UMEM space. In order to release the UMEM lock as soon as
|
||||
// possible, we allocate up-front and copy data in after releasing.
|
||||
// possible we allocate up-front.
|
||||
for _, pkt := range pkts.AsSlice() {
|
||||
batch = append(batch, unix.XDPDesc{
|
||||
Addr: ep.control.UMEM.AllocFrame(),
|
||||
Len: uint32(pkt.Size()),
|
||||
})
|
||||
}
|
||||
ep.control.UMEM.Unlock()
|
||||
|
||||
for i, pkt := range pkts.AsSlice() {
|
||||
// Copy packets into UMEM frame.
|
||||
@@ -311,6 +310,10 @@ func (ep *endpoint) WritePackets(pkts stack.PacketBufferList) (int, tcpip.Error)
|
||||
// Notify the kernel that there're packets to write.
|
||||
ep.control.TX.Notify()
|
||||
|
||||
// TODO(b/240191988): Explore more fine-grained locking. We shouldn't
|
||||
// need to hold the UMEM lock for the whole duration of packet copying.
|
||||
ep.control.UMEM.Unlock()
|
||||
|
||||
return pkts.Len(), nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user