Merge "IPACM: fix memory leak issue"
diff --git a/ipacm/src/IPACM_Wan.cpp b/ipacm/src/IPACM_Wan.cpp
index fec9088..86587bd 100644
--- a/ipacm/src/IPACM_Wan.cpp
+++ b/ipacm/src/IPACM_Wan.cpp
@@ -230,7 +230,14 @@
 			rt_rule_entry->rule.hdr_hdl = hdr.hdl;
 		}
 	    rt_rule_entry->at_rear = false;
-	    rt_rule_entry->rule.dst = iface_query->excp_pipe;  //go to A5
+		if(m_is_sta_mode == Q6_WAN)
+		{
+			rt_rule_entry->rule.dst = IPA_CLIENT_APPS_WAN_CONS;
+		}
+		else
+		{
+			rt_rule_entry->rule.dst = IPA_CLIENT_APPS_LAN_CONS;
+		}
 	    rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
 	    	rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = data->ipv6_addr[0];
 	    	rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = data->ipv6_addr[1];
@@ -383,9 +390,13 @@
 				return IPACM_FAILURE;
 			}
 			rt_rule_entry->rule.hdr_hdl = hdr.hdl;
+			rt_rule_entry->rule.dst = IPA_CLIENT_APPS_WAN_CONS;
+		}
+		else
+		{
+			rt_rule_entry->rule.dst = IPA_CLIENT_APPS_LAN_CONS;
 		}
 		rt_rule_entry->at_rear = false;
-		rt_rule_entry->rule.dst = iface_query->excp_pipe;  //go to A5
 		rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
 		/* still need setup v4 default routing rule to A5*/
 		strcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_lan_v4.name);
@@ -1190,7 +1201,14 @@
     strcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_wan_v6.name);
     memset(rt_rule_entry, 0, sizeof(struct ipa_rt_rule_add));
 	rt_rule_entry->at_rear = true;
-    rt_rule_entry->rule.dst = iface_query->excp_pipe;  //go to A5
+	if(m_is_sta_mode == Q6_WAN)
+	{
+		rt_rule_entry->rule.dst = IPA_CLIENT_APPS_WAN_CONS;
+	}
+	else
+	{
+		rt_rule_entry->rule.dst = IPA_CLIENT_APPS_LAN_CONS;
+	}
     rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR;
 	rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = 0;
 	rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = 0;
diff --git a/ipanat/src/ipa_nat_drvi.c b/ipanat/src/ipa_nat_drvi.c
index 74161a7..32114b5 100644
--- a/ipanat/src/ipa_nat_drvi.c
+++ b/ipanat/src/ipa_nat_drvi.c
@@ -665,6 +665,9 @@
 		return -EINVAL;
 	}
 
+	/* Reset the nat table before posting init cmd */
+	ipa_nati_reset_tbl(tbl_indx);
+
 	/* Initialize the ipa hw with nat table dimensions */
 	ret = ipa_nati_post_ipv4_init_cmd(tbl_indx);
 	if (0 != ret) {
@@ -672,8 +675,6 @@
 		return -EINVAL;
 	}
 
-	ipa_nati_reset_tbl(tbl_indx);
-
 	/* Return table handle */
 	ipv4_nat_cache.table_cnt++;
 	*tbl_hdl = ipv4_nat_cache.table_cnt;