aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@tailscale.com>2020-03-18 13:23:00 -0700
committerDavid Crawshaw <david@zentus.com>2020-04-02 15:17:05 +1100
commit40c3530006f24794ab80f100818a28ac93645d6c (patch)
tree42b7284e588241d08798469415b94d8fb792431f
parent825dfdbe2406283d23e93c84358def1684edba64 (diff)
downloadwireguard-go-40c3530006f24794ab80f100818a28ac93645d6c.tar.gz
wireguard-go-40c3530006f24794ab80f100818a28ac93645d6c.zip
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 <bradfitz@tailscale.com>
-rw-r--r--tun/tun_linux.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/tun/tun_linux.go b/tun/tun_linux.go
index 1e44b59..cc90c45 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; tuntap %s does not exist", name, cloneDevicePath)
+ }
return nil, err
}