Merge ebe50e75f9617b89a20b73acbf665ca23520fb8d on remote branch
Change-Id: Ic344cdfc5d09e954df92d9c1ec2d588df822ca1b
diff --git a/ipacm/inc/IPACM_Iface.h b/ipacm/inc/IPACM_Iface.h
index df192c9..55d9e99 100644
--- a/ipacm/inc/IPACM_Iface.h
+++ b/ipacm/inc/IPACM_Iface.h
@@ -142,10 +142,10 @@
void change_to_network_order(ipa_ip_type iptype, ipa_rule_attrib* attrib);
/* software routing enable */
- virtual int handle_software_routing_enable(void);
+ virtual int handle_software_routing_enable(bool mhip);
/* software routing disable */
- virtual int handle_software_routing_disable(void);
+ virtual int handle_software_routing_disable(bool mhip);
void delete_iface(void);
bool is_global_ipv6_addr(uint32_t* ipv6_addr);
diff --git a/ipacm/inc/IPACM_Wan.h b/ipacm/inc/IPACM_Wan.h
index 9acf175..684bfb7 100644
--- a/ipacm/inc/IPACM_Wan.h
+++ b/ipacm/inc/IPACM_Wan.h
@@ -253,9 +253,16 @@
return curr_wan_ip;
}
- static bool getXlat_Mux_Id()
+ static int getXlat_Mux_Id()
{
- return xlat_mux_id;
+ if (is_xlat)
+ {
+ IPACMDBG_H("xlat_mux_id: %d\n", xlat_mux_id);
+ return xlat_mux_id;
+ } else {
+ IPACMDBG_H("no xlat return invalid mux-id: 0\n");
+ return 0;
+ }
}
static void clearExtProp()
@@ -370,6 +377,12 @@
/* handle for icmpv6 exception rule */
uint32_t icmpv6_exception_hdl;
+ /* handle for TCP FIN rule */
+ uint32_t tcp_fin_hdl;
+
+ /* handle for TCP RST rule */
+ uint32_t tcp_rst_hdl;
+
inline ipa_wan_client* get_client_memptr(ipa_wan_client *param, int cnt)
{
char *ret = ((char *)param) + (wan_client_len * cnt);
@@ -636,6 +649,10 @@
int add_icmpv6_exception_rule();
int delete_icmpv6_exception_rule();
+
+ int add_tcp_fin_rst_exception_rule();
+
+ int delete_tcp_fin_rst_exception_rule();
};
#endif /* IPACM_WAN_H */
diff --git a/ipacm/src/IPACM_Iface.cpp b/ipacm/src/IPACM_Iface.cpp
index 05dd6ca..ec4a9ea 100644
--- a/ipacm/src/IPACM_Iface.cpp
+++ b/ipacm/src/IPACM_Iface.cpp
@@ -88,12 +88,14 @@
}
/* software routing enable */
-int IPACM_Iface::handle_software_routing_enable(void)
+int IPACM_Iface::handle_software_routing_enable(bool mhip)
{
-
+ int fd =0;
int res = IPACM_SUCCESS;
struct ipa_flt_rule_add flt_rule_entry;
ipa_ioc_add_flt_rule *m_pFilteringTable;
+ /* contruct filter rules to pcie modem */
+ ipa_ioc_generate_flt_eq flt_eq;
IPACMDBG("\n");
if (softwarerouting_act == true)
@@ -121,11 +123,9 @@
}
m_pFilteringTable->commit = 1;
- m_pFilteringTable->ep = rx_prop->rx[0].src_pipe;
m_pFilteringTable->global = false;
m_pFilteringTable->num_rules = (uint8_t)1;
-
/* Configuring Software-Routing Filtering Rule */
memset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));
@@ -139,72 +139,52 @@
memcpy(&flt_rule_entry.rule.attrib,
&rx_prop->rx[0].attrib,
sizeof(flt_rule_entry.rule.attrib));
- /* disble meta-data filtering skylar */
- if (IPACM_Wan::backhaul_mode == Q6_MHI_WAN)
- {
- flt_rule_entry.rule.attrib.attrib_mask &= ~((uint32_t)IPA_FLT_META_DATA);
- IPACMDBG_H("disable meta-data filtering 0x%x\n", flt_rule_entry.rule.attrib.attrib_mask);
- }
memcpy(&(m_pFilteringTable->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));
/* check iface is v4 or v6 or both*/
-// if (ip_type == IPA_IP_MAX)
-// {
+
/* handle v4 */
m_pFilteringTable->ip = IPA_IP_v4;
- if (false == m_filtering.AddFilteringRule(m_pFilteringTable))
+
+ fd = open(IPA_DEVICE_NAME, O_RDWR);
+ if (fd < 0)
+ {
+ IPACMERR("Failed opening %s.\n", IPA_DEVICE_NAME);
+ free(m_pFilteringTable);
+ return IPACM_FAILURE;
+ }
+
+ if (mhip)
+ {
+ /* generate eq */
+ memset(&flt_eq, 0, sizeof(flt_eq));
+ memcpy(&flt_eq.attrib, &flt_rule_entry.rule.attrib, sizeof(flt_eq.attrib));
+ flt_eq.ip = IPA_IP_v4;
+
+
+ if(0 != ioctl(fd, IPA_IOC_GENERATE_FLT_EQ, &flt_eq)) //define and cpy attribute to this struct
{
- IPACMERR("Error Adding Filtering rule, aborting...\n");
+ IPACMERR("Failed to get eq_attrib\n");
res = IPACM_FAILURE;
goto fail;
}
- else if (m_pFilteringTable->rules[0].status)
+ memcpy(&flt_rule_entry.rule.eq_attrib,
+ &flt_eq.eq_attrib,
+ sizeof(flt_rule_entry.rule.eq_attrib));
+ memcpy(&(m_pFilteringTable->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));
+
+ /* add rule */
+ if(false == m_filtering.AddOffloadFilteringRule(m_pFilteringTable, IPACM_Iface::ipacmcfg->GetQmapId(), 1))
{
- IPACMERR("adding flt rule failed status=0x%x\n", m_pFilteringTable->rules[0].status);
+ IPACMERR("Failed to install WAN DL filtering table.\n");
res = IPACM_FAILURE;
goto fail;
}
-
- IPACM_Iface::ipacmcfg->increaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v4, 1);
- IPACMDBG("soft-routing flt rule hdl0=0x%x\n", m_pFilteringTable->rules[0].flt_rule_hdl);
- /* copy filter hdls */
- software_routing_fl_rule_hdl[0] = m_pFilteringTable->rules[0].flt_rule_hdl;
-
-
- /* handle v6*/
- m_pFilteringTable->ip = IPA_IP_v6;
- if (false == m_filtering.AddFilteringRule(m_pFilteringTable))
- {
- IPACMERR("Error Adding Filtering rule, aborting...\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- else if (m_pFilteringTable->rules[0].status)
- {
- IPACMDBG("adding flt rule failed status=0x%x\n", m_pFilteringTable->rules[0].status);
- res = IPACM_FAILURE;
- goto fail;
- }
-
- IPACM_Iface::ipacmcfg->increaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v6, 1);
- IPACMDBG("soft-routing flt rule hdl0=0x%x\n", m_pFilteringTable->rules[0].flt_rule_hdl);
- /* copy filter hdls */
- software_routing_fl_rule_hdl[1] = m_pFilteringTable->rules[0].flt_rule_hdl;
- softwarerouting_act = true;
-#if 0
}
else
{
- if (ip_type == IPA_IP_v4)
- {
- m_pFilteringTable->ip = IPA_IP_v4;
- }
- else
- {
- m_pFilteringTable->ip = IPA_IP_v6;
- }
-
+ m_pFilteringTable->ep = rx_prop->rx[0].src_pipe;
if (false == m_filtering.AddFilteringRule(m_pFilteringTable))
{
IPACMERR("Error Adding Filtering rule, aborting...\n");
@@ -217,32 +197,79 @@
res = IPACM_FAILURE;
goto fail;
}
-
- IPACM_Iface::ipacmcfg->increaseFltRuleCount(rx_prop->rx[0].src_pipe, ip_type, 1);
- IPACMDBG("soft-routing flt rule hdl0=0x%x\n", m_pFilteringTable->rules[0].flt_rule_hdl);
- /* copy filter hdls */
- if (ip_type == IPA_IP_v4)
- {
- software_routing_fl_rule_hdl[0] = m_pFilteringTable->rules[0].flt_rule_hdl;
- }
- else
- {
- software_routing_fl_rule_hdl[1] = m_pFilteringTable->rules[0].flt_rule_hdl;
- }
- softwarerouting_act = true;
+ IPACM_Iface::ipacmcfg->increaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v4, 1);
}
-#endif
+
+ IPACMDBG("soft-routing ipv4 flt rule hdl0=0x%x\n", m_pFilteringTable->rules[0].flt_rule_hdl);
+ /* copy filter hdls */
+ software_routing_fl_rule_hdl[0] = m_pFilteringTable->rules[0].flt_rule_hdl;
+
+ /* handle v6*/
+ m_pFilteringTable->ip = IPA_IP_v6;
+ if (mhip)
+ {
+ /* generate eq */
+ memset(&flt_eq, 0, sizeof(flt_eq));
+ memcpy(&flt_eq.attrib, &flt_rule_entry.rule.attrib, sizeof(flt_eq.attrib));
+ flt_eq.ip = IPA_IP_v6;
+
+ if(0 != ioctl(fd, IPA_IOC_GENERATE_FLT_EQ, &flt_eq)) //define and cpy attribute to this struct
+ {
+ IPACMERR("Failed to get eq_attrib\n");
+ res = IPACM_FAILURE;
+ goto fail;
+ }
+ memcpy(&flt_rule_entry.rule.eq_attrib,
+ &flt_eq.eq_attrib,
+ sizeof(flt_rule_entry.rule.eq_attrib));
+ memcpy(&(m_pFilteringTable->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));
+
+ /* add rule */
+ if(false == m_filtering.AddOffloadFilteringRule(m_pFilteringTable, IPACM_Iface::ipacmcfg->GetQmapId(), 1))
+ {
+ IPACMERR("Failed to install WAN DL filtering table.\n");
+ res = IPACM_FAILURE;
+ goto fail;
+ }
+ }
+ else
+ {
+ m_pFilteringTable->ep = rx_prop->rx[0].src_pipe;
+ if (false == m_filtering.AddFilteringRule(m_pFilteringTable))
+ {
+ IPACMERR("Error Adding Filtering rule, aborting...\n");
+ res = IPACM_FAILURE;
+ goto fail;
+ }
+ else if (m_pFilteringTable->rules[0].status)
+ {
+ IPACMERR("adding flt rule failed status=0x%x\n", m_pFilteringTable->rules[0].status);
+ res = IPACM_FAILURE;
+ goto fail;
+ }
+ IPACM_Iface::ipacmcfg->increaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v6, 1);
+ }
+
+ IPACMDBG("soft-routing ipv6 flt rule hdl0=0x%x\n", m_pFilteringTable->rules[0].flt_rule_hdl);
+ /* copy filter hdls */
+ software_routing_fl_rule_hdl[1] = m_pFilteringTable->rules[0].flt_rule_hdl;
+ softwarerouting_act = true;
fail:
+ close(fd);
+ if(m_pFilteringTable != NULL)
+ {
free(m_pFilteringTable);
-
+ }
return res;
}
/* software routing disable */
-int IPACM_Iface::handle_software_routing_disable(void)
+int IPACM_Iface::handle_software_routing_disable(bool mhip)
{
- int res = IPACM_SUCCESS;
+ int len, res = IPACM_SUCCESS;
+ ipa_ioc_del_flt_rule *pFilteringTable = NULL;
+ struct ipa_flt_rule_del flt_rule_entry;
if (rx_prop == NULL)
{
@@ -256,8 +283,43 @@
return IPACM_SUCCESS;
}
-// if (ip_type == IPA_IP_MAX)
-// {
+ if(mhip)
+ {
+ len = sizeof(struct ipa_ioc_del_flt_rule) + sizeof(struct ipa_flt_rule_del);
+ pFilteringTable = (struct ipa_ioc_del_flt_rule*)malloc(len);
+ if (pFilteringTable == NULL)
+ {
+ IPACMERR("Error Locate ipa_ioc_del_flt_rule memory...\n");
+ return IPACM_FAILURE;
+ }
+ memset(pFilteringTable, 0, len);
+
+ pFilteringTable->commit = 1;
+ pFilteringTable->ip = IPA_IP_v4;
+ pFilteringTable->num_hdls = (uint8_t)1;
+
+ if (software_routing_fl_rule_hdl[0] == 0)
+ {
+ IPACMERR("invalid ipv4_exception_hdl.\n");
+ res = IPACM_FAILURE;
+ goto fail;
+ }
+
+ memset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_del));
+ flt_rule_entry.hdl = software_routing_fl_rule_hdl[0];
+
+ memcpy(&(pFilteringTable->hdl[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_del));
+
+ if(false == m_filtering.DelOffloadFilteringRule(pFilteringTable))
+ {
+ IPACMERR("Failed to delete MHI ipv4 exception rule.\n");
+ res = IPACM_FAILURE;
+ goto fail;
+ }
+ software_routing_fl_rule_hdl[0] = 0;
+ }
+ else
+ {
/* ipv4 case */
if (m_filtering.DeleteFilteringHdls(&software_routing_fl_rule_hdl[0],
IPA_IP_v4, 1) == false)
@@ -266,8 +328,34 @@
res = IPACM_FAILURE;
goto fail;
}
- IPACM_Iface::ipacmcfg->decreaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v4, 1);
+ }
+ IPACM_Iface::ipacmcfg->decreaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v4, 1);
+ if(mhip)
+ {
+ pFilteringTable->ip = IPA_IP_v6;
+ if (software_routing_fl_rule_hdl[1] == 0)
+ {
+ IPACMERR("invalid ipv6_exception_hdl.\n");
+ res = IPACM_FAILURE;
+ goto fail;
+ }
+
+ memset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_del));
+ flt_rule_entry.hdl = software_routing_fl_rule_hdl[1];
+
+ memcpy(&(pFilteringTable->hdl[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_del));
+
+ if(false == m_filtering.DelOffloadFilteringRule(pFilteringTable))
+ {
+ IPACMERR("Failed to delete MHI ipv6 exception rule.\n");
+ res = IPACM_FAILURE;
+ goto fail;
+ }
+ software_routing_fl_rule_hdl[1] = 0;
+ }
+ else
+ {
/* ipv6 case */
if (m_filtering.DeleteFilteringHdls(&software_routing_fl_rule_hdl[1],
IPA_IP_v6, 1) == false)
@@ -276,43 +364,15 @@
res = IPACM_FAILURE;
goto fail;
}
- IPACM_Iface::ipacmcfg->decreaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v6, 1);
- softwarerouting_act = false;
-#if 0
}
- else
- {
- if (ip_type == IPA_IP_v4)
- {
- ip = IPA_IP_v4;
- }
- else
- {
- ip = IPA_IP_v6;
- }
-
-
- if (ip_type == IPA_IP_v4)
- {
- flt_hdl = software_routing_fl_rule_hdl[0];
- }
- else
- {
- flt_hdl = software_routing_fl_rule_hdl[1];
- }
-
- if (m_filtering.DeleteFilteringHdls(&flt_hdl, ip, 1) == false)
- {
- IPACMERR("Error Adding Filtering rule, aborting...\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- IPACM_Iface::ipacmcfg->decreaseFltRuleCount(rx_prop->rx[0].src_pipe, ip, 1);
+ IPACM_Iface::ipacmcfg->decreaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v6, 1);
softwarerouting_act = false;
- }
-#endif
fail:
+ if(pFilteringTable != NULL)
+ {
+ free(pFilteringTable);
+ }
return res;
}
diff --git a/ipacm/src/IPACM_Lan.cpp b/ipacm/src/IPACM_Lan.cpp
index fd67ea4..755d730 100644
--- a/ipacm/src/IPACM_Lan.cpp
+++ b/ipacm/src/IPACM_Lan.cpp
@@ -511,7 +511,7 @@
{
/* handle software routing enable event*/
IPACMDBG_H("IPA_SW_ROUTING_ENABLE for iface: %s \n",IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name);
- handle_software_routing_enable();
+ handle_software_routing_enable(false);
}
}
@@ -751,15 +751,19 @@
{
IPACMDBG_H("Received IPA_DOWNSTREAM_ADD event.\n");
#ifdef FEATURE_IPA_ANDROID
- /* indicate v4-offload */
- IPACM_OffloadManager::num_offload_v4_tethered_iface++;
-
- /* xlat not support for 2st tethered iface */
- if (IPACM_Wan::isXlat() && (data->prefix.iptype == IPA_IP_v4) && (IPACM_OffloadManager::num_offload_v4_tethered_iface > 1))
+ if (IPACM_Wan::isXlat() && (data->prefix.iptype == IPA_IP_v4))
{
- IPACMDBG_H("Not support 2st downstream iface %s for xlat, cur: %d\n", dev_name,
- IPACM_OffloadManager::num_offload_v4_tethered_iface);
- return;
+ /* indicate v4-offload */
+ IPACM_OffloadManager::num_offload_v4_tethered_iface++;
+ IPACMDBG_H("in xlat: update num_offload_v4_tethered_iface %d\n", IPACM_OffloadManager::num_offload_v4_tethered_iface);
+
+ /* xlat not support for 2st tethered iface */
+ if (IPACM_OffloadManager::num_offload_v4_tethered_iface > 1)
+ {
+ IPACMDBG_H("Not support 2st downstream iface %s for xlat, cur: %d\n", dev_name,
+ IPACM_OffloadManager::num_offload_v4_tethered_iface);
+ return;
+ }
}
IPACMDBG_H(" support downstream iface %s, cur %d\n", dev_name,
@@ -1066,13 +1070,13 @@
case IPA_SW_ROUTING_ENABLE:
IPACMDBG_H("Received IPA_SW_ROUTING_ENABLE\n");
/* handle software routing enable event*/
- handle_software_routing_enable();
+ handle_software_routing_enable(false);
break;
case IPA_SW_ROUTING_DISABLE:
IPACMDBG_H("Received IPA_SW_ROUTING_DISABLE\n");
/* handle software routing disable event*/
- handle_software_routing_disable();
+ handle_software_routing_disable(false);
break;
case IPA_CRADLE_WAN_MODE_SWITCH:
@@ -1882,6 +1886,7 @@
ret = handle_uplink_filter_rule(ext_prop, iptype, xlat_mux_id);
modem_ul_v6_set = true;
} else if (iptype ==IPA_IP_v4 && modem_ul_v4_set == false) {
+ IPACMDBG_H("check getXlat_Mux_Id:%d\n", IPACM_Wan::getXlat_Mux_Id());
IPACMDBG_H("IPA_IP_v4 xlat_mux_id: %d, modem_ul_v4_set %d\n", xlat_mux_id, modem_ul_v4_set);
ret = handle_uplink_filter_rule(ext_prop, iptype, xlat_mux_id);
modem_ul_v4_set = true;
@@ -3223,7 +3228,7 @@
/* check software routing fl rule hdl */
if (softwarerouting_act == true && rx_prop != NULL)
{
- handle_software_routing_disable();
+ handle_software_routing_disable(false);
}
if (odu_route_rule_v4_hdl != NULL)
@@ -3279,7 +3284,7 @@
int fd;
int i, index, eq_index;
uint32_t value = 0;
- uint8_t qmap_id;
+ uint8_t qmap_id, xlat_debug;
bool result;
IPACMDBG_H("Set modem UL flt rules\n");
@@ -3338,13 +3343,14 @@
flt_index.retain_header = 0;
flt_index.embedded_call_mux_id_valid = 1;
qmap_id = IPACM_Iface::ipacmcfg->GetQmapId();
+ xlat_debug = IPACM_Wan::getXlat_Mux_Id();
flt_index.embedded_call_mux_id = qmap_id;
#ifndef FEATURE_IPA_V3
- IPACMDBG_H("flt_index: src pipe: %d, num of rules: %d, ebd pipe: %d, mux id: %d\n",
- flt_index.source_pipe_index, flt_index.filter_index_list_len, flt_index.embedded_pipe_index, flt_index.embedded_call_mux_id);
+ IPACMDBG_H("flt_index: src pipe: %d, num of rules: %d, ebd pipe: %d, mux id: %d, xlat_mux id: %d, wan-debug %d\n",
+ flt_index.source_pipe_index, flt_index.filter_index_list_len, flt_index.embedded_pipe_index, flt_index.embedded_call_mux_id, xlat_mux_id, xlat_debug);
#else /* defined (FEATURE_IPA_V3) */
- IPACMDBG_H("flt_index: src pipe: %d, num of rules: %d, ebd pipe: %d, mux id: %d\n",
- flt_index.source_pipe_index, flt_index.rule_id_len, flt_index.embedded_pipe_index, flt_index.embedded_call_mux_id);
+ IPACMDBG_H("flt_index: src pipe: %d, num of rules: %d, ebd pipe: %d, mux id: %d, xlat_mux id: %d, wan-debug %d\n",
+ flt_index.source_pipe_index, flt_index.rule_id_len, flt_index.embedded_pipe_index, flt_index.embedded_call_mux_id, xlat_mux_id, xlat_debug);
#endif
len = sizeof(struct ipa_ioc_add_flt_rule) + prop->num_ext_props * sizeof(struct ipa_flt_rule_add);
pFilteringTable = (struct ipa_ioc_add_flt_rule*)malloc(len);
@@ -3415,6 +3421,13 @@
}
/* Handle XLAT configuration */
+ /* temp wa to reset xlat_mux_id to qmap_id if it's xlat call */
+ if (IPACM_Wan::isXlat() && (iptype == IPA_IP_v4))
+ {
+ IPACMDBG_H("WA to replace xlat_mux_id %d with qmap_id: %d\n", xlat_mux_id, qmap_id);
+ xlat_mux_id = qmap_id;
+ }
+
if ((iptype == IPA_IP_v4) && prop->prop[cnt].is_xlat_rule && (xlat_mux_id != 0))
{
/* fill the value of meta-data */
@@ -4719,7 +4732,7 @@
}
}
- ret = ioctl(fd_wwan_ioctl, WAN_IOC_SET_TETHER_CLIENT_PIPE, &tether_client);
+ ret = ioctl(fd_wwan_ioctl, WAN_IOC_SET_TETHER_CLIENT_PIPE, tether_client);
if(ret != 0)
{
IPACMERR("Failed set tether-client-pipe %p with ret %d\n ", &tether_client, ret);
diff --git a/ipacm/src/IPACM_Wan.cpp b/ipacm/src/IPACM_Wan.cpp
index 7638765..db0304a 100644
--- a/ipacm/src/IPACM_Wan.cpp
+++ b/ipacm/src/IPACM_Wan.cpp
@@ -1005,7 +1005,7 @@
if ((ipa_interface_index == ipa_if_num) && (m_is_sta_mode == Q6_WAN))
{
is_xlat_local = true;
- IPACMDBG_H("WAN-LTE (%s) link up, iface: %d is_xlat: %d\n",
+ IPACMDBG_H("WAN-LTE (%s) link up, iface: %d is_xlat_local: %d\n",
IPACM_Iface::ipacmcfg->iface_table[ipa_interface_index].iface_name,data->if_index, is_xlat_local);
}
break;
@@ -1179,7 +1179,15 @@
{
/* handle software routing enable event*/
IPACMDBG_H("IPA_SW_ROUTING_ENABLE for iface: %s \n",IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name);
- handle_software_routing_enable();
+
+ if(m_is_sta_mode == Q6_MHI_WAN)
+ {
+ handle_software_routing_enable(true);
+ }
+ else
+ {
+ handle_software_routing_enable(false);
+ }
}
}
@@ -1632,9 +1640,13 @@
{
install_wan_filtering_rule(true);
}
+ else if(m_is_sta_mode == Q6_MHI_WAN)
+ {
+ handle_software_routing_enable(true);
+ }
else
{
- handle_software_routing_enable();
+ handle_software_routing_enable(false);
}
break;
@@ -1647,9 +1659,13 @@
install_wan_filtering_rule(false);
softwarerouting_act = false;
}
+ else if(m_is_sta_mode == Q6_MHI_WAN)
+ {
+ handle_software_routing_disable(true);
+ }
else
{
- handle_software_routing_disable();
+ handle_software_routing_disable(false);
}
break;
@@ -1854,6 +1870,13 @@
IPACMERR("Failed to send ICMPv6 ex rule to modem.\n");
return IPACM_FAILURE;
}
+
+ /* send ipv4 TCP FIN filtering rule */
+ if(iptype==IPA_IP_v4 && add_tcp_fin_rst_exception_rule())
+ {
+ IPACMERR("Failed to send TCP FIN RST rule to modem.\n");
+ return IPACM_FAILURE;
+ }
}
else
{
@@ -2123,13 +2146,13 @@
IPACM_Wan::is_xlat = is_xlat_local;
/* send xlat configuration for installing uplink rules */
- if(IPACM_Wan::is_xlat && (m_is_sta_mode == Q6_WAN))
+ if(is_xlat_local && (m_is_sta_mode == Q6_WAN))
{
IPACM_Wan::xlat_mux_id = ext_prop->ext[0].mux_id;
wanup_data->xlat_mux_id = IPACM_Wan::xlat_mux_id;
IPACMDBG_H("Set xlat configuraiton with below information:\n");
- IPACMDBG_H("xlat_enabled: %d xlat_mux_id: %d \n",
- IPACM_Wan::is_xlat, xlat_mux_id);
+ IPACMDBG_H("xlat_enabled: %d set xlat_mux_id: %d \n",
+ is_xlat_local, IPACM_Wan::xlat_mux_id);
}
else /*temp put xlat = 0 for Q6_MHI_WAN*/
{
@@ -2245,7 +2268,7 @@
wanup_data->if_index_tether = ipa_if_num_tether;
wanup_data->backhaul_type = m_is_sta_mode;
/* xlat mux-id*/
- if(is_xlat && (m_is_sta_mode == Q6_WAN))
+ if(is_xlat_local && (m_is_sta_mode == Q6_WAN))
wanup_data->xlat_mux_id = ext_prop->ext[0].mux_id;
else
wanup_data->xlat_mux_id = 0;
@@ -4899,6 +4922,12 @@
IPACMERR("Failed to delete icmpv6 rule \n");
return IPACM_FAILURE;
}
+ /* Delete tcp_fin_rst rule */
+ if(delete_tcp_fin_rst_exception_rule())
+ {
+ IPACMERR("Failed to delete tcp_fin_rst rule \n");
+ return IPACM_FAILURE;
+ }
}
else
{
@@ -5381,7 +5410,14 @@
/* check software routing fl rule hdl */
if (softwarerouting_act == true)
{
- handle_software_routing_disable();
+ if(m_is_sta_mode == Q6_MHI_WAN)
+ {
+ handle_software_routing_disable(true);
+ }
+ else
+ {
+ handle_software_routing_disable(false);
+ }
}
/* free dft ipv4 filter rule handlers if any */
if (ip_type != IPA_IP_v6 && rx_prop != NULL)
@@ -5770,11 +5806,11 @@
}
}
- /* check software routing fl rule hdl */
- if (softwarerouting_act == true)
- {
- handle_software_routing_disable();
- }
+// /* check software routing fl rule hdl */
+// if (softwarerouting_act == true)
+// {
+// handle_software_routing_disable();
+// }
fail:
if (tx_prop != NULL)
@@ -7606,7 +7642,7 @@
flt_rule_entry.rule.retain_hdr = 1;
flt_rule_entry.rule.to_uc = 0;
flt_rule_entry.rule.eq_attrib_type = 0;
- flt_rule_entry.at_rear = true;
+ flt_rule_entry.at_rear = false;
flt_rule_entry.flt_rule_hdl = -1;
flt_rule_entry.status = -1;
flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;
@@ -7710,3 +7746,170 @@
}
return res;
}
+
+int IPACM_Wan::add_tcp_fin_rst_exception_rule()
+{
+ int fd;
+ int len, res = IPACM_SUCCESS;
+ uint8_t mux_id;
+ ipa_ioc_add_flt_rule *pFilteringTable = NULL;
+
+ mux_id = ext_prop->ext[0].mux_id;
+ /* contruct filter rules to pcie modem */
+ struct ipa_flt_rule_add flt_rule_entry;
+ ipa_ioc_generate_flt_eq flt_eq;
+
+ /* construct rule */
+ IPACMDBG_H("adding MHI TCP FIN RST rule\n");
+ len = sizeof(struct ipa_ioc_add_flt_rule) + (2 * sizeof(struct ipa_flt_rule_add));
+ pFilteringTable = (struct ipa_ioc_add_flt_rule*)malloc(len);
+ if (pFilteringTable == NULL)
+ {
+ IPACMERR("Error Locate ipa_flt_rule_add memory...\n");
+ return IPACM_FAILURE;
+ }
+ memset(pFilteringTable, 0, len);
+
+ pFilteringTable->commit = 1;
+ pFilteringTable->global = false;
+ pFilteringTable->ip = IPA_IP_v4;
+ pFilteringTable->num_rules = (uint8_t)2;
+
+ /* Configuring TCP FIN RST Filtering Rule */
+ memset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));
+ flt_rule_entry.rule.retain_hdr = 1;
+ flt_rule_entry.rule.to_uc = 0;
+ flt_rule_entry.rule.eq_attrib_type = 0;
+ flt_rule_entry.at_rear = false;
+ flt_rule_entry.flt_rule_hdl = -1;
+ flt_rule_entry.status = -1;
+ flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;
+ /*
+ * need this since fin is last packet in an ongoing TCP connection
+ * so it will always match the previous hash and take MHIP path
+ */
+ flt_rule_entry.rule.hashable = false;
+
+ IPACMDBG_H("rx property attrib mask:0x%x\n", rx_prop->rx[0].attrib.attrib_mask);
+ memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule_entry.rule.attrib));
+ flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_PROTOCOL;
+ flt_rule_entry.rule.attrib.u.v4.protocol = (uint8_t)IPACM_FIREWALL_IPPROTO_TCP;
+
+ /* generate eq */
+ memset(&flt_eq, 0, sizeof(flt_eq));
+ memcpy(&flt_eq.attrib, &flt_rule_entry.rule.attrib, sizeof(flt_eq.attrib));
+ flt_eq.ip = IPA_IP_v4;
+
+ fd = open(IPA_DEVICE_NAME, O_RDWR);
+ if (fd < 0)
+ {
+ IPACMERR("Failed opening %s.\n", IPA_DEVICE_NAME);
+ free(pFilteringTable);
+ return IPACM_FAILURE;
+ }
+
+ if(0 != ioctl(fd, IPA_IOC_GENERATE_FLT_EQ, &flt_eq)) //define and cpy attribute to this struct
+ {
+ IPACMERR("Failed to get eq_attrib\n");
+ res = IPACM_FAILURE;
+ goto fail;
+ }
+ memcpy(&flt_rule_entry.rule.eq_attrib,
+ &flt_eq.eq_attrib,
+ sizeof(flt_rule_entry.rule.eq_attrib));
+
+ /* set the bit mask to use MEQ32_IHL offset */
+ #ifdef FEATURE_IPA_V3
+ flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<7);
+ #else
+ flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<8);
+ #endif
+
+ /* add offset to compare TCP flags */
+ flt_rule_entry.rule.eq_attrib.num_ihl_offset_meq_32 = 1;
+ flt_rule_entry.rule.eq_attrib.ihl_offset_meq_32[0].offset = 12;
+
+ /* add TCP FIN RULE */
+ flt_rule_entry.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_FIN_SHIFT);
+ flt_rule_entry.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_FIN_SHIFT);
+ memcpy(&(pFilteringTable->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));
+
+ /* add TCP RST rule*/
+ flt_rule_entry.rule.eq_attrib.ihl_offset_meq_32[0].value = (((uint32_t)1)<<TCP_RST_SHIFT);
+ flt_rule_entry.rule.eq_attrib.ihl_offset_meq_32[0].mask = (((uint32_t)1)<<TCP_RST_SHIFT);
+ memcpy(&(pFilteringTable->rules[1]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));
+
+ /* add rules */
+ if(false == m_filtering.AddOffloadFilteringRule(pFilteringTable, mux_id, 1))
+ {
+ IPACMERR("Failed to install WAN DL filtering table.\n");
+ res = IPACM_FAILURE;
+ goto fail;
+ }
+
+ /* save handle */
+ tcp_fin_hdl = pFilteringTable->rules[0].flt_rule_hdl;
+ tcp_rst_hdl = pFilteringTable->rules[1].flt_rule_hdl;
+
+fail:
+ close(fd);
+ if(pFilteringTable != NULL)
+ {
+ free(pFilteringTable);
+ }
+ return res;
+}
+
+int IPACM_Wan::delete_tcp_fin_rst_exception_rule()
+{
+ int len, res = IPACM_SUCCESS;
+ ipa_ioc_del_flt_rule *pFilteringTable = NULL;
+
+ struct ipa_flt_rule_del flt_rule_entry;
+
+ IPACMDBG_H("deleting MHI TCP FIN RST rule \n");
+ len = sizeof(struct ipa_ioc_del_flt_rule) + (2 * sizeof(struct ipa_flt_rule_del));
+ pFilteringTable = (struct ipa_ioc_del_flt_rule*)malloc(len);
+ if (pFilteringTable == NULL)
+ {
+ IPACMERR("Error Locate ipa_ioc_del_flt_rule memory...\n");
+ return IPACM_FAILURE;
+ }
+ memset(pFilteringTable, 0, len);
+
+ pFilteringTable->commit = 1;
+ pFilteringTable->ip = IPA_IP_v4;
+ pFilteringTable->num_hdls = (uint8_t)2;
+
+ if (tcp_fin_hdl == 0 || tcp_rst_hdl == 0)
+ {
+ IPACMERR("invalid tcp_fin_rst_hdl.\n");
+ res = IPACM_FAILURE;
+ goto fail;
+ }
+
+ memset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_del));
+ flt_rule_entry.hdl = tcp_fin_hdl;
+
+ memcpy(&(pFilteringTable->hdl[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_del));
+
+ flt_rule_entry.hdl = tcp_rst_hdl;
+
+ memcpy(&(pFilteringTable->hdl[1]), &flt_rule_entry, sizeof(struct ipa_flt_rule_del));
+
+ if(false == m_filtering.DelOffloadFilteringRule(pFilteringTable))
+ {
+ IPACMERR("Failed to delete MHI TCP FIN RST rule.\n");
+ res = IPACM_FAILURE;
+ goto fail;
+ }
+ tcp_fin_hdl = 0;
+ tcp_rst_hdl = 0;
+
+fail:
+ if(pFilteringTable != NULL)
+ {
+ free(pFilteringTable);
+ }
+ return res;
+}
diff --git a/ipacm/src/IPACM_Wlan.cpp b/ipacm/src/IPACM_Wlan.cpp
index f86dd1d..395f951 100644
--- a/ipacm/src/IPACM_Wlan.cpp
+++ b/ipacm/src/IPACM_Wlan.cpp
@@ -350,7 +350,7 @@
{
/* handle software routing enable event*/
IPACMDBG_H("IPA_SW_ROUTING_ENABLE for iface: %s \n",IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name);
- handle_software_routing_enable();
+ handle_software_routing_enable(false);
}
}
}
@@ -562,15 +562,19 @@
{
IPACMDBG_H("Received IPA_DOWNSTREAM_ADD event.\n");
#ifdef FEATURE_IPA_ANDROID
- /* indicate v4-offload */
- IPACM_OffloadManager::num_offload_v4_tethered_iface++;
-
- /* xlat not support for 2st tethered iface sky */
- if (IPACM_Wan::isXlat() && (data->prefix.iptype == IPA_IP_v4) && (IPACM_OffloadManager::num_offload_v4_tethered_iface > 1))
+ if (IPACM_Wan::isXlat() && (data->prefix.iptype == IPA_IP_v4))
{
- IPACMDBG_H("Not support 2st downstream iface %s for xlat, cur: %d\n", dev_name,
- IPACM_OffloadManager::num_offload_v4_tethered_iface);
- return;
+ /* indicate v4-offload */
+ IPACM_OffloadManager::num_offload_v4_tethered_iface++;
+ IPACMDBG_H("in xlat: update num_offload_v4_tethered_iface %d\n", IPACM_OffloadManager::num_offload_v4_tethered_iface);
+
+ /* xlat not support for 2st tethered iface */
+ if (IPACM_OffloadManager::num_offload_v4_tethered_iface > 1)
+ {
+ IPACMDBG_H("Not support 2st downstream iface %s for xlat, cur: %d\n", dev_name,
+ IPACM_OffloadManager::num_offload_v4_tethered_iface);
+ return;
+ }
}
IPACMDBG_H(" support downstream iface %s, cur %d\n", dev_name,
@@ -602,6 +606,7 @@
ext_prop = IPACM_Iface::ipacmcfg->GetExtProp(data->prefix.iptype);
if (data->prefix.iptype == IPA_IP_v4)
{
+ IPACMDBG_H("check getXlat_Mux_Id:%d\n", IPACM_Wan::getXlat_Mux_Id());
handle_wan_up_ex(ext_prop, data->prefix.iptype,
IPACM_Wan::getXlat_Mux_Id());
}
@@ -860,13 +865,13 @@
/* handle software routing enable event, iface will update softwarerouting_act to true*/
case IPA_SW_ROUTING_ENABLE:
IPACMDBG_H("Received IPA_SW_ROUTING_ENABLE\n");
- IPACM_Iface::handle_software_routing_enable();
+ IPACM_Iface::handle_software_routing_enable(false);
break;
/* handle software routing disable event, iface will update softwarerouting_act to false*/
case IPA_SW_ROUTING_DISABLE:
IPACMDBG_H("Received IPA_SW_ROUTING_DISABLE\n");
- IPACM_Iface::handle_software_routing_disable();
+ IPACM_Iface::handle_software_routing_disable(false);
break;
case IPA_WLAN_SWITCH_TO_SCC:
@@ -2119,7 +2124,7 @@
if (softwarerouting_act == true && rx_prop != NULL )
{
IPACMDBG_H("Delete sw routing filtering rules\n");
- IPACM_Iface::handle_software_routing_disable();
+ IPACM_Iface::handle_software_routing_disable(false);
}
IPACMDBG_H("finished delete software-routing filtering rules\n ");