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>
This commit is contained in:
parent
bd83f0ac99
commit
99e8b4ba60
2 changed files with 34 additions and 27 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue