ipacm: fix the err_type override issue

Without ipacm-diag debug component, all
the debug prints will have NOFILE err_type
and overrides the kernel error codes. The fix
is to cache it onve we got error from
kernel.

Bug: 109872530
Change-Id: I222f0eceaff1c2f8e5d5c71556a3a1df0c053eaa
diff --git a/ipacm/src/IPACM_OffloadManager.cpp b/ipacm/src/IPACM_OffloadManager.cpp
index b8c3cf5..81bf4e3 100644
--- a/ipacm/src/IPACM_OffloadManager.cpp
+++ b/ipacm/src/IPACM_OffloadManager.cpp
@@ -576,7 +576,7 @@
 RET IPACM_OffloadManager::setQuota(const char * upstream_name /* upstream */, uint64_t mb/* limit */)
 {
 	wan_ioctl_set_data_quota quota;
-	int fd = -1,rc = 0;
+	int fd = -1, rc = 0, err_type = 0;
 
 	if ((fd = open(DEVICE_NAME, O_RDWR)) < 0)
 	{
@@ -600,9 +600,10 @@
 
 	if(rc != 0)
 	{
+		err_type = errno;
 		close(fd);
-        	IPACMERR("IOCTL WAN_IOCTL_SET_DATA_QUOTA call failed: %s rc: %d\n", strerror(errno),rc);
-		if (errno == ENODEV) {
+		IPACMERR("IOCTL WAN_IOCTL_SET_DATA_QUOTA call failed: %s err_type: %d\n", strerror(err_type), err_type);
+		if (err_type == ENODEV) {
 			IPACMDBG_H("Invalid argument.\n");
 			return FAIL_UNSUPPORTED;
 		}