diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-07-18 15:48:34 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-07-18 15:48:34 +0200 |
commit | 1e39c33ab1abd8cd10c912ef8df48c7e1a4b1590 (patch) | |
tree | a4f90311533ff342fe041cc3b7d28cd69f0fe3f7 /tun/tun_windows.go | |
parent | 6c50fedd8eecc6cb06d8da47514794eb211d5b3a (diff) |
tun: windows: silently drop packet when ring is full
Diffstat (limited to 'tun/tun_windows.go')
-rw-r--r-- | tun/tun_windows.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tun/tun_windows.go b/tun/tun_windows.go index 21bc382..86995a7 100644 --- a/tun/tun_windows.go +++ b/tun/tun_windows.go @@ -22,7 +22,7 @@ import ( const ( packetAlignment uint32 = 4 // Number of bytes packets are aligned to in rings packetSizeMax uint32 = 0xffff // Maximum packet size - packetCapacity uint32 = 0x100000 // Ring capacity (defaults to 1MiB, must be a power of 2) + packetCapacity uint32 = 0x800000 // Ring capacity, 8MiB packetTrailingSize uint32 = uint32(unsafe.Sizeof(packetHeader{})) + ((packetSizeMax + (packetAlignment - 1)) &^ (packetAlignment - 1)) - packetAlignment ioctlRegisterRings uint32 = (0x22 /*FILE_DEVICE_UNKNOWN*/ << 16) | (0x800 << 2) | 0 /*METHOD_BUFFERED*/ | (0x3 /*FILE_READ_DATA | FILE_WRITE_DATA*/ << 14) @@ -381,7 +381,7 @@ func (tun *NativeTun) Write(buff []byte, offset int) (int, error) { buffSpace := tun.rings.receive.ring.wrap(buffHead - buffTail - packetAlignment) if alignedPacketSize > buffSpace { - return 0, errors.New("receive ring full") + return 0, nil // Dropping when ring is full. } packet := (*packet)(unsafe.Pointer(&tun.rings.receive.ring.data[buffTail])) |