Promotion of data.lnx.2.0-00101.
CRs Change ID Subject
--------------------------------------------------------------------------------------------------------------
1098032 I2b5b1f4eedda71dc7df62a3a94229392f98f8042 ipacm: Fix KW issues
1062772 I66dac53f5f1831575d5f208519b70a3fbe802ca0 ipacm: Fix race condition between nat delete rule and up
Change-Id: Ibc857cc3f646463ec20c5067e677b03fd2a1f342
CRs-Fixed: 1098032, 1062772
diff --git a/ipacm/src/IPACM_Config.cpp b/ipacm/src/IPACM_Config.cpp
index eb30e0f..4b02b57 100644
--- a/ipacm/src/IPACM_Config.cpp
+++ b/ipacm/src/IPACM_Config.cpp
@@ -474,7 +474,7 @@
if (ipa_nat_iface_entries < ipa_num_ipa_interfaces)
{
- memcpy(pNatIfaces[ipa_nat_iface_entries - 1].iface_name,
+ strlcpy(pNatIfaces[ipa_nat_iface_entries - 1].iface_name,
dev_name, IPA_IFACE_NAME_LEN);
IPACMDBG_H("Add Nat IfaceName: %s ,update nat-ifaces number: %d\n",
diff --git a/ipacm/src/IPACM_ConntrackListener.cpp b/ipacm/src/IPACM_ConntrackListener.cpp
index 53873cd..ad3fa1e 100644
--- a/ipacm/src/IPACM_ConntrackListener.cpp
+++ b/ipacm/src/IPACM_ConntrackListener.cpp
@@ -210,8 +210,8 @@
sizeof(pNatIfaces[i].iface_name)) == 0)
{
IPACMDBG_H("Nat iface (%s), entry (%d), dont cache",
- pNatIfaces[i].iface_name, j);
- iptodot("with ipv4 address: ", nat_iface_ipv4_addr[j]);
+ pNatIfaces[i].iface_name, i);
+ iptodot("with ipv4 address: ", nat_iface_ipv4_addr[i]);
*NatIface = true;
return IPACM_SUCCESS;
}
diff --git a/ipacm/src/IPACM_Lan.cpp b/ipacm/src/IPACM_Lan.cpp
index f8ed9d8..1727eaf 100644
--- a/ipacm/src/IPACM_Lan.cpp
+++ b/ipacm/src/IPACM_Lan.cpp
@@ -74,6 +74,17 @@
return;
}
+ num_wan_ul_fl_rule_v4 = 0;
+ num_wan_ul_fl_rule_v6 = 0;
+ is_active = true;
+ modem_ul_v4_set = false;
+ modem_ul_v6_set = false;
+ is_mode_switch = false;
+ if_ipv4_subnet =0;
+ each_client_rt_rule_count[IPA_IP_v4] = 0;
+ each_client_rt_rule_count[IPA_IP_v6] = 0;
+ eth_client_len = 0;
+
/* support eth multiple clients */
if(iface_query != NULL)
{
@@ -104,22 +115,14 @@
}
}
- num_wan_ul_fl_rule_v4 = 0;
- num_wan_ul_fl_rule_v6 = 0;
-
memset(wan_ul_fl_rule_hdl_v4, 0, MAX_WAN_UL_FILTER_RULES * sizeof(uint32_t));
memset(wan_ul_fl_rule_hdl_v6, 0, MAX_WAN_UL_FILTER_RULES * sizeof(uint32_t));
- is_active = true;
memset(ipv4_icmp_flt_rule_hdl, 0, NUM_IPV4_ICMP_FLT_RULE * sizeof(uint32_t));
- is_mode_switch = false;
- if_ipv4_subnet =0;
memset(private_fl_rule_hdl, 0, IPA_MAX_PRIVATE_SUBNET_ENTRIES * sizeof(uint32_t));
memset(ipv6_prefix_flt_rule_hdl, 0, NUM_IPV6_PREFIX_FLT_RULE * sizeof(uint32_t));
memset(ipv6_icmp_flt_rule_hdl, 0, NUM_IPV6_ICMP_FLT_RULE * sizeof(uint32_t));
- modem_ul_v4_set = false;
- modem_ul_v6_set = false;
memset(ipv6_prefix, 0, sizeof(ipv6_prefix));
/* ODU routing table initilization */
@@ -157,8 +160,6 @@
}
}
- each_client_rt_rule_count[IPA_IP_v4] = 0;
- each_client_rt_rule_count[IPA_IP_v6] = 0;
if(iface_query != NULL && tx_prop != NULL)
{
for(i=0; i<iface_query->num_tx_props; i++)
diff --git a/ipacm/src/IPACM_Neighbor.cpp b/ipacm/src/IPACM_Neighbor.cpp
index 5a72c4c..b96cebb 100644
--- a/ipacm/src/IPACM_Neighbor.cpp
+++ b/ipacm/src/IPACM_Neighbor.cpp
@@ -76,7 +76,7 @@
IPACMERR("IPA_WLAN_CLIENT_ADD_EVENT_EX: not supported iface id: %d\n", data->if_index);
break;
}
- uint8_t client_mac_addr[6];
+ uint8_t client_mac_addr[6] = {0};
IPACMDBG_H("Received IPA_WLAN_CLIENT_ADD_EVENT\n");
for(i = 0; i < data->num_of_attribs; i++)
diff --git a/ipacm/src/IPACM_Wan.cpp b/ipacm/src/IPACM_Wan.cpp
index 4e6b396..921ddd6 100644
--- a/ipacm/src/IPACM_Wan.cpp
+++ b/ipacm/src/IPACM_Wan.cpp
@@ -129,6 +129,9 @@
is_xlat = false;
hdr_hdl_dummy_v6 = 0;
hdr_proc_hdl_dummy_v6 = 0;
+ is_default_gateway = false;
+ m_fd_ipa = 0;
+ wan_client_len = 0;
if(iface_query != NULL)
{
diff --git a/ipacm/src/IPACM_Wlan.cpp b/ipacm/src/IPACM_Wlan.cpp
index 3bf95f2..2152c4d 100644
--- a/ipacm/src/IPACM_Wlan.cpp
+++ b/ipacm/src/IPACM_Wlan.cpp
@@ -83,6 +83,7 @@
num_wifi_client = 0;
header_name_count = 0;
wlan_client = NULL;
+ wlan_client_len = 0;
if(iface_query != NULL)
{
diff --git a/ipacm/src/IPACM_Xml.cpp b/ipacm/src/IPACM_Xml.cpp
index 073dc98..6b19639 100644
--- a/ipacm/src/IPACM_Xml.cpp
+++ b/ipacm/src/IPACM_Xml.cpp
@@ -268,7 +268,7 @@
str_size = strlen(content);
memset(content_buf, 0, sizeof(content_buf));
memcpy(content_buf, (void *)content, str_size);
- strlcpy(config->iface_config.iface_entries[config->iface_config.num_iface_entries - 1].iface_name, content_buf, str_size+1);
+ strlcpy(config->iface_config.iface_entries[config->iface_config.num_iface_entries - 1].iface_name, content_buf, IPA_IFACE_NAME_LEN);
IPACMDBG_H("Name %s\n", config->iface_config.iface_entries[config->iface_config.num_iface_entries - 1].iface_name);
}
}
diff --git a/ipanat/src/ipa_nat_drvi.c b/ipanat/src/ipa_nat_drvi.c
index faa8c8c..9b96c44 100644
--- a/ipanat/src/ipa_nat_drvi.c
+++ b/ipanat/src/ipa_nat_drvi.c
@@ -1527,13 +1527,20 @@
struct ipa_nat_ip4_table_cache *tbl_ptr;
del_type rule_pos;
uint8_t tbl_indx = (uint8_t)(tbl_hdl - 1);
+ int ret;
/* Parse the rule handle */
ipa_nati_parse_ipv4_rule_hdl(tbl_indx, (uint16_t)rule_hdl,
&expn_tbl, &tbl_entry);
if (IPA_NAT_INVALID_NAT_ENTRY == tbl_entry) {
IPAERR("Invalid Rule Entry\n");
- return -EINVAL;
+ ret = -EINVAL;
+ goto fail;
+ }
+
+ if (pthread_mutex_lock(&nat_mutex) != 0) {
+ ret = -1;
+ goto mutex_lock_error;
}
IPADBG("Delete below rule\n");
@@ -1542,7 +1549,10 @@
tbl_ptr = &ipv4_nat_cache.ip4_tbl[tbl_indx];
if (!tbl_ptr->valid) {
IPAERR("invalid table handle\n");
- return -EINVAL;
+ ret = -EINVAL;
+ if (pthread_mutex_unlock(&nat_mutex) != 0)
+ goto mutex_unlock_error;
+ goto fail;
}
ipa_nati_find_rule_pos(tbl_ptr, expn_tbl,
@@ -1551,7 +1561,10 @@
if (ipa_nati_post_del_dma_cmd(tbl_indx, tbl_entry,
expn_tbl, rule_pos)) {
- return -EINVAL;
+ ret = -EINVAL;
+ if (pthread_mutex_unlock(&nat_mutex) != 0)
+ goto mutex_unlock_error;
+ goto fail;
}
ipa_nati_del_dead_ipv4_head_nodes(tbl_indx);
@@ -1565,7 +1578,22 @@
ipa_nat_dump_ipv4_table(tbl_hdl);
#endif
+ if (pthread_mutex_unlock(&nat_mutex) != 0) {
+ ret = -1;
+ goto mutex_unlock_error;
+ }
+
return 0;
+
+mutex_lock_error:
+ IPAERR("unable to lock the nat mutex\n");
+ return ret;
+
+mutex_unlock_error:
+ IPAERR("unable to unlock the nat mutex\n");
+
+fail:
+ return ret;
}
void ReorderCmds(struct ipa_ioc_nat_dma_cmd *cmd, int size)