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_5.5/20200520.021526^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a4b426ac277f4d8086a92e1ba291869fc528a08c;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 ade257a..6bdcf7b 100755 --- a/src/utils/util.c +++ b/src/utils/util.c @@ -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; }