chiark / gitweb /
networkd: tuntap - return correct error when /dev/net/tun cannot be opened
authorTom Gundersen <teg@jklm.no>
Sat, 6 Sep 2014 20:06:58 +0000 (22:06 +0200)
committerTom Gundersen <teg@jklm.no>
Mon, 8 Sep 2014 13:07:51 +0000 (15:07 +0200)
src/network/networkd-netdev-tuntap.c

index eef8747..eaf5df4 100644 (file)
@@ -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) {