TUN: Skip ErrTooManySegments

This commit is contained in:
Neil Alexander 2024-10-10 09:23:13 +01:00
parent 874083da79
commit d22dc9ecc9
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944

View File

@ -1,5 +1,11 @@
package tun
import (
"errors"
wgtun "golang.zx2c4.com/wireguard/tun"
)
const TUN_OFFSET_BYTES = 80 // sizeof(virtio_net_hdr)
func (tun *TunAdapter) read() {
@ -12,6 +18,10 @@ func (tun *TunAdapter) read() {
for {
n, err := tun.iface.Read(bufs, sizes, TUN_OFFSET_BYTES)
if err != nil {
if errors.Is(err, wgtun.ErrTooManySegments) {
tun.log.Debugln("TUN segments dropped: %v", err)
continue
}
tun.log.Errorln("Error reading TUN:", err)
return
}