summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-09-06 22:06:58 +0200
committerTom Gundersen <teg@jklm.no>2014-09-08 15:07:51 +0200
commit6f44acfb48d4b58565d4c14714d082997389afd3 (patch)
tree3de9bf28a7763ea06156e3a3be5ac45bc5678945
parente44da745d19b9e02e67e32ea82c3bad86175120c (diff)
networkd: tuntap - return correct error when /dev/net/tun cannot be opened
-rw-r--r--src/network/networkd-netdev-tuntap.c10
1 files 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) {