Merge 45f180de4ee0030f629c0eb784c897f197ed5338 on remote branch

Change-Id: Ia1f0eae318c06cfea9e3d95341992ecb5534598f
diff --git a/ipacm/src/IPACM_Config.cpp b/ipacm/src/IPACM_Config.cpp
index 41b920d..2af4e1d 100644
--- a/ipacm/src/IPACM_Config.cpp
+++ b/ipacm/src/IPACM_Config.cpp
@@ -535,7 +535,7 @@
 		}
 	}
 
-	IPACMDBG_H("Add iface %s to NAT-ifaces, origin it has %d nat ifaces\n",
+	IPACMDBG_H_LOG("Add iface %s to NAT-ifaces, origin it has %d nat ifaces\n",
 					          dev_name, ipa_nat_iface_entries);
 	ipa_nat_iface_entries++;
 
diff --git a/ipacm/src/IPACM_Filtering.cpp b/ipacm/src/IPACM_Filtering.cpp
index 3e79149..78d673b 100644
--- a/ipacm/src/IPACM_Filtering.cpp
+++ b/ipacm/src/IPACM_Filtering.cpp
@@ -566,12 +566,12 @@
 	if(rule_table_v4 != NULL)
 	{
 		num_rules += rule_table_v4->num_rules;
-		IPACMDBG_H("Get %d WAN DL IPv4 filtering rules.\n", rule_table_v4->num_rules);
+		IPACMDBG_H_LOG("Get %d WAN DL IPv4 filtering rules.\n", rule_table_v4->num_rules);
 	}
 	if(rule_table_v6 != NULL)
 	{
 		num_rules += rule_table_v6->num_rules;
-		IPACMDBG_H("Get %d WAN DL IPv6 filtering rules.\n", rule_table_v6->num_rules);
+		IPACMDBG_H_LOG("Get %d WAN DL IPv6 filtering rules.\n", rule_table_v6->num_rules);
 	}
 
 	/* if it is not IPA v3, use old QMI format */
@@ -597,7 +597,7 @@
 			qmi_rule_msg.filter_spec_list_len = num_rules;
 			qmi_rule_msg.source_pipe_index_valid = 0;
 
-			IPACMDBG_H("Get %d WAN DL filtering rules in total.\n", num_rules);
+			IPACMDBG_H_LOG("Get %d WAN DL filtering rules in total.\n", num_rules);
 
 			if(rule_table_v4 != NULL)
 			{
@@ -682,7 +682,7 @@
 			qmi_rule_ex_msg.filter_spec_ex_list_len = num_rules;
 			qmi_rule_ex_msg.source_pipe_index_valid = 0;
 
-			IPACMDBG_H("Get %d WAN DL filtering rules in total.\n", num_rules);
+			IPACMDBG_H_LOG("Get %d WAN DL filtering rules in total.\n", num_rules);
 
 			if(rule_table_v4 != NULL)
 			{
@@ -706,7 +706,7 @@
 					}
 					else
 					{
-						IPACMERR(" QMI only support max %d rules, current (%d)\n ",QMI_IPA_MAX_FILTERS_EX_V01, pos);
+						IPACMERR_LOG(" QMI only support max %d rules, current (%d)\n ",QMI_IPA_MAX_FILTERS_EX_V01, pos);
 					}
 				}
 			}
@@ -733,7 +733,7 @@
 					}
 					else
 					{
-						IPACMERR(" QMI only support max %d rules, current (%d)\n ",QMI_IPA_MAX_FILTERS_EX_V01, pos);
+						IPACMERR_LOG(" QMI only support max %d rules, current (%d)\n ",QMI_IPA_MAX_FILTERS_EX_V01, pos);
 					}
 				}
 			}
diff --git a/ipacm/src/IPACM_Iface.cpp b/ipacm/src/IPACM_Iface.cpp
index 55cf71d..e384d15 100644
--- a/ipacm/src/IPACM_Iface.cpp
+++ b/ipacm/src/IPACM_Iface.cpp
@@ -1056,7 +1056,7 @@
 	{
 		if ((ip_type == IPA_IP_v4) || (ip_type == IPA_IP_MAX))
 		{
-			IPACMDBG_H(" interface(%s:%d) already in ip-type %d\n", dev_name, ipa_if_num, ip_type);
+			IPACMDBG_H_LOG(" interface(%s:%d) already in ip-type %d\n", dev_name, ipa_if_num, ip_type);
 			return;
 		}
 
@@ -1068,7 +1068,7 @@
 		{
 			ip_type = IPA_IP_v4;
 		}
-		IPACMDBG_H(" interface(%s:%d) now ip-type is %d\n", dev_name, ipa_if_num, ip_type);
+		IPACMDBG_H_LOG(" interface(%s:%d) now ip-type is %d\n", dev_name, ipa_if_num, ip_type);
 	}
 	else
 	{
@@ -1087,7 +1087,7 @@
 			ip_type = IPA_IP_v6;
 		}
 
