diff options
author | Susant Sahani <susant@redhat.com> | 2015-06-12 14:01:51 +0530 |
---|---|---|
committer | Susant Sahani <susant@redhat.com> | 2015-06-14 11:18:28 +0530 |
commit | ce67afb04320c5b94435dd171af68629b54bb7b5 (patch) | |
tree | 5ab0599c1829b492eb628e536539764e353cc90a /src/network | |
parent | 034e10d7fb8bd3d574bc4861f84cf4a86c343bf2 (diff) |
networkd: tuntap improve logging
Replaces strerror() usage with log_netdev_error_errno()
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/networkd-netdev-tuntap.c | 51 |
1 files changed, 14 insertions, 37 deletions
diff --git a/src/network/networkd-netdev-tuntap.c b/src/network/networkd-netdev-tuntap.c index 4e974927cb..378312f091 100644 --- a/src/network/networkd-netdev-tuntap.c +++ b/src/network/networkd-netdev-tuntap.c @@ -69,18 +69,12 @@ static int netdev_tuntap_add(NetDev *netdev, struct ifreq *ifr) { assert(ifr); fd = open(TUN_DEV, O_RDWR); - if (fd < 0) { - log_netdev_error(netdev, "Failed to open tun dev: %m"); - return -errno; - } + if (fd < 0) + return log_netdev_error_errno(netdev, -errno, "Failed to open tun dev: %m"); r = ioctl(fd, TUNSETIFF, ifr); - if (r < 0) { - log_netdev_error(netdev, - "TUNSETIFF failed on tun dev: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, -errno, "TUNSETIFF failed on tun dev: %m"); if (netdev->kind == NETDEV_KIND_TAP) t = TAP(netdev); @@ -94,18 +88,12 @@ static int netdev_tuntap_add(NetDev *netdev, struct ifreq *ifr) { user = t->user_name; r = get_user_creds(&user, &uid, NULL, NULL, NULL); - if (r < 0) { - log_error_errno(r, "Cannot resolve user name %s: %m", - t->user_name); - return 0; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Cannot resolve user name %s: %m", t->user_name); r = ioctl(fd, TUNSETOWNER, uid); - if ( r < 0) { - log_netdev_error(netdev, - "TUNSETOWNER failed on tun dev: %s", - strerror(-r)); - } + if (r < 0) + return log_netdev_error_errno(netdev, -errno, "TUNSETOWNER failed on tun dev: %m"); } if (t->group_name) { @@ -113,29 +101,18 @@ static int netdev_tuntap_add(NetDev *netdev, struct ifreq *ifr) { group = t->group_name; r = get_group_creds(&group, &gid); - if (r < 0) { - log_error_errno(r, "Cannot resolve group name %s: %m", - t->group_name); - return 0; - } + if (r < 0) + return log_netdev_error_errno(netdev, r, "Cannot resolve group name %s: %m", t->group_name); r = ioctl(fd, TUNSETGROUP, gid); - if( r < 0) { - log_netdev_error(netdev, - "TUNSETGROUP failed on tun dev: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, -errno, "TUNSETGROUP failed on tun dev: %m"); } r = ioctl(fd, TUNSETPERSIST, 1); - if (r < 0) { - log_netdev_error(netdev, - "TUNSETPERSIST failed on tun dev: %s", - strerror(-r)); - return r; - } + if (r < 0) + return log_netdev_error_errno(netdev, -errno, "TUNSETPERSIST failed on tun dev: %m"); return 0; } |