aboutsummaryrefslogtreecommitdiffstats
path: root/device
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-05-20 18:26:01 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2021-05-20 18:26:01 +0200
commit99e8b4ba605538b64c693c4056904f34810c3938 (patch)
tree87bc010144d676f7d74d838e3f475876ffa808fa /device
parentconn: linux: protect read fds (diff)
downloadwireguard-go-99e8b4ba605538b64c693c4056904f34810c3938.tar.xz
wireguard-go-99e8b4ba605538b64c693c4056904f34810c3938.zip
tun: linux: account for interface removal from outside
On Linux we can run `ip link del wg0`, in which case the fd becomes stale, and we should exit. Since this is an intentional action, don't treat it as an error. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'device')
-rw-r--r--device/send.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/device/send.go b/device/send.go
index e07df1b..a4f07e4 100644
--- a/device/send.go
+++ b/device/send.go
@@ -8,7 +8,9 @@ package device
import (
"bytes"
"encoding/binary"
+ "errors"
"net"
+ "os"
"sync"
"sync/atomic"
"time"
@@ -227,7 +229,9 @@ func (device *Device) RoutineReadFromTUN() {
if err != nil {
if !device.isClosed() {
- device.log.Errorf("Failed to read packet from TUN device: %v", err)
+ if !errors.Is(err, os.ErrClosed) {
+ device.log.Errorf("Failed to read packet from TUN device: %v", err)
+ }
go device.Close()
}
device.PutMessageBuffer(elem.buffer)