diff options
-rw-r--r-- | data-ipa-cfg-mgr/ipacm/inc/IPACM_Config.h | 10 | ||||
-rw-r--r-- | data-ipa-cfg-mgr/ipacm/src/IPACM_CmdQueue.cpp | 11 | ||||
-rw-r--r-- | data-ipa-cfg-mgr/ipacm/src/IPACM_Config.cpp | 55 | ||||
-rw-r--r-- | data-ipa-cfg-mgr/ipacm/src/IPACM_Iface.cpp | 15 | ||||
-rw-r--r-- | data-ipa-cfg-mgr/ipacm/src/IPACM_Lan.cpp | 149 | ||||
-rw-r--r-- | data-ipa-cfg-mgr/ipacm/src/IPACM_OffloadManager.cpp | 51 | ||||
-rw-r--r-- | data-ipa-cfg-mgr/ipacm/src/IPACM_Wan.cpp | 77 | ||||
-rw-r--r-- | data-ipa-cfg-mgr/ipacm/src/IPACM_Wlan.cpp | 6 |
8 files changed, 270 insertions, 104 deletions
diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Config.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Config.h index 1aeeec5..4afff00 100644 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Config.h +++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Config.h @@ -1,5 +1,5 @@ /* -Copyright (c) 2013-2016, The Linux Foundation. All rights reserved. +Copyright (c) 2013-2018, The Linux Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -46,7 +46,9 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. typedef struct { - char iface_name[IPA_IFACE_NAME_LEN]; + char iface_name[IPA_IFACE_NAME_LEN]; + bool v4_up; + bool v6_up; }NatIfaces; /* for IPACM rm dependency use*/ @@ -230,11 +232,11 @@ public: void DelRmDepend(ipa_rm_resource_name rm1); - int AddNatIfaces(char *dev_name); + int AddNatIfaces(char *dev_name, ipa_ip_type ip_type); int DelNatIfaces(char *dev_name); - int CheckNatIfaces(const char *dev_name); + int CheckNatIfaces(const char *dev_name, ipa_ip_type ip_type); inline void SetQmapId(uint8_t id) { diff --git a/data-ipa-cfg-mgr/ipacm/src/IPACM_CmdQueue.cpp b/data-ipa-cfg-mgr/ipacm/src/IPACM_CmdQueue.cpp index c612b7f..812a768 100644 --- a/data-ipa-cfg-mgr/ipacm/src/IPACM_CmdQueue.cpp +++ b/data-ipa-cfg-mgr/ipacm/src/IPACM_CmdQueue.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013-2016, The Linux Foundation. All rights reserved. +Copyright (c) 2013-2018, The Linux Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -123,6 +123,7 @@ void* MessageQueue::Process(void *param) MessageQueue *MsgQueueExternal = NULL; Message *item = NULL; param = NULL; + const char *eventName = NULL; IPACMDBG("MessageQueue::Process()\n"); @@ -154,8 +155,12 @@ void* MessageQueue::Process(void *param) item = MsgQueueExternal->dequeue(); if(item) { - IPACMDBG("Get event %s from external queue.\n", - IPACM_Iface::ipacmcfg->getEventName(item->evt.data.event)); + eventName = IPACM_Iface::ipacmcfg->getEventName(item->evt.data.event); + if (eventName != NULL) + { + IPACMDBG("Get event %s from external queue.\n", + eventName); + } } } else diff --git a/data-ipa-cfg-mgr/ipacm/src/IPACM_Config.cpp b/data-ipa-cfg-mgr/ipacm/src/IPACM_Config.cpp index 9e66367..c46bc71 100644 --- a/data-ipa-cfg-mgr/ipacm/src/IPACM_Config.cpp +++ b/data-ipa-cfg-mgr/ipacm/src/IPACM_Config.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013-2017, The Linux Foundation. All rights reserved. +Copyright (c) 2013-2018, The Linux Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -466,7 +466,7 @@ int IPACM_Config::GetNatIfaces(int nIfaces, NatIfaces *pIfaces) } -int IPACM_Config::AddNatIfaces(char *dev_name) +int IPACM_Config::AddNatIfaces(char *dev_name, ipa_ip_type ip_type) { int i; /* Check if this iface already in NAT-iface*/ @@ -476,7 +476,15 @@ int IPACM_Config::AddNatIfaces(char *dev_name) pNatIfaces[i].iface_name, sizeof(pNatIfaces[i].iface_name)) == 0) { - IPACMDBG("Interface (%s) is add to nat iface already\n", dev_name); + IPACMDBG_H("Interface (%s) is add to nat iface already\n", dev_name); + if (ip_type == IPA_IP_v4) { + pNatIfaces[i].v4_up = true; + IPACMDBG_H("Change v4_up to (%d) \n", pNatIfaces[i].v4_up); + } + if (ip_type == IPA_IP_v6) { + pNatIfaces[i].v6_up = true; + IPACMDBG_H("Change v6_up to (%d) \n", pNatIfaces[i].v6_up); + } return 0; } } @@ -493,8 +501,15 @@ int IPACM_Config::AddNatIfaces(char *dev_name) IPACMDBG_H("Add Nat IfaceName: %s ,update nat-ifaces number: %d\n", pNatIfaces[ipa_nat_iface_entries - 1].iface_name, ipa_nat_iface_entries); + if (ip_type == IPA_IP_v4) { + pNatIfaces[ipa_nat_iface_entries - 1].v4_up = true; + IPACMDBG_H("Change v4_up to (%d) \n", pNatIfaces[ipa_nat_iface_entries - 1].v4_up); + } + if (ip_type == IPA_IP_v6) { + pNatIfaces[ipa_nat_iface_entries - 1].v6_up = true; + IPACMDBG_H("Change v6_up to (%d) \n", pNatIfaces[ipa_nat_iface_entries - 1].v6_up); + } } - return 0; } @@ -513,14 +528,20 @@ int IPACM_Config::DelNatIfaces(char *dev_name) /* Reset the matched entry */ memset(pNatIfaces[i].iface_name, 0, IPA_IFACE_NAME_LEN); + pNatIfaces[i].v4_up = false; + pNatIfaces[i].v6_up = false; for (; i < ipa_nat_iface_entries - 1; i++) { memcpy(pNatIfaces[i].iface_name, pNatIfaces[i + 1].iface_name, IPA_IFACE_NAME_LEN); + pNatIfaces[i].v4_up = pNatIfaces[i + 1].v4_up; + pNatIfaces[i].v6_up = pNatIfaces[i + 1].v6_up; /* Reset the copied entry */ memset(pNatIfaces[i + 1].iface_name, 0, IPA_IFACE_NAME_LEN); + pNatIfaces[i + 1].v4_up = false; + pNatIfaces[i + 1].v6_up = false; } ipa_nat_iface_entries--; IPACMDBG_H("Update nat-ifaces number: %d\n", ipa_nat_iface_entries); @@ -533,23 +554,33 @@ int IPACM_Config::DelNatIfaces(char *dev_name) return 0; } -int IPACM_Config::CheckNatIfaces(const char *dev_name) +int IPACM_Config::CheckNatIfaces(const char *dev_name, ipa_ip_type ip_type) { int i = 0; - IPACMDBG_H("Check iface %s from NAT-ifaces, currently it has %d nat ifaces\n", - dev_name, ipa_nat_iface_entries); + IPACMDBG_H("Check iface %s for ip-type %d from NAT-ifaces, currently it has %d nat ifaces\n", + dev_name, ip_type, ipa_nat_iface_entries); for (i = 0; i < ipa_nat_iface_entries; i++) { if (strcmp(dev_name, pNatIfaces[i].iface_name) == 0) { - IPACMDBG_H("Find Nat IfaceName: %s ,previous nat-ifaces number: %d\n", - pNatIfaces[i].iface_name, ipa_nat_iface_entries); - return 0; + IPACMDBG_H("Find Nat IfaceName: %s ,previous nat-ifaces number: %d, v4_up %d, v6_up %d \n", + pNatIfaces[i].iface_name, ipa_nat_iface_entries, pNatIfaces[i].v4_up, pNatIfaces[i].v6_up); + if (ip_type == IPA_IP_v4 && pNatIfaces[i].v4_up == true) + { + IPACMDBG_H(" v4_up=%d\n", pNatIfaces[i].v4_up); + return 0; + } + if (ip_type == IPA_IP_v6 && pNatIfaces[i].v6_up == true) + { + IPACMDBG_H(" v6_up=%d\n", pNatIfaces[i].v6_up); + return 0; + } + return -1; } } - IPACMDBG_H("Can't find Nat IfaceName: %s with total nat-ifaces number: %d\n", - dev_name, ipa_nat_iface_entries); + IPACMDBG_H("Can't find Nat IfaceName: %s for ip_type %d up with total nat-ifaces number: %d\n", + dev_name, ip_type, ipa_nat_iface_entries); return -1; } diff --git a/data-ipa-cfg-mgr/ipacm/src/IPACM_Iface.cpp b/data-ipa-cfg-mgr/ipacm/src/IPACM_Iface.cpp index 36e2141..db3aa0d 100644 --- a/data-ipa-cfg-mgr/ipacm/src/IPACM_Iface.cpp +++ b/data-ipa-cfg-mgr/ipacm/src/IPACM_Iface.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, The Linux Foundation. All rights reserved. +Copyright (c) 2013-2018, The Linux Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -622,13 +622,6 @@ int IPACM_Iface::query_iface_property(void) } } - /* Add Natting iface to IPACM_Config if there is Rx/Tx property */ - if (rx_prop != NULL || tx_prop != NULL) - { - IPACMDBG_H(" Has rx/tx properties registered for iface %s, add for NATTING \n", dev_name); - IPACM_Iface::ipacmcfg->AddNatIfaces(dev_name); - } - close(fd); return res; } @@ -937,6 +930,12 @@ int IPACM_Iface::init_fl_rule(ipa_ip_type iptype) } } + /* Add Natting iface to IPACM_Config if there is Rx/Tx property */ + if (rx_prop != NULL || tx_prop != NULL) + { + IPACMDBG_H(" Has rx/tx properties registered for iface %s, add for NATTING for ip-family %d \n", dev_name, iptype); + IPACM_Iface::ipacmcfg->AddNatIfaces(dev_name, iptype); + } fail: free(m_pFilteringTable); diff --git a/data-ipa-cfg-mgr/ipacm/src/IPACM_Lan.cpp b/data-ipa-cfg-mgr/ipacm/src/IPACM_Lan.cpp index 7503df1..afb1f0d 100644 --- a/data-ipa-cfg-mgr/ipacm/src/IPACM_Lan.cpp +++ b/data-ipa-cfg-mgr/ipacm/src/IPACM_Lan.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013-2017, The Linux Foundation. All rights reserved. +Copyright (c) 2013-2018, The Linux Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -193,6 +193,14 @@ IPACM_Lan::IPACM_Lan(int iface_index) : IPACM_Iface(iface_index) memset(&prefix, 0, sizeof(prefix)); #ifdef FEATURE_IPACM_HAL + + /* check if Upstream was set before as WIFI with RNDIS case */ + if(ipa_if_cate == LAN_IF && IPACM_Wan::backhaul_is_sta_mode == true) /* STA */ + { + IPACMDBG_H(" Skip the Upstream flag set on LAN instance (%d) with WIFI backhaul (%d)\n", ipa_if_cate, IPACM_Wan::backhaul_is_sta_mode ); /* RNDIS+WIFI not support on msm*/ + return; + } + /* check if Upstream was set before */ if (IPACM_Wan::isWanUP(ipa_if_num)) { @@ -227,6 +235,7 @@ void IPACM_Lan::event_callback(ipa_cm_event_id event, void *param) } int ipa_interface_index; + uint32_t i; ipacm_ext_prop* ext_prop; ipacm_event_iface_up_tehter* data_wan_tether; @@ -261,7 +270,7 @@ void IPACM_Lan::event_callback(ipa_cm_event_id event, void *param) if (rx_prop != NULL || tx_prop != NULL) { IPACMDBG_H(" Has rx/tx properties registered for iface %s, add for NATTING \n", dev_name); - IPACM_Iface::ipacmcfg->AddNatIfaces(dev_name); + IPACM_Iface::ipacmcfg->AddNatIfaces(dev_name, IPA_IP_MAX); } } break; @@ -501,6 +510,45 @@ void IPACM_Lan::event_callback(ipa_cm_event_id event, void *param) IPACMERR("IPA_HANDLE_WAN_UP_TETHER tether_if(%d), not valid (%d) ignore\n", data_wan_tether->if_index_tether, ipa_if_num); return; } +#else /* not offload rndis on WIFI mode on MSM targets sky*/ + if (data_wan_tether->is_sta) + { + IPACMERR("Not support RNDIS offload on WIFI mode, dun install UL filter rules for WIFI mode\n"); + + /* clean rndis header, routing rules */ + IPACMDBG_H("left %d eth clients need to be deleted \n ", num_eth_client); + for (i = 0; i < num_eth_client; i++) + { + /* First reset nat rules and then route rules */ + if(get_client_memptr(eth_client, i)->ipv4_set == true) + { + IPACMDBG_H("Clean Nat Rules for ipv4:0x%x\n", get_client_memptr(eth_client, i)->v4_addr); + CtList->HandleNeighIpAddrDelEvt(get_client_memptr(eth_client, i)->v4_addr); + } + if (delete_eth_rtrules(i, IPA_IP_v4)) + IPACMERR("unbale to delete usb-client v4 route rules for index %d\n", i); + + if (delete_eth_rtrules(i, IPA_IP_v6)) + IPACMERR("unbale to delete ecm-client v6 route rules for index %d\n", i); + + IPACMDBG_H("Delete %d client header\n", num_eth_client); + + if(get_client_memptr(eth_client, i)->ipv4_header_set == true) + { + if (m_header.DeleteHeaderHdl(get_client_memptr(eth_client, i)->hdr_hdl_v4) + == false) + IPACMERR("unbale to delete usb-client v4 header for index %d\n", i); + } + + if(get_client_memptr(eth_client, i)->ipv6_header_set == true) + { + if (m_header.DeleteHeaderHdl(get_client_memptr(eth_client, i)->hdr_hdl_v6) + == false) + IPACMERR("unable to delete usb-client v6 header for index %d\n", i); + } + } /* end of for loop */ + return; + } #endif if (ip_type == IPA_IP_v4 || ip_type == IPA_IP_MAX) { @@ -673,7 +721,7 @@ void IPACM_Lan::event_callback(ipa_cm_event_id event, void *param) if (ipa_interface_index == ipa_if_num) { IPACMDBG_H("Received IPA_DOWNSTREAM_ADD event.\n"); - if (is_downstream_set[data->prefix.iptype] == false) + if (data->prefix.iptype < IPA_IP_MAX && is_downstream_set[data->prefix.iptype] == false) { IPACMDBG_H("Add downstream for IP iptype %d\n", data->prefix.iptype); is_downstream_set[data->prefix.iptype] = true; @@ -832,6 +880,14 @@ void IPACM_Lan::event_callback(ipa_cm_event_id event, void *param) IPACMDBG_H("Recieved IPA_NEIGH_CLIENT_IP_ADDR_ADD_EVENT event \n"); IPACMDBG_H("check iface %s category: %d\n", dev_name, ipa_if_cate); + /* if RNDIS under WIFI mode in MSM, dun add RT rule*/ +#ifdef FEATURE_IPACM_HAL + if(IPACM_Wan::backhaul_is_sta_mode == true) /* WIFI */ + { + IPACMDBG_H(" dun construct header and RT-rules for RNDIS-PC in WIFI mode on MSM targets (STA %d) \n", IPACM_Wan::backhaul_is_sta_mode); + return; + } +#endif if (ipa_interface_index == ipa_if_num && ipa_if_cate == ODU_IF) { IPACMDBG_H("ODU iface got v4-ip \n"); @@ -3194,46 +3250,43 @@ int IPACM_Lan::handle_uplink_filter_rule(ipacm_ext_prop *prop, ipa_ip_type iptyp #ifdef FEATURE_IPACM_HAL /* add prefix equation in modem UL rules */ - if(iptype == IPA_IP_v4) + if(iptype == IPA_IP_v4 && flt_rule_entry.rule.eq_attrib.num_offset_meq_32 < IPA_IPFLTR_NUM_MEQ_32_EQNS) { flt_rule_entry.rule.eq_attrib.num_offset_meq_32++; - if(flt_rule_entry.rule.eq_attrib.num_offset_meq_32 <= IPA_IPFLTR_NUM_MEQ_32_EQNS) - { - eq_index = flt_rule_entry.rule.eq_attrib.num_offset_meq_32 - 1; + eq_index = flt_rule_entry.rule.eq_attrib.num_offset_meq_32 - 1; #ifdef FEATURE_IPA_V3 - if(eq_index == 0) - { - flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<5); - } - else - { - flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<6); - } + if(eq_index == 0) + { + flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<5); + } + else + { + flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<6); + } #else - if(eq_index == 0) - { - flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<2); - } - else - { - flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<3); - } -#endif - flt_rule_entry.rule.eq_attrib.offset_meq_32[eq_index].offset = 12; - flt_rule_entry.rule.eq_attrib.offset_meq_32[eq_index].mask = prefix[IPA_IP_v4].v4Mask; - flt_rule_entry.rule.eq_attrib.offset_meq_32[eq_index].value = prefix[IPA_IP_v4].v4Addr; + if(eq_index == 0) + { + flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<2); } else { - IPACMERR("Run out of MEQ32 equation.\n"); - flt_rule_entry.rule.eq_attrib.num_offset_meq_32--; + flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<3); } +#endif + flt_rule_entry.rule.eq_attrib.offset_meq_32[eq_index].offset = 12; + flt_rule_entry.rule.eq_attrib.offset_meq_32[eq_index].mask = prefix[IPA_IP_v4].v4Mask; + flt_rule_entry.rule.eq_attrib.offset_meq_32[eq_index].value = prefix[IPA_IP_v4].v4Addr; + } + else if (flt_rule_entry.rule.eq_attrib.num_offset_meq_32 > IPA_IPFLTR_NUM_MEQ_32_EQNS) + { + IPACMERR("Run out of MEQ32 equation.\n"); + flt_rule_entry.rule.eq_attrib.num_offset_meq_32--; } else { - flt_rule_entry.rule.eq_attrib.num_offset_meq_128++; - if(flt_rule_entry.rule.eq_attrib.num_offset_meq_128 <= IPA_IPFLTR_NUM_MEQ_128_EQNS) + if (flt_rule_entry.rule.eq_attrib.num_offset_meq_128 < IPA_IPFLTR_NUM_MEQ_128_EQNS) { + flt_rule_entry.rule.eq_attrib.num_offset_meq_128++; eq_index = flt_rule_entry.rule.eq_attrib.num_offset_meq_128 - 1; #ifdef FEATURE_IPA_V3 if(eq_index == 0) @@ -3245,21 +3298,21 @@ int IPACM_Lan::handle_uplink_filter_rule(ipacm_ext_prop *prop, ipa_ip_type iptyp flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<4); } *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].mask + 0) - = prefix[IPA_IP_v6].v6Mask[3]; + = prefix[IPA_IP_v6].v6Mask[3]; *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].mask + 4) - = prefix[IPA_IP_v6].v6Mask[2]; + = prefix[IPA_IP_v6].v6Mask[2]; *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].mask + 8) - = prefix[IPA_IP_v6].v6Mask[1]; + = prefix[IPA_IP_v6].v6Mask[1]; *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].mask + 12) - = prefix[IPA_IP_v6].v6Mask[0]; + = prefix[IPA_IP_v6].v6Mask[0]; *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].value + 0) - = prefix[IPA_IP_v6].v6Addr[3]; + = prefix[IPA_IP_v6].v6Addr[3]; *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].value + 4) - = prefix[IPA_IP_v6].v6Addr[2]; + = prefix[IPA_IP_v6].v6Addr[2]; *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].value + 8) - = prefix[IPA_IP_v6].v6Addr[1]; + = prefix[IPA_IP_v6].v6Addr[1]; *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].value + 12) - = prefix[IPA_IP_v6].v6Addr[0]; + = prefix[IPA_IP_v6].v6Addr[0]; #else if(eq_index == 0) { @@ -3270,24 +3323,24 @@ int IPACM_Lan::handle_uplink_filter_rule(ipacm_ext_prop *prop, ipa_ip_type iptyp flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<10); } *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].mask + 0) - = prefix[IPA_IP_v6].v6Mask[0]; + = prefix[IPA_IP_v6].v6Mask[0]; *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].mask + 4) - = prefix[IPA_IP_v6].v6Mask[1]; + = prefix[IPA_IP_v6].v6Mask[1]; *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].mask + 8) - = prefix[IPA_IP_v6].v6Mask[2]; + = prefix[IPA_IP_v6].v6Mask[2]; *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].mask + 12) - = prefix[IPA_IP_v6].v6Mask[3]; + = prefix[IPA_IP_v6].v6Mask[3]; *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].value + 0) - = prefix[IPA_IP_v6].v6Addr[0]; + = prefix[IPA_IP_v6].v6Addr[0]; *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].value + 4) - = prefix[IPA_IP_v6].v6Addr[1]; + = prefix[IPA_IP_v6].v6Addr[1]; *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].value + 8) - = prefix[IPA_IP_v6].v6Addr[2]; + = prefix[IPA_IP_v6].v6Addr[2]; *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].value + 12) - = prefix[IPA_IP_v6].v6Addr[3]; + = prefix[IPA_IP_v6].v6Addr[3]; #endif flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].offset = 8; - } + } else { IPACMERR("Run out of MEQ128 equation.\n"); diff --git a/data-ipa-cfg-mgr/ipacm/src/IPACM_OffloadManager.cpp b/data-ipa-cfg-mgr/ipacm/src/IPACM_OffloadManager.cpp index 977b9b1..93a7dd4 100644 --- a/data-ipa-cfg-mgr/ipacm/src/IPACM_OffloadManager.cpp +++ b/data-ipa-cfg-mgr/ipacm/src/IPACM_OffloadManager.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2017, The Linux Foundation. All rights reserved. +Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -196,6 +196,7 @@ RET IPACM_OffloadManager::addDownstream(const char * downstream_name, const Pref int index; ipacm_cmd_q_data evt; ipacm_event_ipahal_stream *evt_data; + bool cache_need = false; IPACMDBG_H("addDownstream name(%s), ip-family(%d) \n", downstream_name, prefix.fam); @@ -222,8 +223,13 @@ RET IPACM_OffloadManager::addDownstream(const char * downstream_name, const Pref IPACMDBG_H("add iface(%s) to list\n", downstream_name); } - /* check if downstream netdev driver finished its configuration on IPA-HW */ - if (IPACM_Iface::ipacmcfg->CheckNatIfaces(downstream_name)) + /* check if upstream netdev driver finished its configuration on IPA-HW for ipv4 and ipv6 */ + if (prefix.fam == V4 && IPACM_Iface::ipacmcfg->CheckNatIfaces(downstream_name, IPA_IP_v4)) + cache_need = true; + if (prefix.fam == V6 && IPACM_Iface::ipacmcfg->CheckNatIfaces(downstream_name, IPA_IP_v6)) + cache_need = true; + + if (cache_need) { IPACMDBG_H("addDownstream name(%s) currently not support in ipa \n", downstream_name); /* copy to the cache */ @@ -342,6 +348,7 @@ RET IPACM_OffloadManager::setUpstream(const char *upstream_name, const Prefix& g { int index; RET result = SUCCESS; + bool cache_need = false; /* if interface name is NULL, default route is removed */ if(upstream_name != NULL) @@ -379,8 +386,13 @@ RET IPACM_OffloadManager::setUpstream(const char *upstream_name, const Prefix& g return FAIL_INPUT_CHECK; } - /* check if downstream netdev driver finished its configuration on IPA-HW */ - if (IPACM_Iface::ipacmcfg->CheckNatIfaces(upstream_name)) + /* check if upstream netdev driver finished its configuration on IPA-HW for ipv4 and ipv6 */ + if (gw_addr_v4.fam == V4 && IPACM_Iface::ipacmcfg->CheckNatIfaces(upstream_name, IPA_IP_v4)) + cache_need = true; + if (gw_addr_v6.fam == V6 && IPACM_Iface::ipacmcfg->CheckNatIfaces(upstream_name, IPA_IP_v6)) + cache_need = true; + + if (cache_need) { IPACMDBG_H("setUpstream name(%s) currently not support in ipa \n", upstream_name); /* copy to the cache */ @@ -395,7 +407,7 @@ RET IPACM_OffloadManager::setUpstream(const char *upstream_name, const Prefix& g memcpy(&event_cache[latest_cache_index].prefix_cache, &gw_addr_v4, sizeof(event_cache[latest_cache_index].prefix_cache)); memcpy(&event_cache[latest_cache_index].prefix_cache_v6, &gw_addr_v6, sizeof(event_cache[latest_cache_index].prefix_cache_v6)); if (gw_addr_v4.fam == V4) { - IPACMDBG_H("cache event(%d) ipv4 fateway: (%x) dev(%s) on entry (%d)\n", + IPACMDBG_H("cache event(%d) ipv4 gateway: (%x) dev(%s) on entry (%d)\n", event_cache[latest_cache_index].event, event_cache[latest_cache_index].prefix_cache.v4Addr, event_cache[latest_cache_index].dev_name, @@ -648,9 +660,16 @@ int IPACM_OffloadManager::post_route_evt(enum ipa_ip_type iptype, int index, ipa IPACMDBG_H("IPV6 gateway: %08x:%08x:%08x:%08x \n", evt_data_route->ipv6_addr_gw[0], evt_data_route->ipv6_addr_gw[1], evt_data_route->ipv6_addr_gw[2], evt_data_route->ipv6_addr_gw[3]); #endif - IPACMDBG_H("Received WAN_UPSTREAM_ROUTE_ADD: fid(%d) tether_fid(%d) ip-type(%d)\n", evt_data_route->if_index, + if (event == WAN_UPSTREAM_ROUTE_ADD) + { + IPACMDBG_H("Received WAN_UPSTREAM_ROUTE_ADD: fid(%d) tether_fid(%d) ip-type(%d)\n", evt_data_route->if_index, evt_data_route->if_index_tether, evt_data_route->iptype); - + } + else if (event == WAN_UPSTREAM_ROUTE_DEL) + { + IPACMDBG_H("Received WAN_UPSTREAM_ROUTE_DEL: fid(%d) tether_fid(%d) ip-type(%d)\n", evt_data_route->if_index, + evt_data_route->if_index_tether, evt_data_route->iptype); + } memset(&evt, 0, sizeof(evt)); evt.evt_data = (void*)evt_data_route; evt.event = event; @@ -700,27 +719,25 @@ int IPACM_OffloadManager::resetTetherStats(const char * upstream_name /* upstrea wan_ioctl_reset_tether_stats stats; if ((fd = open(DEVICE_NAME, O_RDWR)) < 0) { - IPACMERR("Failed opening %s.\n", DEVICE_NAME); - return FAIL_HARDWARE; - } - - memset(stats.upstreamIface, 0, IFNAMSIZ); - if (strlcpy(stats.upstreamIface, upstream_name, IFNAMSIZ) >= IFNAMSIZ) { + IPACMERR("Failed opening %s.\n", DEVICE_NAME); + return FAIL_HARDWARE; + } + memset(stats.upstreamIface, 0, IFNAMSIZ); + if (strlcpy(stats.upstreamIface, upstream_name, IFNAMSIZ) >= IFNAMSIZ) { IPACMERR("String truncation occurred on upstream\n"); close(fd); return FAIL_INPUT_CHECK; } stats.reset_stats = true; - if (ioctl(fd, WAN_IOC_RESET_TETHER_STATS, &stats) < 0) { - IPACMERR("IOCTL WAN_IOC_RESET_TETHER_STATS call failed: %s", strerror(errno)); + IPACMERR("IOCTL WAN_IOC_RESET_TETHER_STATS call failed: %s", strerror(errno)); close(fd); return FAIL_HARDWARE; } IPACMDBG_H("Reset Interface %s stats\n", upstream_name); close(fd); return IPACM_SUCCESS; -} + } IPACM_OffloadManager* IPACM_OffloadManager::GetInstance() { diff --git a/data-ipa-cfg-mgr/ipacm/src/IPACM_Wan.cpp b/data-ipa-cfg-mgr/ipacm/src/IPACM_Wan.cpp index 749e09c..e8610b2 100644 --- a/data-ipa-cfg-mgr/ipacm/src/IPACM_Wan.cpp +++ b/data-ipa-cfg-mgr/ipacm/src/IPACM_Wan.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013, The Linux Foundation. All rights reserved. +Copyright (c) 2013-2018, The Linux Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -509,12 +509,12 @@ int IPACM_Wan::handle_addr_evt(ipacm_event_data_addr *data) } #ifdef FEATURE_IPACM_HAL - /* check if having pending add_downstream cache*/ + /* check if having pending set_upstream cache*/ OffloadMng = IPACM_OffloadManager::GetInstance(); if (OffloadMng == NULL) { IPACMERR("failed to get IPACM_OffloadManager instance !\n"); } else { - IPACMDBG_H(" check iface %s if having add_downstream cache events\n", dev_name); + IPACMDBG_H(" check iface %s if having set_upstream cache events\n", dev_name); OffloadMng->search_framwork_cache(dev_name); } #endif @@ -3202,6 +3202,12 @@ int IPACM_Wan::init_fl_rule_ex(ipa_ip_type iptype) } install_wan_filtering_rule(false); + /* Add Natting iface to IPACM_Config if there is Rx/Tx property */ + if (rx_prop != NULL || tx_prop != NULL) + { + IPACMDBG_H(" Has rx/tx properties registered for iface %s, add for NATTING \n", dev_name); + IPACM_Iface::ipacmcfg->AddNatIfaces(dev_name, iptype); + } fail: return res; } @@ -4357,7 +4363,11 @@ int IPACM_Wan::config_dft_embms_rules(ipa_ioc_add_flt_rule *pFilteringTable_v4, int IPACM_Wan::handle_down_evt() { int res = IPACM_SUCCESS; - uint32_t i; + uint32_t i, tether_total; + int ipa_if_num_tether_tmp[IPA_MAX_IFACE_ENTRIES]; + + tether_total = 0; + memset(ipa_if_num_tether_tmp, 0, IPA_MAX_IFACE_ENTRIES); IPACMDBG_H(" wan handle_down_evt \n"); @@ -4378,22 +4388,61 @@ int IPACM_Wan::handle_down_evt() /* make sure default routing rules and firewall rules are deleted*/ if (active_v4) { - if (rx_prop != NULL) - { + if (rx_prop != NULL) + { del_dft_firewall_rules(IPA_IP_v4); } handle_route_del_evt(IPA_IP_v4); IPACMDBG_H("Delete default v4 routing rules\n"); + +#ifdef FEATURE_IPA_ANDROID + /* posting wan_down_tether for lan clients */ +#ifdef FEATURE_IPACM_HAL + IPACMDBG_H("Posting IPA_WAN_DOWN_TETHER_EVENT for IPV4\n"); + post_wan_down_tether_evt(IPA_IP_v4, 0); +#else + for (i=0; i < IPACM_Wan::ipa_if_num_tether_v4_total; i++) + { + ipa_if_num_tether_tmp[i] = IPACM_Wan::ipa_if_num_tether_v4[i]; + } + tether_total = IPACM_Wan::ipa_if_num_tether_v4_total; + for (i=0; i < tether_total; i++) + { + post_wan_down_tether_evt(IPA_IP_v4, ipa_if_num_tether_tmp[i]); + IPACMDBG_H("post_wan_down_tether_v4 iface(%d: %s)\n", + i, IPACM_Iface::ipacmcfg->iface_table[ipa_if_num_tether_tmp[i]].iface_name); + } +#endif +#endif } if (active_v6) { - if (rx_prop != NULL) - { + if (rx_prop != NULL) + { del_dft_firewall_rules(IPA_IP_v6); } handle_route_del_evt(IPA_IP_v6); IPACMDBG_H("Delete default v6 routing rules\n"); +#ifdef FEATURE_IPA_ANDROID + /* posting wan_down_tether for lan clients */ +#ifdef FEATURE_IPACM_HAL + IPACMDBG_H("Posting IPA_WAN_DOWN_TETHER_EVENT for IPV6\n"); + post_wan_down_tether_evt(IPA_IP_v6, 0); +#else + for (i=0; i < IPACM_Wan::ipa_if_num_tether_v6_total; i++) + { + ipa_if_num_tether_tmp[i] = IPACM_Wan::ipa_if_num_tether_v6[i]; + } + tether_total = IPACM_Wan::ipa_if_num_tether_v6_total; + for (i=0; i < tether_total; i++) + { + post_wan_down_tether_evt(IPA_IP_v6, ipa_if_num_tether_tmp[i]); + IPACMDBG_H("post_wan_down_tether_v6 iface(%d: %s)\n", + i, IPACM_Iface::ipacmcfg->iface_table[ipa_if_num_tether_tmp[i]].iface_name); + } +#endif +#endif } /* Delete default v4 RT rule */ @@ -4402,7 +4451,7 @@ int IPACM_Wan::handle_down_evt() IPACMDBG_H("Delete default v4 routing rules\n"); if (m_routing.DeleteRoutingHdl(dft_rt_rule_hdl[0], IPA_IP_v4) == false) { - IPACMERR("Routing rule deletion failed!\n"); + IPACMERR("Routing rule deletion failed!\n"); res = IPACM_FAILURE; goto fail; } @@ -4737,6 +4786,10 @@ int IPACM_Wan::handle_down_evt_ex() handle_route_del_evt_ex(IPA_IP_v4); #ifdef FEATURE_IPA_ANDROID /* posting wan_down_tether for all lan clients */ +#ifdef FEATURE_IPACM_HAL + IPACMDBG_H("Posting IPA_WAN_DOWN_TETHER_EVENT for IPV4\n"); + post_wan_down_tether_evt(IPA_IP_v4, 0); +#else for (i=0; i < IPACM_Wan::ipa_if_num_tether_v4_total; i++) { ipa_if_num_tether_tmp[i] = IPACM_Wan::ipa_if_num_tether_v4[i]; @@ -4749,11 +4802,16 @@ int IPACM_Wan::handle_down_evt_ex() i, IPACM_Iface::ipacmcfg->iface_table[ipa_if_num_tether_tmp[i]].iface_name); } #endif +#endif IPACM_Wan::wan_up_v6 = false; del_wan_firewall_rule(IPA_IP_v6); handle_route_del_evt_ex(IPA_IP_v6); #ifdef FEATURE_IPA_ANDROID /* posting wan_down_tether for all lan clients */ +#ifdef FEATURE_IPACM_HAL + IPACMDBG_H("Posting IPA_WAN_DOWN_TETHER_EVENT for IPV6\n"); + post_wan_down_tether_evt(IPA_IP_v6, 0); +#else for (i=0; i < IPACM_Wan::ipa_if_num_tether_v6_total; i++) { ipa_if_num_tether_tmp[i] = IPACM_Wan::ipa_if_num_tether_v6[i]; @@ -4766,6 +4824,7 @@ int IPACM_Wan::handle_down_evt_ex() i, IPACM_Iface::ipacmcfg->iface_table[ipa_if_num_tether_tmp[i]].iface_name); } #endif +#endif memset(IPACM_Wan::wan_up_dev_name, 0, sizeof(IPACM_Wan::wan_up_dev_name)); install_wan_filtering_rule(false); diff --git a/data-ipa-cfg-mgr/ipacm/src/IPACM_Wlan.cpp b/data-ipa-cfg-mgr/ipacm/src/IPACM_Wlan.cpp index c912a6e..307a788 100644 --- a/data-ipa-cfg-mgr/ipacm/src/IPACM_Wlan.cpp +++ b/data-ipa-cfg-mgr/ipacm/src/IPACM_Wlan.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013-2017, The Linux Foundation. All rights reserved. +Copyright (c) 2013-2018, The Linux Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -524,7 +524,7 @@ void IPACM_Wlan::event_callback(ipa_cm_event_id event, void *param) if(ipa_interface_index == ipa_if_num) { IPACMDBG_H("Received IPA_DOWNSTREAM_ADD event.\n"); - if(is_downstream_set[data->prefix.iptype] == false) + if(data->prefix.iptype < IPA_IP_MAX && is_downstream_set[data->prefix.iptype] == false) { IPACMDBG_H("Add downstream for IP iptype %d.\n", data->prefix.iptype); is_downstream_set[data->prefix.iptype] = true; @@ -856,7 +856,7 @@ void IPACM_Wlan::event_callback(ipa_cm_event_id event, void *param) if (rx_prop != NULL || tx_prop != NULL) { IPACMDBG_H(" Has rx/tx properties registered for iface %s, add for NATTING \n", dev_name); - IPACM_Iface::ipacmcfg->AddNatIfaces(dev_name); + IPACM_Iface::ipacmcfg->AddNatIfaces(dev_name, IPA_IP_MAX); } if (m_is_guest_ap == true && (IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].wlan_mode == FULL)) |