-		IPACMDBG_H(" interface(%s:%d) now ip-type is %d\n", dev_name, ipa_if_num, ip_type);
+		IPACMDBG_H_LOG(" interface(%s:%d) now ip-type is %d\n", dev_name, ipa_if_num, ip_type);
 	}
 
 	return;
@@ -1131,7 +1131,7 @@
 		IPACMERR("IPv6 address is empty.\n");
 		return false;
 	}
-	IPACMDBG_H("Get ipv6 address with first word 0x%08x.\n", ipv6_addr[0]);
+	IPACMDBG_H_LOG("Get ipv6 address with first word 0x%08x.\n", ipv6_addr[0]);
 
 	if((ipv6_addr[0] & ipv6_link_local_prefix_mask) == (ipv6_link_local_prefix & ipv6_link_local_prefix_mask))
 	{
diff --git a/ipacm/src/IPACM_Routing.cpp b/ipacm/src/IPACM_Routing.cpp
index 654a0f9..bade460 100644
--- a/ipacm/src/IPACM_Routing.cpp
+++ b/ipacm/src/IPACM_Routing.cpp
@@ -99,7 +99,7 @@
 	retval = ioctl(m_fd, IPA_IOC_ADD_RT_RULE, ruleTable);
 	if (retval)
 	{
-		IPACMERR("Failed adding routing rule %p\n", ruleTable);
+		IPACMERR_LOG("Failed adding routing rule %p\n", ruleTable);
 		return false;
 	}
 
@@ -108,7 +108,7 @@
 		IPACMDBG("Rule:%d  dst_pipe:%d\n", cnt, ruleTable->rules[cnt].rule.dst);
 	}
 
-	IPACMDBG_H("Added routing rule %p\n", ruleTable);
+	IPACMDBG_H_LOG("Added routing rule %p\n", ruleTable);
 	return true;
 }
 
@@ -340,7 +340,7 @@
 	rt_rule_entry->status = -1;
 	rt_rule_entry->hdl = rt_rule_hdl;
 
-	IPACMDBG_H("Deleting Route hdl:(0x%x) with ip type: %d\n", rt_rule_entry->hdl, ip);
+	IPACMDBG_H_LOG("Deleting Route hdl:(0x%x) with ip type: %d\n", rt_rule_entry->hdl, ip);
 	if ((false == DeleteRoutingRule(rt_rule)) ||
 			(rt_rule_entry->status))
 	{
diff --git a/ipacm/src/IPACM_Wan.cpp b/ipacm/src/IPACM_Wan.cpp
index 1d9d0bc..4316ba8 100644
--- a/ipacm/src/IPACM_Wan.cpp
+++ b/ipacm/src/IPACM_Wan.cpp
@@ -438,7 +438,7 @@
 		}
 			else if (rt_rule_entry->status)
 		{
-				IPACMERR("rt rule adding failed. Result=%d\n", rt_rule_entry->status);
+				IPACMERR_LOG("rt rule adding failed. Result=%d\n", rt_rule_entry->status);
 				res = rt_rule_entry->status;
 				goto fail;
 		}
@@ -477,7 +477,7 @@
 			}
 			else if (rt_rule_entry->status)
 			{
-				IPACMERR("rsc tcp rt rule adding failed. Result=%d\n", rt_rule_entry->status);
+				IPACMERR_LOG("rsc tcp rt rule adding failed. Result=%d\n", rt_rule_entry->status);
 				res = rt_rule_entry->status;
 				goto fail;
 		}
@@ -511,7 +511,7 @@
 		}
 		else if (rt_rule_entry->status)
 		{
-				IPACMERR("rsb udp rt rule adding failed. Result=%d\n", rt_rule_entry->status);
+				IPACMERR_LOG("rsb udp rt rule adding failed. Result=%d\n", rt_rule_entry->status);
 				res = rt_rule_entry->status;
 				goto fail;
 		}
