From: Cheoleun Moon Date: Tue, 19 May 2020 12:03:51 +0000 (+0900) Subject: Print errno when socket and ioctl fail X-Git-Tag: submit/tizen/20200602.082342~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F40%2F235040%2F1;p=platform%2Fcore%2Fconnectivity%2Fnet-config.git Print errno when socket and ioctl fail Change-Id: I29f6264dd8db405405494f360c9543a33d342bb9 Signed-off-by: Cheoleun Moon --- diff --git a/src/utils/util.c b/src/utils/util.c index f113032..26beb05 100755 --- a/src/utils/util.c +++ b/src/utils/util.c @@ -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; }