Skip to content

Commit

Permalink
TUN: Skip ErrTooManySegments
Browse files Browse the repository at this point in the history
  • Loading branch information
neilalexander committed Oct 10, 2024
1 parent 874083d commit d22dc9e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/tun/iface.go
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -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
}
Expand Down

1 comment on commit d22dc9e

@mittwerk
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice # @neilalexander Thanks

Please sign in to comment.