@@ -555,7 +555,7 @@
 				}
 				else if (rt_rule_entry->status)
 				{
-						IPACMDBG_H("low lat udp rt rule adding failed. Result=%d\n", rt_rule_entry->status);
+						IPACMDBG_H_LOG("low lat udp rt rule adding failed. Result=%d\n", rt_rule_entry->status);
 						res = rt_rule_entry->status;
 						goto fail;
 					}
@@ -587,7 +587,7 @@
 			}
 			else if (rt_rule_entry->status)
 			{
-			IPACMERR("rt rule adding failed. Result=%d\n", rt_rule_entry->status);
+			IPACMERR_LOG("rt rule adding failed. Result=%d\n", rt_rule_entry->status);
 			res = rt_rule_entry->status;
 			goto fail;
 		}
@@ -603,7 +603,7 @@
 		}
 		else if (rt_rule_entry->status)
 		{
-			IPACMERR("rt rule adding failed. Result=%d\n", rt_rule_entry->status);
+			IPACMERR_LOG("rt rule adding failed. Result=%d\n", rt_rule_entry->status);
 			res = rt_rule_entry->status;
 			goto fail;
 		}
@@ -623,7 +623,7 @@
 			{
 				modem_ipv6_pdn_index = num_ipv6_modem_pdn;
 				num_ipv6_modem_pdn++;
-				IPACMDBG_H("Now the number of modem ipv6 pdn is %d.\n", num_ipv6_modem_pdn);
+				IPACMDBG_H_LOG("Now the number of modem ipv6 pdn is %d.\n", num_ipv6_modem_pdn);
 				init_fl_rule_ex(data->iptype);
 			}
 			else if(m_is_sta_mode == Q6_MHI_WAN)
@@ -702,7 +702,8 @@
 				{
 					IPACM_Iface::ipacmcfg->increaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v6, 1);
 					ipv6_dest_flt_rule_hdl[num_ipv6_dest_flt_rule] = flt_rule->rules[0].flt_rule_hdl;
-					IPACMDBG_H("IPv6 dest filter rule %d HDL:0x%x\n", num_ipv6_dest_flt_rule, ipv6_dest_flt_rule_hdl[num_ipv6_dest_flt_rule]);
+					IPACMDBG_H_LOG("IPv6 dest filter rule %d HDL:0x%x\n",
+						num_ipv6_dest_flt_rule, ipv6_dest_flt_rule_hdl[num_ipv6_dest_flt_rule]);
 					num_ipv6_dest_flt_rule++;
 					free(flt_rule);
 				}
@@ -711,7 +712,8 @@
 
 		if (sec_addr)
 		{
-	    	sec_num_dft_rt_v6++;
+			sec_num_dft_rt_v6++;
+			IPACMDBG_H_LOG("Secondary v6 num :%d\n", sec_num_dft_rt_v6);
 		}
 		else
 		{
@@ -722,6 +724,7 @@
 				dft_rt_v6_glbl_idx = num_dft_rt_v6;
 			}
 			num_dft_rt_v6++;
+			IPACMDBG_H_LOG("v6 num %d: \n",num_dft_rt_v6);
 		}
     }
 	else
