Print errno when socket and ioctl fail 40/235040/1
authorCheoleun Moon <chleun.moon@samsung.com>
Tue, 19 May 2020 12:03:51 +0000 (21:03 +0900)
committerCheoleun Moon <chleun.moon@samsung.com>
Tue, 2 Jun 2020 02:14:47 +0000 (11:14 +0900)
Change-Id: I29f6264dd8db405405494f360c9543a33d342bb9
Signed-off-by: Cheoleun Moon <chleun.moon@samsung.com>
src/utils/util.c

index f113032..26beb05 100755 (executable)
@@ -370,19 +370,23 @@ gboolean netconfig_interface_up(const char *ifname)
        struct ifreq ifr;
 
        fd = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
-       if (fd < 0)
+       if (fd < 0) {
+               ERR("socket failed %d", errno);
                return FALSE;
+       }
 
        memset(&ifr, 0, sizeof(ifr));
        g_strlcpy((char *)ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
 
        if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
+               ERR("Fail to get IFFLAGS %d", errno);
                close(fd);
                return FALSE;
        }
 
        ifr.ifr_flags |= (IFF_UP | IFF_DYNAMIC);
        if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) {
+               ERR("Fail to set IFFLAGS %d", errno);
                close(fd);
                return FALSE;
        }
@@ -399,19 +403,23 @@ gboolean netconfig_interface_down(const char *ifname)
        struct ifreq ifr;
 
        fd = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
-       if (fd < 0)
+       if (fd < 0) {
+               ERR("socket failed %d", errno);
                return FALSE;
+       }
 
        memset(&ifr, 0, sizeof(ifr));
        g_strlcpy((char *)ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
 
        if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
+               ERR("Fail to get IFFLAGS %d", errno);
                close(fd);
                return FALSE;
        }
 
        ifr.ifr_flags = (ifr.ifr_flags & ~IFF_UP) | IFF_DYNAMIC;
        if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) {
+               ERR("Fail to set IFFLAGS %d", errno);
                close(fd);
                return FALSE;
        }