]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
conn: windows: compare head and tail properly
authorJason A. Donenfeld <Jason@zx2c4.com>
Fri, 9 Apr 2021 00:17:59 +0000 (18:17 -0600)
committerJason A. Donenfeld <Jason@zx2c4.com>
Fri, 9 Apr 2021 20:26:08 +0000 (14:26 -0600)
By not comparing these with the modulo, the ring became nearly never
full, resulting in completion queue buffers filling up prematurely.

Reported-by: Joshua Sjoding <joshua.sjoding@scjalliance.com>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
conn/bind_windows.go

index 6cabee19c7d12485f2261bed710df26c0c13cde2..a25c7aa2710ac04ad7dacf4215082cc709a1c7b5 100644 (file)
@@ -47,7 +47,7 @@ func (rb *ringBuffer) Push() *ringPacket {
        }
        ret := (*ringPacket)(unsafe.Pointer(rb.packets + (uintptr(rb.tail%packetsPerRing) * unsafe.Sizeof(ringPacket{}))))
        rb.tail += 1
-       if rb.tail == rb.head {
+       if rb.tail%packetsPerRing == rb.head%packetsPerRing {
                rb.isFull = true
        }
        return ret