@@ -736,14 +739,14 @@
 			}
 			else
 			{
-				IPACMDBG_H(" device (%s) ipv4 addr is changed\n", dev_name);
+				IPACMDBG_H_LOG(" device (%s) ipv4 addr is changed\n", dev_name);
 				if (m_is_sta_mode == Q6_WAN) {
 					sec_addr = true;
 				}
 				else
 				{
 					/* Delete default v4 RT rule */
-					IPACMDBG_H("Delete default v4 routing rules\n");
+					IPACMDBG_H_LOG("Delete default v4 routing rules\n");
 					if (m_routing.DeleteRoutingHdl(dft_rt_rule_hdl[0], IPA_IP_v4) == false)
 					{
 						IPACMERR("Routing old RT rule deletion failed!\n");
@@ -802,7 +805,7 @@
 			}
 			else if (rt_rule_entry->status)
 			{
-				IPACMERR("rt rule adding failed. Result=%d\n", rt_rule_entry->status);
+				IPACMERR_LOG("rt rule adding failed. Result=%d\n", rt_rule_entry->status);
 				res = rt_rule_entry->status;
 				goto fail;
 			}
@@ -835,7 +838,7 @@
 			}
 			else if (rt_rule_entry->status)
 			{
-				IPACMERR("rsc tcp rt rule adding failed. Result=%d\n", rt_rule_entry->status);
+				IPACMERR_LOG("rsc tcp rt rule adding failed. Result=%d\n", rt_rule_entry->status);
 				res = rt_rule_entry->status;
 				goto fail;
 			}
@@ -930,23 +933,20 @@
 		{
 			rt_rule_entry->rule.dst = IPA_CLIENT_APPS_LAN_CONS;
 			/* legacy default v4 rt-rule */
-			if (false == m_routing.AddRoutingRule(rt_rule))
-			{
+			if (false == m_routing.AddRoutingRule(rt_rule)) {
 				IPACMERR("Routing rule addition failed!\n");
 				res = IPACM_FAILURE;
 				goto fail;
+			} else if (rt_rule_entry->status) {
+				IPACMERR("rt rule adding failed. Result=%d\n", rt_rule_entry->status);
+				res = rt_rule_entry->status;
+				goto fail;
 			}
-			else if (rt_rule_entry->status)
-			{
-			IPACMERR("rt rule adding failed. Result=%d\n", rt_rule_entry->status);
-			res = rt_rule_entry->status;
-			goto fail;
-		}
-		dft_rt_rule_hdl[0] = rt_rule_entry->rt_rule_hdl;
-		IPACMDBG_H("ipv4 wan iface rt-rule hdll=0x%x\n", dft_rt_rule_hdl[0]);
+			dft_rt_rule_hdl[0] = rt_rule_entry->rt_rule_hdl;
+			IPACMDBG_H("ipv4 wan iface rt-rule hdll=0x%x\n", dft_rt_rule_hdl[0]);
 		}
 
-			/* initial multicast/broadcast/fragment filter rule */
+		/* initial multicast/broadcast/fragment filter rule */
 		/* only do one time */
 		if(!wan_v4_addr_set)
 		{
@@ -960,7 +960,7 @@
 			}
 			else if(m_is_sta_mode == Q6_MHI_WAN)
 			{
-				IPACMDBG_H(" Has rx/tx properties registered for iface %s, add for NATTING for ip-family %d \n", dev_name, IPA_IP_v4);
+				IPACMDBG_H_LOG(" Has rx/tx properties registered for iface %s, add for NATTING for ip-family %d \n", dev_name, IPA_IP_v4);
 				IPACM_Iface::ipacmcfg->AddNatIfaces(dev_name, IPA_IP_v4);
 			}
 			else
@@ -983,7 +983,7 @@
 			if (m_is_sta_mode == Q6_WAN && !sec_addr)
 			curr_wan_ip = data->ipv4_addr;
 
-			IPACMDBG_H("Receved wan ipv4-addr:0x%x, sec_addr:%d\n",data->ipv4_addr, sec_addr);
+			IPACMDBG_H_LOG("Received wan ipv4-addr:0x%x, sec_addr:%d\n",data->ipv4_addr, sec_addr);
 	}
 
 #ifdef FEATURE_IPACM_HAL
@@ -996,7 +996,7 @@
 		OffloadMng->search_framwork_cache(dev_name);
 	}
 #endif
-	IPACMDBG_H("number of default route rules %d\n", num_dft_rt_v6);
+	IPACMDBG_H_LOG("number of default route rules %d\n", num_dft_rt_v6);
 
 fail:
 	if (rt_rule != NULL)
@@ -1038,7 +1038,7 @@
 					(sec_ipv6_addr[num_ipv6_addr][2] == data->ipv6_addr[2]) &&
 					(sec_ipv6_addr[num_ipv6_addr][3] == data->ipv6_addr[3]))
 				{
-						IPACMDBG_H("find matched ipv6 address, index:%d \n", num_ipv6_addr);
+						IPACMDBG_H_LOG("find matched ipv6 address, index:%d \n", num_ipv6_addr);
 						sec_addr = true;
 				}
 			}
@@ -1050,7 +1050,7 @@
 					(ipv6_addr[num_ipv6_addr][2] == data->ipv6_addr[2]) &&
 					(ipv6_addr[num_ipv6_addr][3] == data->ipv6_addr[3]))
 				{
-					IPACMDBG_H("find matched ipv6 address, index:%d \n", num_ipv6_addr);
+					IPACMDBG_H_LOG("find matched ipv6 address, index:%d \n", num_ipv6_addr);
 					pri_addr = true;
 					rt_idx = num_ipv6_addr;
 				}
@@ -1090,6 +1090,7 @@
 				}
 				memset(sec_ipv6_addr, 0, sizeof(sec_ipv6_addr));
 				sec_num_dft_rt_v6 = 0;
