IPACM: Add dummy nat rules only for modem backhaul

Don't add dummy nat rules for AP + STA mode.

Change-Id: I409e21df430e7c2878340a64483501931182da3c
Signed-off-by: Sunil Paidimarri <hisunil@codeaurora.org>
CRs-Fixed: 1031957
diff --git a/ipacm/src/IPACM_ConntrackListener.cpp b/ipacm/src/IPACM_ConntrackListener.cpp
index 33023cb..a5a838b 100644
--- a/ipacm/src/IPACM_ConntrackListener.cpp
+++ b/ipacm/src/IPACM_ConntrackListener.cpp
@@ -210,30 +210,11 @@
 					pNatIfaces[i].iface_name,
 					sizeof(pNatIfaces[i].iface_name)) == 0)
 		{
-			/* copy the ipv4 address to filter out downlink connections
-				 ignore downlink after listening connection event from
-				 conntrack as it is not destinated to private ip address */
-			IPACMDBG("Interface (%s) is nat\n", ifr.ifr_name);
-			for (j = 0; j < MAX_IFACE_ADDRESS; j++)
-			{
-				/* check if duplicate NAT ip */
-				if (nat_iface_ipv4_addr[j] == data->ipv4_addr)
-				{
-					*NatIface = true;
-					return IPACM_SUCCESS;
-				}
-
-				if (nat_iface_ipv4_addr[j] == 0)
-				{
-					nat_iface_ipv4_addr[j] = data->ipv4_addr;
-					IPACMDBG_H("Nating connections of Interface (%s), entry (%d) ",
+			IPACMDBG_H("Nat iface (%s), entry (%d), dont cache",
 						pNatIfaces[i].iface_name, j);
-					iptodot("with ipv4 address: ", nat_iface_ipv4_addr[j]);
-
-					*NatIface = true;
-					return IPACM_SUCCESS;
-				}
-			}
+			iptodot("with ipv4 address: ", nat_iface_ipv4_addr[j]);
+			*NatIface = true;
+			return IPACM_SUCCESS;
 		}
 	}
 
@@ -247,6 +228,12 @@
 	bool NatIface = false;
 	int cnt, ret;
 
+	if (isStaMode)
+	{
+		IPACMDBG("In STA mode, don't add dummy rules for non nat ifaces\n");
+		return;
+	}
+
 	/* Handle only non nat ifaces, NAT iface should be handle
 	   separately to avoid race conditions between route/nat
 	   rules add/delete operations */
@@ -261,6 +248,9 @@
 				if (nonnat_iface_ipv4_addr[cnt] == 0)
 				{
 					nonnat_iface_ipv4_addr[cnt] = data->ipv4_addr;
+					IPACMDBG("Add ip addr to non nat list (%d) ", cnt);
+					iptodot("with ipv4 address", nonnat_iface_ipv4_addr[cnt]);
+
 					/* Add dummy nat rule for non nat ifaces */
 					nat_inst->FlushTempEntries(data->ipv4_addr, true, true);
 					return;
@@ -727,7 +717,7 @@
 			{
 				IPACMDBG("matched non_nat_iface_ipv4_addr entry(%d)\n", cnt);
 				iptodot("AddIface(): Non Nat entry match with ip addr",
-						nat_iface_ipv4_addr[cnt]);
+						nonnat_iface_ipv4_addr[cnt]);
 
 				rule->private_ip = rule->public_ip;
 				rule->private_port = rule->public_port;
diff --git a/ipacm/src/IPACM_Conntrack_NATApp.cpp b/ipacm/src/IPACM_Conntrack_NATApp.cpp
index 93627bb..f0bdd99 100644
--- a/ipacm/src/IPACM_Conntrack_NATApp.cpp
+++ b/ipacm/src/IPACM_Conntrack_NATApp.cpp
@@ -242,7 +242,7 @@
 			 cache[cnt].protocol == rule->protocol)
 		{
 			log_nat(rule->protocol,rule->private_ip,rule->target_ip,rule->private_port,\
-			rule->target_port,"Duplicate Rule");
+			rule->target_port,"Duplicate Rule\n");
 			return true;
 		}
 	}
@@ -257,7 +257,7 @@
 	IPACMDBG("%s() %d\n", __FUNCTION__, __LINE__);
 
 	log_nat(rule->protocol,rule->private_ip,rule->target_ip,rule->private_port,\
-	rule->target_port,"for deletion");
+	rule->target_port,"for deletion\n");
 
 
 	for(; cnt < max_entries; cnt++)
@@ -302,7 +302,7 @@
 
 	CHK_TBL_HDL();
 	log_nat(rule->protocol,rule->private_ip,rule->target_ip,rule->private_port,\
-	rule->target_port,"for addition");
+	rule->target_port,"for addition\n");
 	if(isAlgPort(rule->protocol, rule->private_port) ||
 		 isAlgPort(rule->protocol, rule->target_port))
 	{