Blob Blame History Raw
From 6f44acfb48d4b58565d4c14714d082997389afd3 Mon Sep 17 00:00:00 2001
From: Tom Gundersen <teg@jklm.no>
Date: Sat, 6 Sep 2014 22:06:58 +0200
Subject: [PATCH] networkd: tuntap - return correct error when /dev/net/tun
 cannot be opened

---
 src/network/networkd-netdev-tuntap.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/network/networkd-netdev-tuntap.c b/src/network/networkd-netdev-tuntap.c
index eef8747210..eaf5df4971 100644
--- a/src/network/networkd-netdev-tuntap.c
+++ b/src/network/networkd-netdev-tuntap.c
@@ -63,17 +63,15 @@ static int netdev_tuntap_add(NetDev *netdev, struct ifreq *ifr) {
         const char *group;
         uid_t uid;
         gid_t gid;
-        int r = 0;
+        int r;
 
         assert(netdev);
         assert(ifr);
 
         fd = open(TUN_DEV, O_RDWR);
         if (fd < 0) {
-                log_error_netdev(netdev,
-                                 "Failed to open tun dev: %s",
-                                 strerror(-r));
-                return r;
+                log_error_netdev(netdev, "Failed to open tun dev: %m");
+                return -errno;
         }
 
         r = ioctl(fd, TUNSETIFF, ifr);
@@ -139,7 +137,7 @@ static int netdev_tuntap_add(NetDev *netdev, struct ifreq *ifr) {
                 return r;
         }
 
-        return r;
+        return 0;
 }
 
 static int netdev_create_tuntap(NetDev *netdev) {