+				IPACMDBG_H_LOG("Secondary v6 num :%d\n", sec_num_dft_rt_v6);
 				return IPACM_SUCCESS;
 			}
 
@@ -1155,12 +1156,12 @@
 					memcpy(ipv6_prefix, sec_ipv6_addr[sec_num_dft_rt_v6-1], sizeof(ipv6_prefix));
 					memset(sec_ipv6_addr[sec_num_dft_rt_v6-1], 0, sizeof(sec_ipv6_addr[sec_num_dft_rt_v6-1]));
 					sec_num_dft_rt_v6--;
-					IPACMDBG_H("Secondary v6 num %d: \n",sec_num_dft_rt_v6);
+					IPACMDBG_H_LOG("Secondary v6 num %d: \n",sec_num_dft_rt_v6);
 				}
 				else
 				{
 					num_dft_rt_v6--;
-					IPACMDBG_H("v6 num %d: \n",num_dft_rt_v6);
+					IPACMDBG_H_LOG("v6 num %d: \n",num_dft_rt_v6);
 				}
 			}
 		}
@@ -1318,6 +1319,7 @@
 			memcpy(ipv6_prefix, data->ipv6_addr, sizeof(ipv6_prefix));
 		}
 		num_dft_rt_v6++;
+		IPACMDBG_H_LOG("v6 num %d: \n",num_dft_rt_v6);
 		if (num_dft_rt_v6 == 1)
 		{
 			/* Add Natting iface to IPACM_Config if there is  Rx/Tx property */
@@ -6451,6 +6453,7 @@
 			}
 			memset(sec_ipv6_addr, 0, sizeof(sec_ipv6_addr));
 			sec_num_dft_rt_v6 = 0;
+			IPACMDBG_H_LOG("Secondary v6 num :%d\n", sec_num_dft_rt_v6);
 		}
 	}
 	else
@@ -6648,6 +6651,7 @@
 			}
 			memset(sec_ipv6_addr, 0, sizeof(sec_ipv6_addr));
 			sec_num_dft_rt_v6 = 0;
+			IPACMDBG_H_LOG("Secondary v6 num :%d\n", sec_num_dft_rt_v6);
 		}
 	}
 
@@ -6853,7 +6857,7 @@
 				len = sizeof(struct ipa_ioc_add_flt_rule) + IPACM_Wan::num_v4_flt_rule * sizeof(struct ipa_flt_rule_add);
 				pFilteringTable_v4 = (struct ipa_ioc_add_flt_rule*)malloc(len);
 
-				IPACMDBG_H("Total number of WAN DL filtering rule for IPv4 is %d\n", IPACM_Wan::num_v4_flt_rule);
+				IPACMDBG_H_LOG("Total number of WAN DL filtering rule for IPv4 is %d\n", IPACM_Wan::num_v4_flt_rule);
 
 				if (pFilteringTable_v4 == NULL)
 				{
@@ -6875,7 +6879,7 @@
 				len = sizeof(struct ipa_ioc_add_flt_rule) + IPACM_Wan::num_v6_flt_rule * sizeof(struct ipa_flt_rule_add);
 				pFilteringTable_v6 = (struct ipa_ioc_add_flt_rule*)malloc(len);
 
-				IPACMDBG_H("Total number of WAN DL filtering rule for IPv6 is %d\n", IPACM_Wan::num_v6_flt_rule);
+				IPACMDBG_H_LOG("Total number of WAN DL filtering rule for IPv6 is %d\n", IPACM_Wan::num_v6_flt_rule);
 
 				if (pFilteringTable_v6 == NULL)
 				{
@@ -6914,7 +6918,7 @@
 			/* allocate ipv6 filtering table */
 			len = sizeof(struct ipa_ioc_add_flt_rule) + (1 + IPACM_Wan::num_v6_flt_rule) * sizeof(struct ipa_flt_rule_add);
 			pFilteringTable_v6 = (struct ipa_ioc_add_flt_rule*)malloc(len);
-			IPACMDBG_H("Total number of WAN DL filtering rule for IPv6 is %d\n", IPACM_Wan::num_v6_flt_rule + 1);
+			IPACMDBG_H_LOG("Total number of WAN DL filtering rule for IPv6 is %d\n", IPACM_Wan::num_v6_flt_rule + 1);
 			if (pFilteringTable_v6 == NULL)
 			{
 				IPACMERR("Error Locate ipa_flt_rule_add memory...\n");