Print errno when socket and ioctl fail 34/233834/2 submit/tizen_5.5/20200520.021526 submit/tizen_5.5/20200521.101938
authorCheoleun Moon <chleun.moon@samsung.com>
Tue, 19 May 2020 12:03:51 +0000 (21:03 +0900)
committerCheoleun Moon <chleun.moon@samsung.com>
Wed, 20 May 2020 01:36:56 +0000 (10:36 +0900)
Change-Id: I29f6264dd8db405405494f360c9543a33d342bb9
Signed-off-by: Cheoleun Moon <chleun.moon@samsung.com>
src/utils/util.c

index ade257a9c670ee2f27e4b8fa26009c8c0285018e..6bdcf7bdfff6befbcff817889499b13988995752 100755 (executable)
@@ -366,19 +366,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;
        }
@@ -395,19 +399,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;
        }