From: Brad Fitzpatrick Date: Wed, 18 Mar 2020 20:23:00 +0000 (-0700) Subject: tun: return a better error message if /dev/net/tun doesn't exist X-Git-Tag: 0.0.20201118~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2fb0a712f0ca2f9a922cdc4f1f47b88c3ee70048;p=thirdparty%2Fwireguard-go.git tun: return a better error message if /dev/net/tun doesn't exist It was just returning "no such file or directory" (the String of the syscall.Errno returned by CreateTUN). Signed-off-by: Brad Fitzpatrick --- diff --git a/tun/tun_linux.go b/tun/tun_linux.go index 1e44b59..179635a 100644 --- a/tun/tun_linux.go +++ b/tun/tun_linux.go @@ -392,6 +392,9 @@ func (tun *NativeTun) Close() error { func CreateTUN(name string, mtu int) (Device, error) { nfd, err := unix.Open(cloneDevicePath, os.O_RDWR, 0) if err != nil { + if os.IsNotExist(err) { + return nil, fmt.Errorf("CreateTUN(%q) failed; %s does not exist", name, cloneDevicePath) + } return nil, err }