Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LLT-5312] Add more logging when read from tun failure happens #1

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions device/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"encoding/binary"
"errors"
"net"
"os"
"sync"
"time"

Expand Down Expand Up @@ -310,9 +309,7 @@ func (device *Device) RoutineReadFromTUN() {
continue
}
if !device.isClosed() {
if !errors.Is(readErr, os.ErrClosed) {
device.log.Errorf("Failed to read packet from TUN device: %v", readErr)
}
device.log.Errorf("Failed to read packet from TUN device: %v", readErr)
go device.Close()
}
return
Expand Down
6 changes: 3 additions & 3 deletions tun/tun_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,13 @@ func (tun *NativeTun) Read(bufs [][]byte, sizes []int, offset int) (int, error)
defer tun.running.Done()
retry:
if tun.close.Load() {
return 0, os.ErrClosed
return 0, errors.New("Tunnel is being shutdown at the startup of reading of packets")
}
start := nanotime()
shouldSpin := tun.rate.current.Load() >= spinloopRateThreshold && uint64(start-tun.rate.nextStartTime.Load()) <= rateMeasurementGranularity*2
for {
if tun.close.Load() {
return 0, os.ErrClosed
return 0, errors.New("Tunnel is being shutdown while reading packets")
}
packet, err := tun.session.ReceivePacket()
switch err {
Expand All @@ -173,7 +173,7 @@ retry:
procyield(1)
continue
case windows.ERROR_HANDLE_EOF:
return 0, os.ErrClosed
return 0, errors.New("Driver indicated EOF while reading from tunnel")
case windows.ERROR_INVALID_DATA:
return 0, errors.New("Send ring corrupt")
}
Expand Down
Loading