diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-02-09 19:48:27 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-02-09 19:50:31 +0100 |
commit | c040dea7985b7b5a35ca2fa746c3385732c44bd1 (patch) | |
tree | d9dc0633a65e854ffeea40d3bcf9f54ea8ec018a /tun/tun_openbsd.go | |
parent | 5cdb862f15fc4d0772ace2ca3fd0271233012185 (diff) |
tun: use errors.Is for unwrapping
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'tun/tun_openbsd.go')
-rw-r--r-- | tun/tun_openbsd.go | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/tun/tun_openbsd.go b/tun/tun_openbsd.go index ab4e99f..b2815d7 100644 --- a/tun/tun_openbsd.go +++ b/tun/tun_openbsd.go @@ -6,6 +6,7 @@ package tun import ( + "errors" "fmt" "io/ioutil" "net" @@ -99,16 +100,6 @@ func (tun *NativeTun) routineRouteListener(tunIfindex int) { } } -func errorIsEBUSY(err error) bool { - if pe, ok := err.(*os.PathError); ok { - err = pe.Err - } - if errno, ok := err.(syscall.Errno); ok && errno == syscall.EBUSY { - return true - } - return false -} - func CreateTUN(name string, mtu int) (Device, error) { ifIndex := -1 if name != "tun" { @@ -126,7 +117,7 @@ func CreateTUN(name string, mtu int) (Device, error) { } else { for ifIndex = 0; ifIndex < 256; ifIndex++ { tunfile, err = os.OpenFile(fmt.Sprintf("/dev/tun%d", ifIndex), unix.O_RDWR, 0) - if err == nil || !errorIsEBUSY(err) { + if err == nil || !errors.Is(err, syscall.EBUSY) { break } } |