Merge "ipacm: make ip address in updatetimeout network byte order"
diff --git a/ipacm/src/IPACM_ConntrackClient.cpp b/ipacm/src/IPACM_ConntrackClient.cpp
index f8f143b..ffb0088 100644
--- a/ipacm/src/IPACM_ConntrackClient.cpp
+++ b/ipacm/src/IPACM_ConntrackClient.cpp
@@ -606,28 +606,43 @@
 
 	IPACMDBG("\n");
 
+	pClient = IPACM_ConntrackClient::GetInstance();
+	if(pClient == NULL)
+	{
+		IPACMERR("unable to retrieve instance of conntrack client\n");
+		return;
+	}
+
 	/* destroy the TCP filter.. this will not detach the filter */
-	nfct_filter_destroy(pClient->tcp_filter);
-	pClient->tcp_filter = NULL;
+	if (pClient->tcp_filter) {
+		nfct_filter_destroy(pClient->tcp_filter);
+		pClient->tcp_filter = NULL;
+	}
 
 	/* de-register the callback */
-	nfct_callback_unregister(pClient->tcp_hdl);
-	/* close the handle */
-	nfct_close(pClient->tcp_hdl);
-	pClient->tcp_hdl = NULL;
+	if (pClient->tcp_hdl) {
+		nfct_callback_unregister(pClient->tcp_hdl);
+		/* close the handle */
+		nfct_close(pClient->tcp_hdl);
+		pClient->tcp_hdl = NULL;
+	}
 
 	/* destroy the filter.. this will not detach the filter */
-	nfct_filter_destroy(pClient->udp_filter);
-	pClient->udp_filter = NULL;
+	if (pClient->udp_filter) {
+		nfct_filter_destroy(pClient->udp_filter);
+		pClient->udp_filter = NULL;
+	}
 
 	/* de-register the callback */
-	nfct_callback_unregister(pClient->udp_hdl);
-	/* close the handle */
-	nfct_close(pClient->udp_hdl);
-	pClient->udp_hdl = NULL;
+	if (pClient->udp_hdl) {
+		nfct_callback_unregister(pClient->udp_hdl);
+		/* close the handle */
+		nfct_close(pClient->udp_hdl);
+		pClient->udp_hdl = NULL;
+	}
 
-	pClient->fd_tcp = 0;
-	pClient->fd_udp = 0;
+	pClient->fd_tcp = -1;
+	pClient->fd_udp = -1;
 
 	return;
 }
diff --git a/ipacm/src/IPACM_Wan.cpp b/ipacm/src/IPACM_Wan.cpp
index 0a52ad5..3cda91e 100644
--- a/ipacm/src/IPACM_Wan.cpp
+++ b/ipacm/src/IPACM_Wan.cpp
@@ -3289,11 +3289,10 @@
 		IPACM_Wan::num_v4_flt_rule++;
 
 		/* Configure ALG filtering rules */
+		/* maintain meta data mask */
 		memcpy(&flt_rule_entry.rule.attrib,
 					 &rx_prop->rx[0].attrib,
 					 sizeof(flt_rule_entry.rule.attrib));
-		/* remove meta data mask */
-		flt_rule_entry.rule.attrib.attrib_mask &= ~((uint32_t)IPA_FLT_META_DATA);
 		flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_SRC_PORT;
 		flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_PROTOCOL;
 		for(i = 0; i < ipacm_config->ipa_num_alg_ports; i++)
@@ -3317,11 +3316,10 @@
 			IPACM_Wan::num_v4_flt_rule++;
 		}
 
+		/* maintain meta data mask */
 		memcpy(&flt_rule_entry.rule.attrib,
 					 &rx_prop->rx[0].attrib,
 					 sizeof(flt_rule_entry.rule.attrib));
-		/* remove meta data mask */
-		flt_rule_entry.rule.attrib.attrib_mask &= ~((uint32_t)IPA_FLT_META_DATA);
 		flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_DST_PORT;
 		flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_PROTOCOL;
 		for(i = 0; i < ipacm_config->ipa_num_alg_ports; i++)