Merge "ipacm: do not post internal link up events"
diff --git a/ipacm/src/IPACM_Lan.cpp b/ipacm/src/IPACM_Lan.cpp
index b1cdb2f..984e589 100644
--- a/ipacm/src/IPACM_Lan.cpp
+++ b/ipacm/src/IPACM_Lan.cpp
@@ -1777,8 +1777,9 @@
 	IPACM_Config* ipacm_config = IPACM_Iface::ipacmcfg;
 	struct ipa_ioc_write_qmapid mux;
 
-	/* not  needed for newer versions since it will be overridden by NAT metadata replacement for IPAv4 and up */
-	if((IPACM_Iface::ipacmcfg->GetIPAVer() < IPA_HW_v4_0) && (rx_prop != NULL))
+	/* for newer versions metadata is overridden by NAT metadata replacement for IPAv4 and up */
+	/* this is still needed for IPv6 traffic in case qmapid need to be used */
+	if(rx_prop != NULL)
 	{
 		/* give mux ID of the default PDN to IPA-driver for WLAN/LAN pkts */
 		fd = open(IPA_DEVICE_NAME, O_RDWR);
diff --git a/ipacm/src/IPACM_OffloadManager.cpp b/ipacm/src/IPACM_OffloadManager.cpp
index b8c3cf5..81bf4e3 100644
--- a/ipacm/src/IPACM_OffloadManager.cpp
+++ b/ipacm/src/IPACM_OffloadManager.cpp
@@ -576,7 +576,7 @@
 RET IPACM_OffloadManager::setQuota(const char * upstream_name /* upstream */, uint64_t mb/* limit */)
 {
 	wan_ioctl_set_data_quota quota;
-	int fd = -1,rc = 0;
+	int fd = -1, rc = 0, err_type = 0;
 
 	if ((fd = open(DEVICE_NAME, O_RDWR)) < 0)
 	{
@@ -600,9 +600,10 @@
 
 	if(rc != 0)
 	{
+		err_type = errno;
 		close(fd);
-        	IPACMERR("IOCTL WAN_IOCTL_SET_DATA_QUOTA call failed: %s rc: %d\n", strerror(errno),rc);
-		if (errno == ENODEV) {
+		IPACMERR("IOCTL WAN_IOCTL_SET_DATA_QUOTA call failed: %s err_type: %d\n", strerror(err_type), err_type);
+		if (err_type == ENODEV) {
 			IPACMDBG_H("Invalid argument.\n");
 			return FAIL_UNSUPPORTED;
 		}
diff --git a/ipacm/src/IPACM_Xml.cpp b/ipacm/src/IPACM_Xml.cpp
index b81856a..4451906 100644
--- a/ipacm/src/IPACM_Xml.cpp
+++ b/ipacm/src/IPACM_Xml.cpp
@@ -665,6 +665,9 @@
 						memcpy(content_buf, (void *)content, str_size);
 						config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v4.tos
 							 = atoi(content_buf);
+						// Here we do not know if it is TOS with mask or not, so we put at both places
+						config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.tos_value
+							= atoi(content_buf);
 						IPACMDBG_H("\n IPV4 TOS val is %d \n",
 										 config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v4.tos);
 					}
@@ -674,13 +677,25 @@
 					content = IPACM_read_content_element(xml_node);
 					if (content)
 					{
+						uint8_t mask;
+
 						str_size = strlen(content);
 						memset(content_buf, 0, sizeof(content_buf));
 						memcpy(content_buf, (void *)content, str_size);
-						config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v4.tos
-							 &= atoi(content_buf);
-						IPACMDBG_H("\n IPv4 TOS mask is %d \n",
-								config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v4.tos);
+						mask = atoi(content_buf);
+						IPACMDBG_H("\n IPv4 TOS mask is %u \n", mask);
+						if (mask != 0xFF) {
+							// TOS attribute cannot be used
+							config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.u.v4.tos = 0;
+							config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.tos_mask = mask;
+
+							config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.attrib_mask |=
+								IPA_FLT_TOS_MASKED;
+							config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.attrib_mask &=
+								~IPA_FLT_TOS;
+						} else {
+							config->extd_firewall_entries[config->num_extd_firewall_entries - 1].attrib.tos_value = 0;
+						}
 					}
 				}
 				else if (0 == IPACM_util_icmp_string((char*)xml_node->name, IPV4NextHeaderProtocol_TAG))