Browse Source

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>
Brad Fitzpatrick 2 months ago
parent
commit
40c3530006
1 changed files with 3 additions and 0 deletions
  1. 3
    0
      tun/tun_linux.go

+ 3
- 0
tun/tun_linux.go View File

@@ -392,6 +392,9 @@ func (tun *NativeTun) Close() error {
392 392
 func CreateTUN(name string, mtu int) (Device, error) {
393 393
 	nfd, err := unix.Open(cloneDevicePath, os.O_RDWR, 0)
394 394
 	if err != nil {
395
+		if os.IsNotExist(err) {
396
+			return nil, fmt.Errorf("CreateTUN(%q) failed; tuntap %s does not exist", name, cloneDevicePath)
397
+		}
395 398
 		return nil, err
396 399
 	}
397 400
 

Loading…
Cancel
Save