summaryrefslogtreecommitdiffhomepage
path: root/tun/tun_linux.go
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@tailscale.com>2020-03-18 13:23:00 -0700
committerJason A. Donenfeld <Jason@zx2c4.com>2020-05-02 01:50:47 -0600
commit2fb0a712f0ca2f9a922cdc4f1f47b88c3ee70048 (patch)
treed78290c8787e3e12936a342ea384a0b6acf98c76 /tun/tun_linux.go
parentf2c6faad44fa70cdc8ef80385ca9826bbf0468d9 (diff)
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>
Diffstat (limited to 'tun/tun_linux.go')
-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..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
}