[Feature][ZXW-241]merge P56U01 version

Only Configure: No
Affected branch: master
Affected module: unknow
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update: No

Change-Id: I7985538dde6951dd824c36149bf9a1e3ca23c734
diff --git a/ap/app/clatd/clatd.c b/ap/app/clatd/clatd.c
index a1552d2..a5cd0a9 100755
--- a/ap/app/clatd/clatd.c
+++ b/ap/app/clatd/clatd.c
@@ -403,7 +403,10 @@
       // If any other bit is set, assume it's due to an error (i.e. POLLERR).
       if (wait_fd[0].revents & ~POLLIN) {
         // ring_read doesn't clear the error indication on the socket.
-        recv(tunnel->read_fd6, NULL, 0, MSG_PEEK);
+        if(recv(tunnel->read_fd6, NULL, 0, MSG_PEEK) == -1)
+		{
+			logmsg_dbg(ANDROID_LOG_ERROR,"recv fd6 failed");
+        }
         logmsg(ANDROID_LOG_WARN, "event_loop: clearing error on read_fd6: %s",
                strerror(errno));
       }
diff --git a/ap/app/clatd/dns64.c b/ap/app/clatd/dns64.c
index 3a287cf..cd92134 100755
--- a/ap/app/clatd/dns64.c
+++ b/ap/app/clatd/dns64.c
@@ -67,7 +67,8 @@
   // that could be done with them at this time anyway).
 
   if (result->ai_family != AF_INET6) {
-    logmsg(ANDROID_LOG_WARN, "plat_prefix/unexpected address family: %d", result->ai_family);
+    logmsg(ANDROID_LOG_WARN, "plat_prefix/unexpected address family: %d", result->ai_family);	
+  	freeaddrinfo(result);
     return 0;
   }
   plat_addr = ((struct sockaddr_in6 *)result->ai_addr)->sin6_addr;
diff --git a/ap/app/clatd/ring.c b/ap/app/clatd/ring.c
index 5e99fd5..113c8ec 100755
--- a/ap/app/clatd/ring.c
+++ b/ap/app/clatd/ring.c
@@ -39,6 +39,7 @@
   int ver = TPACKET_V2;
   if (setsockopt(packetsock, SOL_PACKET, PACKET_VERSION, (void *) &ver, sizeof(ver))) {
     logmsg(ANDROID_LOG_FATAL, "setsockopt(PACKET_VERSION, %d) failed: %s", ver, strerror(errno));
+	close(packetsock);
     return -1;
   }
 
@@ -61,6 +62,7 @@
 
   if (setsockopt(packetsock, SOL_PACKET, PACKET_RX_RING, &req, sizeof(req)) < 0) {
     logmsg(ANDROID_LOG_FATAL, "PACKET_RX_RING failed: %s", strerror(errno));
+	close(packetsock);
     return -1;
   }
 
@@ -69,6 +71,7 @@
                     packetsock, 0);
   if (ring->base == MAP_FAILED) {
     logmsg(ANDROID_LOG_FATAL, "mmap %lu failed: %s", buflen, strerror(errno));
+	close(packetsock);
     return -1;
   }
 
diff --git a/ap/app/clatd/translate.c b/ap/app/clatd/translate.c
index 1541cea..905f69c 100755
--- a/ap/app/clatd/translate.c
+++ b/ap/app/clatd/translate.c
@@ -556,7 +556,10 @@
   msg.msg_iov = out,
   msg.msg_iovlen = iov_len,
   sin6.sin6_addr = ((struct ip6_hdr *) out[CLAT_POS_IPHDR].iov_base)->ip6_dst;
-  sendmsg(fd, &msg, 0);
+  if(sendmsg(fd, &msg, 0) == -1)
+  {
+  	logmsg_dbg(ANDROID_LOG_ERROR,"send_rawv6 failed");
+  } 
 }
 
 /* function: translate_packet