Merge "ipacm: Fix to add dummy NAT entries for tunneled connections"
diff --git a/ipacm/inc/IPACM_Defs.h b/ipacm/inc/IPACM_Defs.h
index e60516e..82e9c6b 100644
--- a/ipacm/inc/IPACM_Defs.h
+++ b/ipacm/inc/IPACM_Defs.h
@@ -193,6 +193,10 @@
IPA_ETH_BRIDGE_WLAN_SCC_MCC_SWITCH, /* ipacm_event_eth_bridge*/
IPA_SSR_NOTICE, /* NULL*/
IPA_COALESCE_NOTICE, /* NULL*/
+#ifdef IPA_MTU_EVENT_MAX
+ IPA_MTU_SET, /* ipa_mtu_info */
+ IPA_MTU_UPDATE, /* ipacm_event_mtu_info */
+#endif
#ifdef FEATURE_L2TP
IPA_ADD_VLAN_IFACE, /* ipa_ioc_vlan_iface_info */
IPA_DEL_VLAN_IFACE, /* ipa_ioc_vlan_iface_info */
@@ -407,4 +411,11 @@
_ipacm_offload_prefix prefix;
} ipacm_event_ipahal_stream;
+#ifdef IPA_MTU_EVENT_MAX
+typedef struct _ipacm_event_mtu_info
+{
+ int if_index;
+ ipa_mtu_info mtu_info;
+} ipacm_event_mtu_info;
+#endif
#endif /* IPA_CM_DEFS_H */
diff --git a/ipacm/inc/IPACM_Lan.h b/ipacm/inc/IPACM_Lan.h
index 605edb5..de64be1 100644
--- a/ipacm/inc/IPACM_Lan.h
+++ b/ipacm/inc/IPACM_Lan.h
@@ -230,6 +230,8 @@
int reset_to_dummy_flt_rule(ipa_ip_type iptype, uint32_t rule_hdl);
+ virtual int modify_ipv6_prefix_flt_rule(uint32_t* prefix);
+
virtual int install_ipv6_prefix_flt_rule(uint32_t* prefix);
virtual void delete_ipv6_prefix_flt_rule();
diff --git a/ipacm/inc/IPACM_Wan.h b/ipacm/inc/IPACM_Wan.h
index ad62783..9460938 100644
--- a/ipacm/inc/IPACM_Wan.h
+++ b/ipacm/inc/IPACM_Wan.h
@@ -63,6 +63,7 @@
#define NETWORK_STATS "%s %llu %llu %llu %llu"
#define IPA_NETWORK_STATS_FILE_NAME "/data/misc/ipa/network_stats"
+#define IPA_OFFLOAD_TETHER_STATE_FILE_NAME "/data/vendor/ipa/offload_state"
typedef struct _wan_client_rt_hdl
{
@@ -105,8 +106,10 @@
static bool wan_up;
static bool wan_up_v6;
static uint8_t xlat_mux_id;
- static uint16_t mtu_default_wan;
- uint16_t mtu_size;
+
+ static uint16_t mtu_default_wan_v4;
+ static uint16_t mtu_default_wan_v6;
+
/* IPACM interface name */
static char wan_up_dev_name[IF_NAME_LEN];
static uint32_t curr_wan_ip;
@@ -145,15 +148,14 @@
{
if (isWanUP(ipa_if_num_tether))
{
- return mtu_default_wan;
+ return mtu_default_wan_v4;
}
}
else if (iptype == IPA_IP_v6)
{
if (isWanUP_V6(ipa_if_num_tether))
{
- return mtu_default_wan;
-
+ return mtu_default_wan_v6;
}
}
return DEFAULT_MTU_SIZE;
@@ -405,6 +407,14 @@
/* handle for TCP RST rule */
uint32_t tcp_rst_hdl;
+ /* V4 MTU value. */
+ uint16_t mtu_v4;
+ bool mtu_v4_set;
+
+ /* V6 MTU value. */
+ uint16_t mtu_v6;
+ bool mtu_v6_set;
+
inline ipa_wan_client* get_client_memptr(ipa_wan_client *param, int cnt)
{
char *ret = ((char *)param) + (wan_client_len * cnt);
@@ -583,10 +593,13 @@
return IPACM_SUCCESS;
}
- int handle_wan_hdr_init(uint8_t *mac_addr);
+ int handle_wan_hdr_init(uint8_t *mac_addr, bool replaced = false, int entry = 0);
int handle_wan_client_ipaddr(ipacm_event_data_all *data);
int handle_wan_client_route_rule(uint8_t *mac_addr, ipa_ip_type iptype);
+ /* handle_gw_mac_renew, index_client valiud is success */
+ int handle_gw_mac_renew(ipacm_event_data_all *data, int index_client);
+
/* handle new_address event */
int handle_addr_evt(ipacm_event_data_addr *data);
@@ -594,10 +607,10 @@
int handle_addr_evt_mhi_q6(ipacm_event_data_addr *data);
/* wan default route/filter rule configuration */
- int handle_route_add_evt(ipa_ip_type iptype);
+ int handle_route_add_evt(ipa_ip_type iptype, bool add_only = false);
/* construct complete STA ethernet header */
- int handle_sta_header_add_evt();
+ int handle_sta_header_add_evt(bool renew = false);
bool check_dft_firewall_rules_attr_mask(IPACM_firewall_conf_t *firewall_config);
@@ -612,7 +625,7 @@
/* configure the initial firewall filter rules */
int config_dft_embms_rules(ipa_ioc_add_flt_rule *pFilteringTable_v4, ipa_ioc_add_flt_rule *pFilteringTable_v6);
- int handle_route_del_evt(ipa_ip_type iptype);
+ int handle_route_del_evt(ipa_ip_type iptype, bool delete_only = false);
int del_dft_firewall_rules(ipa_ip_type iptype);
@@ -674,7 +687,7 @@
int delete_tcp_fin_rst_exception_rule();
- /* Query mtu size */
+ /* MTU helper functions */
int query_mtu_size();
};
diff --git a/ipacm/src/IPACM_Config.cpp b/ipacm/src/IPACM_Config.cpp
index c396c6c..d0c33e9 100644
--- a/ipacm/src/IPACM_Config.cpp
+++ b/ipacm/src/IPACM_Config.cpp
@@ -106,7 +106,12 @@
__stringify(IPA_ETH_BRIDGE_CLIENT_ADD), /* ipacm_event_eth_bridge*/
__stringify(IPA_ETH_BRIDGE_CLIENT_DEL), /* ipacm_event_eth_bridge*/
__stringify(IPA_ETH_BRIDGE_WLAN_SCC_MCC_SWITCH), /* ipacm_event_eth_bridge*/
- __stringify(IPA_SSR_NOTICE) /* NULL*/
+ __stringify(IPA_SSR_NOTICE), /* NULL*/
+ __stringify(IPA_COALESCE_NOTICE), /* NULL*/
+#ifdef IPA_MTU_EVENT_MAX
+ __stringify(IPA_MTU_SET), /* ipa_mtu_info */
+ __stringify(IPA_MTU_UPDATE), /* ipacm_event_mtu_info */
+#endif
#ifdef FEATURE_L2TP
__stringify(IPA_ADD_VLAN_IFACE), /* ipa_ioc_vlan_iface_info */
__stringify(IPA_DEL_VLAN_IFACE), /* ipa_ioc_vlan_iface_info */
diff --git a/ipacm/src/IPACM_Iface.cpp b/ipacm/src/IPACM_Iface.cpp
index 8282915..55cf71d 100644
--- a/ipacm/src/IPACM_Iface.cpp
+++ b/ipacm/src/IPACM_Iface.cpp
@@ -1009,7 +1009,7 @@
return res;
}
-/* get ipa interface name */
+/* get ipa interface index from name */
int IPACM_Iface::ipa_get_if_index
(
char * if_name,
diff --git a/ipacm/src/IPACM_IfaceManager.cpp b/ipacm/src/IPACM_IfaceManager.cpp
index 7ba5a80..1392a1a 100644
--- a/ipacm/src/IPACM_IfaceManager.cpp
+++ b/ipacm/src/IPACM_IfaceManager.cpp
@@ -291,6 +291,9 @@
IPACM_EvtDispatcher::registr(IPA_TETHERING_STATS_UPDATE_EVENT, lan);
#endif
IPACM_EvtDispatcher::registr(IPA_CRADLE_WAN_MODE_SWITCH, lan);
+#ifdef IPA_MTU_EVENT_MAX
+ IPACM_EvtDispatcher::registr(IPA_MTU_UPDATE, lan);
+#endif
IPACM_EvtDispatcher::registr(IPA_LINK_DOWN_EVENT, lan);
/* IPA_LAN_DELETE_SELF should be always last */
IPACM_EvtDispatcher::registr(IPA_LAN_DELETE_SELF, lan);
@@ -420,6 +423,9 @@
IPACM_EvtDispatcher::registr(IPA_WLAN_FWR_SSR_BEFORE_SHUTDOWN_NOTICE, wl);
#endif
IPACM_EvtDispatcher::registr(IPA_WIGIG_CLIENT_ADD_EVENT, wl);
+#ifdef IPA_MTU_EVENT_MAX
+ IPACM_EvtDispatcher::registr(IPA_MTU_UPDATE, wl);
+#endif
/* IPA_LAN_DELETE_SELF should be always last */
IPACM_EvtDispatcher::registr(IPA_LAN_DELETE_SELF, wl);
IPACMDBG_H("ipa_WLAN (%s):ipa_index (%d) instance open/registr ok\n", wl->dev_name, wl->ipa_if_num);
@@ -464,6 +470,9 @@
if(is_sta_mode == Q6_WAN)
{
IPACM_EvtDispatcher::registr(IPA_NETWORK_STATS_UPDATE_EVENT, w);
+#ifdef IPA_MTU_EVENT_MAX
+ IPACM_EvtDispatcher::registr(IPA_MTU_SET, w);
+#endif
};
#else/* defined(FEATURE_IPA_ANDROID) */
IPACM_EvtDispatcher::registr(IPA_ROUTE_ADD_EVENT, w);
diff --git a/ipacm/src/IPACM_Lan.cpp b/ipacm/src/IPACM_Lan.cpp
index 7e7e875..c97168d 100644
--- a/ipacm/src/IPACM_Lan.cpp
+++ b/ipacm/src/IPACM_Lan.cpp
@@ -1110,6 +1110,36 @@
}
break;
+#ifdef IPA_MTU_EVENT_MAX
+ case IPA_MTU_UPDATE:
+ {
+ IPACMDBG_H("Received IPA_MTU_UPDATE");
+ ipacm_event_mtu_info *evt_data = (ipacm_event_mtu_info *)param;
+ ipa_mtu_info *data = &(evt_data->mtu_info);
+
+ /* IPA_IP_MAX means both ipv4 and ipv6 */
+ if ((data->ip_type == IPA_IP_v4 || data->ip_type == IPA_IP_MAX) && IPACM_Wan::isWanUP(ipa_if_num))
+ {
+ handle_private_subnet_android(IPA_IP_v4);
+ }
+
+ /* IPA_IP_MAX means both ipv4 and ipv6 */
+ if ((data->ip_type == IPA_IP_v6 || data->ip_type == IPA_IP_MAX) && IPACM_Wan::isWanUP_V6(ipa_if_num))
+ {
+ /* check if the prefix + MTU rules are installed */
+ if (ipv6_prefix_flt_rule_hdl[0] && ipv6_prefix_flt_rule_hdl[1])
+ {
+ modify_ipv6_prefix_flt_rule(IPACM_Wan::backhaul_ipv6_prefix);
+ }
+ else
+ {
+ IPACMERR("Failed to update prefix MTU rules, no prefix rules set");
+ }
+ }
+ }
+ break;
+#endif
+
default:
break;
}
@@ -1641,9 +1671,9 @@
/* Update ipv6 MTU here if WAN_v6 is up and filter rules were installed */
if (IPACM_Wan::isWanUP_V6(ipa_if_num))
{
- if (ipv6_prefix_flt_rule_hdl[0] && ipv6_prefix_flt_rule_hdl[1] ) {
- delete_ipv6_prefix_flt_rule();
- install_ipv6_prefix_flt_rule(IPACM_Wan::backhaul_ipv6_prefix);
+ if (ipv6_prefix_flt_rule_hdl[0] && ipv6_prefix_flt_rule_hdl[1])
+ {
+ modify_ipv6_prefix_flt_rule(IPACM_Wan::backhaul_ipv6_prefix);
}
}
@@ -1912,9 +1942,9 @@
/* Update ipv6 MTU here if WAN_v6 is up and filter rules were installed */
if (IPACM_Wan::isWanUP_V6(ipa_if_num))
{
- if (ipv6_prefix_flt_rule_hdl[0] && ipv6_prefix_flt_rule_hdl[1] ) {
- delete_ipv6_prefix_flt_rule();
- install_ipv6_prefix_flt_rule(IPACM_Wan::backhaul_ipv6_prefix);
+ if (ipv6_prefix_flt_rule_hdl[0] && ipv6_prefix_flt_rule_hdl[1])
+ {
+ modify_ipv6_prefix_flt_rule(IPACM_Wan::backhaul_ipv6_prefix);
}
}
@@ -4212,7 +4242,7 @@
}
else
{
- IPACMERR("MTU is 0");
+ IPACMDBG_H("MTU is zero\n");
}
}
IPACMDBG_H("total %d MTU rules are needed\n", mtu_rule_cnt);
@@ -4293,8 +4323,13 @@
return res;
}
-int IPACM_Lan::install_ipv6_prefix_flt_rule(uint32_t* prefix)
+int IPACM_Lan::modify_ipv6_prefix_flt_rule(uint32_t* prefix)
{
+ int len, res = IPACM_SUCCESS;
+ struct ipa_flt_rule_mdfy flt_rule_entry;
+ struct ipa_ioc_mdfy_flt_rule* flt_rule;
+ int rule_cnt = 1;
+
if(prefix == NULL)
{
IPACMERR("IPv6 prefix is empty.\n");
@@ -4302,12 +4337,114 @@
}
IPACMDBG_H("Receive IPv6 prefix: 0x%08x%08x.\n", prefix[0], prefix[1]);
+ uint16_t mtu = IPACM_Wan::queryMTU(ipa_if_num, IPA_IP_v6);
+ if (mtu > 0)
+ {
+ IPACMDBG_H("MTU is %d\n", mtu);
+ rule_cnt ++;
+ }
+ else
+ {
+ IPACMERR("MTU is 0");
+ }
+
+
+ if(rx_prop == NULL)
+ {
+ IPACMERR("no rx props\n");
+ return IPACM_FAILURE;
+ }
+
+ len = sizeof(struct ipa_ioc_mdfy_flt_rule) + rule_cnt * sizeof(struct ipa_flt_rule_mdfy);
+ flt_rule = (struct ipa_ioc_mdfy_flt_rule*)malloc(len);
+ if(!flt_rule)
+ {
+ IPACMERR("Failed to allocate ipa_ioc_mdfy_flt_rule memory...\n");
+ return IPACM_FAILURE;
+ }
+ memset(flt_rule, 0, len);
+
+ flt_rule->commit = 1;
+ flt_rule->ip = IPA_IP_v6;
+ flt_rule->num_rules = rule_cnt;
+
+ memset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_mdfy));
+ flt_rule_entry.status = -1;
+ flt_rule_entry.rule.retain_hdr = 1;
+ flt_rule_entry.rule.to_uc = 0;
+ flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;
+ flt_rule_entry.rule.eq_attrib_type = 0;
+ flt_rule_entry.rule_hdl = ipv6_prefix_flt_rule_hdl[0];
+
+ 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_DST_ADDR;
+ flt_rule_entry.rule.attrib.u.v6.dst_addr[0] = prefix[0];
+ flt_rule_entry.rule.attrib.u.v6.dst_addr[1] = prefix[1];
+ flt_rule_entry.rule.attrib.u.v6.dst_addr[2] = 0x0;
+ flt_rule_entry.rule.attrib.u.v6.dst_addr[3] = 0x0;
+ flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF;
+ flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF;
+ flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[2] = 0x0;
+ flt_rule_entry.rule.attrib.u.v6.dst_addr_mask[3] = 0x0;
+ memcpy(&(flt_rule->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_mdfy));
+
+
+ flt_rule_entry.rule_hdl = ipv6_prefix_flt_rule_hdl[1];
+ memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule_entry.rule.attrib)); // this will remove the IPA_FLT_DST_ADDR
+ flt_rule_entry.rule.attrib.u.v6.src_addr[3] = prefix[0];
+ flt_rule_entry.rule.attrib.u.v6.src_addr[2] = prefix[1];
+ flt_rule_entry.rule.attrib.u.v6.src_addr[1] = 0x0;
+ flt_rule_entry.rule.attrib.u.v6.src_addr[0] = 0x0;
+ flt_rule_entry.rule.attrib.u.v6.src_addr_mask[3] = 0xFFFFFFFF;
+ flt_rule_entry.rule.attrib.u.v6.src_addr_mask[2] = 0xFFFFFFFF;
+ flt_rule_entry.rule.attrib.u.v6.src_addr_mask[1] = 0x0;
+ flt_rule_entry.rule.attrib.u.v6.src_addr_mask[0] = 0x0;
+ flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_SRC_ADDR;
+
+ /* Add an MTU rule with every new private prefix */
+ if (mtu > 0)
+ {
+ if (construct_mtu_rule(&flt_rule_entry.rule, IPA_IP_v6, mtu))
+ {
+ IPACMERR("Failed to add MTU filtering rule.\n")
+ }
+ else
+ {
+ memcpy(&(flt_rule->rules[1]), &flt_rule_entry, sizeof(struct ipa_flt_rule_mdfy));
+ }
+ }
+
+
+ if(false == m_filtering.ModifyFilteringRule(flt_rule))
+ {
+ IPACMERR("Failed to modify prefix filtering rules.\n");
+ res = IPACM_FAILURE;
+ goto fail;
+ }
+
+fail:
+ if(flt_rule != NULL)
+ {
+ free(flt_rule);
+ }
+ return res;
+}
+
+int IPACM_Lan::install_ipv6_prefix_flt_rule(uint32_t* prefix)
+{
int len;
struct ipa_ioc_add_flt_rule* flt_rule;
struct ipa_flt_rule_add flt_rule_entry;
bool result;
int rule_cnt = 1;
+ if(prefix == NULL)
+ {
+ IPACMERR("IPv6 prefix is empty.\n");
+ return IPACM_FAILURE;
+ }
+ IPACMDBG_H("Receive IPv6 prefix: 0x%08x%08x.\n", prefix[0], prefix[1]);
+
uint16_t mtu = IPACM_Wan::queryMTU(ipa_if_num, IPA_IP_v6);
if (mtu > 0)
{
@@ -4383,18 +4520,7 @@
}
}
-#ifdef IPA_IOCTL_SET_FNR_COUNTER_INFO
- /* use index hw-counter */
- if(ipa_if_cate == WLAN_IF && IPACM_Iface::ipacmcfg->hw_fnr_stats_support)
- {
- IPACMDBG_H("hw-index-enable %d, counter %d\n", IPACM_Iface::ipacmcfg->hw_fnr_stats_support, IPACM_Iface::ipacmcfg->hw_counter_offset + UL_ALL);
- result = m_filtering.AddFilteringRule_hw_index(flt_rule, IPACM_Iface::ipacmcfg->hw_counter_offset + UL_ALL);
- } else {
- result = m_filtering.AddFilteringRule(flt_rule);
- }
-#else
result = m_filtering.AddFilteringRule(flt_rule);
-#endif
if (result == false)
{
diff --git a/ipacm/src/IPACM_LanToLan.cpp b/ipacm/src/IPACM_LanToLan.cpp
index ea016ef..0075418 100644
--- a/ipacm/src/IPACM_LanToLan.cpp
+++ b/ipacm/src/IPACM_LanToLan.cpp
@@ -1308,8 +1308,12 @@
it_own_peer_info++)
{
/* decrement reference count of peer l2 header type on both interfaces*/
- decrement_ref_cnt_peer_l2_hdr_type(it_own_peer_info->peer->get_iface_pointer()->tx_prop->tx[0].hdr_l2_type);
- it_own_peer_info->peer->decrement_ref_cnt_peer_l2_hdr_type(m_p_iface->tx_prop->tx[0].hdr_l2_type);
+ if (it_own_peer_info->peer &&
+ it_own_peer_info->peer->get_iface_pointer() &&
+ it_own_peer_info->peer->get_iface_pointer()->tx_prop)
+ decrement_ref_cnt_peer_l2_hdr_type(it_own_peer_info->peer->get_iface_pointer()->tx_prop->tx[0].hdr_l2_type);
+ if (it_own_peer_info->peer && m_p_iface && m_p_iface->tx_prop)
+ it_own_peer_info->peer->decrement_ref_cnt_peer_l2_hdr_type(m_p_iface->tx_prop->tx[0].hdr_l2_type);
/* first clear all flt rule on target interface */
IPACMDBG_H("Clear all flt rule on target interface.\n");
@@ -1330,7 +1334,8 @@
other_iface->clear_all_rt_rule_for_one_peer_iface(&(*it_other_iface_peer_info));
/* remove the peer info from the list */
other_iface->m_peer_iface_info.erase(it_other_iface_peer_info);
- other_iface->del_hdr_proc_ctx(m_p_iface->tx_prop->tx[0].hdr_l2_type);
+ if (m_p_iface && m_p_iface->tx_prop)
+ other_iface->del_hdr_proc_ctx(m_p_iface->tx_prop->tx[0].hdr_l2_type);
break;
}
}
@@ -1338,6 +1343,9 @@
/* then clear rt rule and hdr proc ctx and release rt table on target interface */
IPACMDBG_H("Clear rt rules and hdr proc ctx and release rt table on target interface.\n");
clear_all_rt_rule_for_one_peer_iface(&(*it_own_peer_info));
+ if (it_own_peer_info->peer &&
+ it_own_peer_info->peer->get_iface_pointer() &&
+ it_own_peer_info->peer->get_iface_pointer()->tx_prop)
del_hdr_proc_ctx(it_own_peer_info->peer->get_iface_pointer()->tx_prop->tx[0].hdr_l2_type);
}
m_peer_iface_info.clear();
diff --git a/ipacm/src/IPACM_Main.cpp b/ipacm/src/IPACM_Main.cpp
index ca75a4a..6bd117e 100644
--- a/ipacm/src/IPACM_Main.cpp
+++ b/ipacm/src/IPACM_Main.cpp
@@ -270,6 +270,10 @@
#endif
ipacm_cmd_q_data new_neigh_evt;
ipacm_event_data_all* new_neigh_data;
+#ifdef IPA_MTU_EVENT_MAX
+ ipacm_event_mtu_info *mtu_event = NULL;
+ ipa_mtu_info *mtu_info;
+#endif
param = NULL;
fd = open(IPA_DRIVER, O_RDWR);
@@ -874,6 +878,32 @@
break;
#endif
+#ifdef IPA_MTU_EVENT_MAX
+ case IPA_SET_MTU:
+ mtu_event = (ipacm_event_mtu_info *)malloc(sizeof(*mtu_event));
+ if(mtu_event == NULL)
+ {
+ IPACMERR("Failed to allocate memory.\n");
+ return NULL;
+ }
+ mtu_info = &(mtu_event->mtu_info);
+ memcpy(mtu_info, buffer + sizeof(struct ipa_msg_meta), sizeof(struct ipa_mtu_info));
+ IPACMDBG_H("Received IPA_SET_MTU if_name %s ip_type %d mtu_v4 %d mtu_v6 %d\n",
+ mtu_info->if_name, mtu_info->ip_type, mtu_info->mtu_v4, mtu_info->mtu_v6);
+ if (mtu_info->ip_type > IPA_IP_MAX)
+ {
+ IPACMERR("ip_type (%d) beyond the Max range (%d), abort\n",
+ mtu_info->ip_type, IPA_IP_MAX);
+ return NULL;
+ }
+
+ ipa_get_if_index(mtu_info->if_name, &(mtu_event->if_index));
+
+ evt_data.event = IPA_MTU_SET;
+ evt_data.evt_data = mtu_event;
+ break;
+#endif
+
default:
IPACMDBG_H("Unhandled message type: %d\n", event_hdr.msg_type);
continue;
diff --git a/ipacm/src/IPACM_Wan.cpp b/ipacm/src/IPACM_Wan.cpp
index 397c820..f17eb03 100644
--- a/ipacm/src/IPACM_Wan.cpp
+++ b/ipacm/src/IPACM_Wan.cpp
@@ -92,7 +92,8 @@
int IPACM_Wan::ipa_if_num_tether_v6[IPA_MAX_IFACE_ENTRIES];
#endif
-uint16_t IPACM_Wan::mtu_default_wan = DEFAULT_MTU_SIZE;
+uint16_t IPACM_Wan::mtu_default_wan_v4 = DEFAULT_MTU_SIZE;
+uint16_t IPACM_Wan::mtu_default_wan_v6 = DEFAULT_MTU_SIZE;
IPACM_Wan::IPACM_Wan(int iface_index,
ipacm_wan_iface_type is_sta_mode,
@@ -132,7 +133,11 @@
ext_prop = NULL;
is_ipv6_frag_firewall_flt_rule_installed = false;
ipv6_frag_firewall_flt_rule_hdl = 0;
- mtu_size = DEFAULT_MTU_SIZE;
+
+ mtu_v4 = DEFAULT_MTU_SIZE;
+ mtu_v4_set = false;
+ mtu_v6 = DEFAULT_MTU_SIZE;
+ mtu_v6_set = false;
num_wan_client = 0;
header_name_count = 0;
@@ -146,6 +151,53 @@
wan_client_len = 0;
m_is_sta_mode = is_sta_mode;
+#ifdef IPA_MTU_EVENT_MAX
+ /* Query WAN MTU to handle IPACM restart scenarios. */
+ if(is_sta_mode == Q6_WAN)
+ {
+ int fd_wwan_ioctl;
+ ipa_mtu_info *mtu_info = (ipa_mtu_info *)malloc(sizeof(ipa_mtu_info));
+ if (mtu_info)
+ {
+ memset(mtu_info, 0, sizeof(ipa_mtu_info));
+ memcpy(mtu_info->if_name, dev_name, IPA_IFACE_NAME_LEN);
+ fd_wwan_ioctl = open(WWAN_QMI_IOCTL_DEVICE_NAME, O_RDWR);
+ if(fd_wwan_ioctl < 0)
+ {
+ IPACMERR("Failed to open %s.\n",WWAN_QMI_IOCTL_DEVICE_NAME);
+ }
+ else
+ {
+ IPACMDBG_H("send WAN_IOC_GET_WAN_MTU for %s\n", mtu_info->if_name);
+ if(ioctl(fd_wwan_ioctl, WAN_IOC_GET_WAN_MTU, mtu_info))
+ {
+ IPACMERR("Failed to send WAN_IOC_GET_WAN_MTU\n ");
+ }
+ else
+ {
+ /* Updated MTU values.*/
+ if (mtu_info->mtu_v4)
+ {
+ mtu_v4 = mtu_info->mtu_v4;
+ mtu_v4_set = true;
+ IPACMDBG_H("Updated v4 mtu=[%d] for (%s)\n",
+ mtu_v4, mtu_info->if_name);
+ }
+ if (mtu_info->mtu_v6)
+ {
+ mtu_v6 = mtu_info->mtu_v6;
+ mtu_v6_set = true;
+ IPACMDBG_H("Updated v6 mtu=[%d] for (%s)\n",
+ mtu_v6, mtu_info->if_name);
+ }
+ }
+ close(fd_wwan_ioctl);
+ }
+ free(mtu_info);
+ }
+ }
+#endif
+
if(iface_query != NULL)
{
IPACMDBG_H("index:%d constructor: Tx properties:%d\n", iface_index, iface_query->num_tx_props);
@@ -810,7 +862,7 @@
IPACMDBG_H(" Has rx/tx properties registered for iface %s, add for NATTING for ip-family %d \n", dev_name, IPA_IP_v6);
IPACM_Iface::ipacmcfg->AddNatIfaces(dev_name, IPA_IP_v6);
}
- /* skylar setup v6-wan-tbl */
+ /* setup v6-wan-tbl */
rt_rule = (struct ipa_ioc_add_rt_rule *)
calloc(1, sizeof(struct ipa_ioc_add_rt_rule) +
NUM_RULES * sizeof(struct ipa_rt_rule_add));
@@ -1112,6 +1164,7 @@
}
}
break;
+
case IPA_LINK_DOWN_EVENT:
{
ipacm_event_data_fid *data = (ipacm_event_data_fid *)param;
@@ -1575,6 +1628,8 @@
{
ipacm_event_data_all *data = (ipacm_event_data_all *)param;
ipa_interface_index = iface_ipa_index_query(data->if_index);
+ int index = 0;
+ bool renew = false;
if (ipa_interface_index == ipa_if_num)
{
@@ -1606,6 +1661,7 @@
}
IPACMDBG_H("wan-iface got client \n");
+
/* first construc WAN-client full header */
if(memcmp(data->mac_addr,
invalid_mac,
@@ -1617,7 +1673,20 @@
return;
}
- handle_wan_hdr_init(data->mac_addr);
+ /* check if same as GW_ip need replacing */
+ if( handle_gw_mac_renew(data, index) == IPACM_SUCCESS)
+ {
+ renew = true;
+ IPACMDBG_H("Renew is happening with client-index (%d)\n", index);
+ /* clinet renew procedure */
+ handle_wan_hdr_init(data->mac_addr, true, index);
+ }
+ else
+ {
+ IPACMDBG_H("Renew is no need!\n");
+ handle_wan_hdr_init(data->mac_addr);
+ }
+
IPACMDBG_H("construct wan-client header and route rules \n");
/* Associate with IP and construct RT-rule */
if (handle_wan_client_ipaddr(data) == IPACM_FAILURE)
@@ -1626,7 +1695,7 @@
}
handle_wan_client_route_rule(data->mac_addr, data->iptype);
/* Check & construct STA header */
- handle_sta_header_add_evt();
+ handle_sta_header_add_evt(renew);
return;
}
}
@@ -1721,54 +1790,117 @@
}
break;
- case IPA_WLAN_SWITCH_TO_SCC:
- if(IPACM_Wan::backhaul_mode == WLAN_WAN)
+ case IPA_WLAN_SWITCH_TO_SCC:
+ if(IPACM_Wan::backhaul_mode == WLAN_WAN)
+ {
+ IPACMDBG_H("Received IPA_WLAN_SWITCH_TO_SCC\n");
+ if(ip_type == IPA_IP_MAX)
{
- IPACMDBG_H("Received IPA_WLAN_SWITCH_TO_SCC\n");
- if(ip_type == IPA_IP_MAX)
- {
- handle_wlan_SCC_MCC_switch(true, IPA_IP_v4);
- handle_wlan_SCC_MCC_switch(true, IPA_IP_v6);
- handle_wan_client_SCC_MCC_switch(true, IPA_IP_v4);
- handle_wan_client_SCC_MCC_switch(true, IPA_IP_v6);
- }
- else
- {
- handle_wlan_SCC_MCC_switch(true, ip_type);
- handle_wan_client_SCC_MCC_switch(true, ip_type);
- }
+ handle_wlan_SCC_MCC_switch(true, IPA_IP_v4);
+ handle_wlan_SCC_MCC_switch(true, IPA_IP_v6);
+ handle_wan_client_SCC_MCC_switch(true, IPA_IP_v4);
+ handle_wan_client_SCC_MCC_switch(true, IPA_IP_v6);
}
- break;
-
- case IPA_WLAN_SWITCH_TO_MCC:
- if(IPACM_Wan::backhaul_mode == WLAN_WAN)
+ else
{
- IPACMDBG_H("Received IPA_WLAN_SWITCH_TO_MCC\n");
- if(ip_type == IPA_IP_MAX)
- {
- handle_wlan_SCC_MCC_switch(false, IPA_IP_v4);
- handle_wlan_SCC_MCC_switch(false, IPA_IP_v6);
- handle_wan_client_SCC_MCC_switch(false, IPA_IP_v4);
- handle_wan_client_SCC_MCC_switch(false, IPA_IP_v6);
- }
- else
- {
- handle_wlan_SCC_MCC_switch(false, ip_type);
- handle_wan_client_SCC_MCC_switch(false, ip_type);
- }
+ handle_wlan_SCC_MCC_switch(true, ip_type);
+ handle_wan_client_SCC_MCC_switch(true, ip_type);
}
- break;
-#ifdef FEATURE_IPACM_HAL
- /* WA for WLAN to clean up NAT instance during SSR */
- case IPA_SSR_NOTICE:
- case IPA_WLAN_FWR_SSR_BEFORE_SHUTDOWN_NOTICE:
- IPACMDBG_H("Received IPA_SSR_NOTICE event.\n");
- if(m_is_sta_mode == WLAN_WAN)
- {
- IPACM_Iface::ipacmcfg->DelNatIfaces(dev_name); // delete NAT-iface
- }
+ }
break;
+
+ case IPA_WLAN_SWITCH_TO_MCC:
+ if(IPACM_Wan::backhaul_mode == WLAN_WAN)
+ {
+ IPACMDBG_H("Received IPA_WLAN_SWITCH_TO_MCC\n");
+ if(ip_type == IPA_IP_MAX)
+ {
+ handle_wlan_SCC_MCC_switch(false, IPA_IP_v4);
+ handle_wlan_SCC_MCC_switch(false, IPA_IP_v6);
+ handle_wan_client_SCC_MCC_switch(false, IPA_IP_v4);
+ handle_wan_client_SCC_MCC_switch(false, IPA_IP_v6);
+ }
+ else
+ {
+ handle_wlan_SCC_MCC_switch(false, ip_type);
+ handle_wan_client_SCC_MCC_switch(false, ip_type);
+ }
+ }
+ break;
+#ifdef FEATURE_IPACM_HAL
+ /* WA for WLAN to clean up NAT instance during SSR */
+ case IPA_SSR_NOTICE:
+ case IPA_WLAN_FWR_SSR_BEFORE_SHUTDOWN_NOTICE:
+ {
+ IPACMDBG_H("Received IPA_SSR_NOTICE event.\n");
+ if(m_is_sta_mode == WLAN_WAN)
+ {
+ IPACM_Iface::ipacmcfg->DelNatIfaces(dev_name); // delete NAT-iface
+ }
+ }
+ break;
#endif
+#ifdef IPA_MTU_EVENT_MAX
+ case IPA_MTU_SET:
+ {
+ ipacm_event_mtu_info *data = (ipacm_event_mtu_info *)param;
+ ipa_mtu_info *mtu_info = &(data->mtu_info);
+ ipa_interface_index = iface_ipa_index_query(data->if_index);
+
+ if (ipa_interface_index == ipa_if_num)
+ {
+ IPACMDBG_H("Received IPA_MTU_SET (Android) for interface (%d)\n",
+ ipa_interface_index);
+ if (mtu_info->ip_type == IPA_IP_v4 || mtu_info->ip_type == IPA_IP_MAX)
+ {
+ /* Update v4_mtu. */
+ mtu_v4 = mtu_info->mtu_v4;
+ mtu_v4_set = true;
+
+ if (active_v4)
+ {
+ /* upstream interface. update default MTU. */
+ mtu_default_wan_v4 = mtu_v4;
+ }
+ IPACMDBG_H("Updated v4 mtu=[%d] for (%s), upstream_mtu=[%d]\n",
+ mtu_v4, mtu_info->if_name, mtu_default_wan_v4);
+ }
+ if (mtu_info->ip_type == IPA_IP_v6 || mtu_info->ip_type == IPA_IP_MAX)
+ {
+ /* Update v4_mtu. */
+ mtu_v6 = mtu_info->mtu_v6;
+ mtu_v6_set = true;
+ if (active_v6)
+ {
+ /* upstream interface. update default MTU. */
+ mtu_default_wan_v6 = mtu_v6;
+ }
+ IPACMDBG_H("Updated v6 mtu=[%d] for (%s), upstream_mtu=[%d]\n",
+ mtu_v6, mtu_info->if_name, mtu_default_wan_v6);
+ }
+
+ if (active_v4 || active_v6)
+ {
+ ipacm_event_mtu_info *mtu_event;
+ ipacm_cmd_q_data evt_data;
+ mtu_event = (ipacm_event_mtu_info *)malloc(sizeof(*mtu_event));
+ if(mtu_event == NULL)
+ {
+ IPACMERR("Failed to allocate memory.\n");
+ return;
+ }
+ memcpy(&mtu_event->mtu_info, mtu_info, sizeof(ipa_mtu_info));
+ evt_data.event = IPA_MTU_UPDATE;
+ evt_data.evt_data = mtu_event;
+ /* finish command queue */
+ IPACMDBG_H("Posting IPA_MTU_UPDATE event\n");
+ IPACM_EvtDispatcher::PostEvt(&evt_data);
+ }
+ }
+ }
+ break;
+#endif
+
default:
break;
}
@@ -1777,9 +1909,8 @@
}
/* wan default route/filter rule configuration */
-int IPACM_Wan::handle_route_add_evt(ipa_ip_type iptype)
+int IPACM_Wan::handle_route_add_evt(ipa_ip_type iptype, bool add_only)
{
-
/* add default WAN route */
struct ipa_ioc_add_rt_rule *rt_rule = NULL;
struct ipa_rt_rule_add *rt_rule_entry;
@@ -1817,8 +1948,14 @@
}
IPACMDBG_H("backhaul_is_wan_bridge ?: %d \n", IPACM_Wan::backhaul_is_wan_bridge);
- /* query MTU size of the interface */
- query_mtu_size();
+ /* query MTU size of the interface if MTU is not set via ioctl. */
+ if (!mtu_v4_set && !mtu_v6_set)
+ {
+ if(query_mtu_size())
+ {
+ IPACMERR("Failed to query mtu");
+ }
+ }
if (m_is_sta_mode ==Q6_WAN)
{
@@ -2104,10 +2241,16 @@
wan_route_rule_v6_hdl_a5[0], 0, iptype);
}
- /* set mtu_default_wan to current default wan instance */
- mtu_default_wan = mtu_size;
-
- IPACMDBG_H("replace the mtu_default_wan to %d\n", mtu_default_wan);
+ /* support delete only, not post wan_down event */
+ if (add_only)
+ {
+ IPACMDBG_H(" Only add default WAN routing rules (%d)\n", add_only);
+ if(rt_rule != NULL)
+ {
+ free(rt_rule);
+ }
+ return IPACM_SUCCESS;
+ }
ipacm_event_iface_up *wanup_data;
wanup_data = (ipacm_event_iface_up *)malloc(sizeof(ipacm_event_iface_up));
@@ -2122,6 +2265,10 @@
/* handling filter rule construction */
if (iptype == IPA_IP_v4)
{
+ /* set mtu_default_wan to current default wan instance */
+ mtu_default_wan_v4 = mtu_v4;
+ IPACMDBG_H("replace the mtu_wan to %d\n", mtu_default_wan_v4);
+
IPACM_Wan::wan_up = true;
active_v4 = true;
memcpy(IPACM_Wan::wan_up_dev_name,
@@ -2181,6 +2328,10 @@
}
else
{
+ /* set mtu_default_wan to current default wan instance */
+ mtu_default_wan_v6 = mtu_v6;
+ IPACMDBG_H("replace the mtu_wan to %d\n", mtu_default_wan_v6);
+
memcpy(backhaul_ipv6_prefix, ipv6_prefix, sizeof(backhaul_ipv6_prefix));
IPACMDBG_H("Setup backhaul ipv6 prefix to be 0x%08x%08x.\n", backhaul_ipv6_prefix[0], backhaul_ipv6_prefix[1]);
@@ -2244,6 +2395,20 @@
IPACMERR("Failed to send WAN_IOC_NOTIFY_WAN_STATE as up %d\n ", wan_state.up);
}
close(fd_wwan_ioctl);
+
+ /* Store the Offload state. */
+ FILE *fp = NULL;
+ fp = fopen(IPA_OFFLOAD_TETHER_STATE_FILE_NAME, "w");
+ if (fp == NULL)
+ {
+ IPACMERR("Failed to write offload state to %s, error is %d - %s\n",
+ IPA_OFFLOAD_TETHER_STATE_FILE_NAME, errno, strerror(errno));
+ }
+ else
+ {
+ fprintf(fp, "UPSTREAM=%s,STATE=UP", dev_name);
+ fclose(fp);
+ }
}
ipa_pm_q6_check++;
IPACMDBG_H("update ipa_pm_q6_check to %d\n", ipa_pm_q6_check);
@@ -2371,7 +2536,7 @@
#endif
/* construct complete ethernet header */
-int IPACM_Wan::handle_sta_header_add_evt()
+int IPACM_Wan::handle_sta_header_add_evt(bool renew)
{
int res = IPACM_SUCCESS, index = IPACM_INVALID_INDEX;
if((header_set_v4 == true) || (header_set_v6 == true))
@@ -2428,7 +2593,13 @@
}
}
- /* checking if the ipv4 same as default route */
+ /* see if v4 default routes are setup before constructing full header */
+ if(header_partial_default_wan_v4 == true)
+ {
+ handle_route_add_evt(IPA_IP_v4, renew);
+ }
+
+ /* checking if the ipv6 same as default route */
if(wan_v6_addr_gw_set)
{
index = get_wan_client_index_ipv6(wan_v6_addr_gw);
@@ -2476,15 +2647,11 @@
}
}
- /* see if default routes are setup before constructing full header */
- if(header_partial_default_wan_v4 == true)
- {
- handle_route_add_evt(IPA_IP_v4);
- }
+ /* see if v6 default routes are setup before constructing full header */
if(header_partial_default_wan_v6 == true)
{
- handle_route_add_evt(IPA_IP_v6);
+ handle_route_add_evt(IPA_IP_v6, renew);
}
return res;
}
@@ -4672,7 +4839,7 @@
}
/* for STA mode: wan default route/filter rule delete */
-int IPACM_Wan::handle_route_del_evt(ipa_ip_type iptype)
+int IPACM_Wan::handle_route_del_evt(ipa_ip_type iptype, bool delete_only)
{
uint32_t tx_index;
ipacm_cmd_q_data evt_data;
@@ -4681,6 +4848,7 @@
int fd_wwan_ioctl;
memset(&wan_state, 0, sizeof(wan_state));
#endif
+ int ret = IPACM_SUCCESS;
IPACMDBG_H("got handle_route_del_evt for STA-mode with ip-family:%d \n", iptype);
@@ -4696,42 +4864,42 @@
if (((iptype == IPA_IP_v4) && (active_v4 == true)) ||
((iptype == IPA_IP_v6) && (active_v6 == true)))
{
- if(IPACM_Iface::ipacmcfg->GetIPAVer() >= IPA_HW_None && IPACM_Iface::ipacmcfg->GetIPAVer() < IPA_HW_v4_0)
+ if (!delete_only)
{
- /* Delete corresponding ipa_rm_resource_name of TX-endpoint after delete IPV4/V6 RT-rule */
- IPACMDBG_H("dev %s delete producer dependency\n", dev_name);
- IPACMDBG_H("depend Got pipe %d rm index : %d \n", tx_prop->tx[0].dst_pipe, IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[tx_prop->tx[0].dst_pipe]);
- IPACM_Iface::ipacmcfg->DelRmDepend(IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[tx_prop->tx[0].dst_pipe]);
- }
- else
- {
- /* change wan_state for Q6_MHI */
-#ifdef WAN_IOC_NOTIFY_WAN_STATE
- IPACMDBG_H("ipa_pm_q6_check to %d\n", ipa_pm_q6_check);
- if(ipa_pm_q6_check == 1 && m_is_sta_mode == Q6_MHI_WAN)
+ if(IPACM_Iface::ipacmcfg->GetIPAVer() >= IPA_HW_None && IPACM_Iface::ipacmcfg->GetIPAVer() < IPA_HW_v4_0)
{
- fd_wwan_ioctl = open(WWAN_QMI_IOCTL_DEVICE_NAME, O_RDWR);
- if(fd_wwan_ioctl < 0)
- {
- IPACMERR("Failed to open %s.\n",WWAN_QMI_IOCTL_DEVICE_NAME);
- return false;
- }
- IPACMDBG_H("send WAN_IOC_NOTIFY_WAN_STATE down to IPA_PM\n");
-#ifdef WAN_IOCTL_NOTIFY_WAN_INTF_NAME
- strlcpy(wan_state.upstreamIface, dev_name, IFNAMSIZ);
-#endif
- if(ioctl(fd_wwan_ioctl, WAN_IOC_NOTIFY_WAN_STATE, &wan_state))
- {
- IPACMERR("Failed to send WAN_IOC_NOTIFY_WAN_STATE as up %d\n ", wan_state.up);
- }
- close(fd_wwan_ioctl);
+ /* Delete corresponding ipa_rm_resource_name of TX-endpoint after delete IPV4/V6 RT-rule */
+ IPACMDBG_H("dev %s delete producer dependency\n", dev_name);
+ IPACMDBG_H("depend Got pipe %d rm index : %d \n", tx_prop->tx[0].dst_pipe, IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[tx_prop->tx[0].dst_pipe]);
+ IPACM_Iface::ipacmcfg->DelRmDepend(IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[tx_prop->tx[0].dst_pipe]);
}
- if (ipa_pm_q6_check > 0)
- ipa_pm_q6_check--;
else
- IPACMERR(" ipa_pm_q6_check becomes negative !!!\n");
+ {
+ /* change wan_state for Q6_MHI */
+#ifdef WAN_IOC_NOTIFY_WAN_STATE
+ IPACMDBG_H("ipa_pm_q6_check to %d\n", ipa_pm_q6_check);
+ if(ipa_pm_q6_check == 1 && m_is_sta_mode == Q6_MHI_WAN)
+ {
+ fd_wwan_ioctl = open(WWAN_QMI_IOCTL_DEVICE_NAME, O_RDWR);
+ if(fd_wwan_ioctl < 0)
+ {
+ IPACMERR("Failed to open %s.\n",WWAN_QMI_IOCTL_DEVICE_NAME);
+ return false;
+ }
+ IPACMDBG_H("send WAN_IOC_NOTIFY_WAN_STATE down to IPA_PM\n");
+ if(ioctl(fd_wwan_ioctl, WAN_IOC_NOTIFY_WAN_STATE, &wan_state))
+ {
+ IPACMERR("Failed to send WAN_IOC_NOTIFY_WAN_STATE as up %d\n ", wan_state.up);
+ }
+ close(fd_wwan_ioctl);
+ }
+ if (ipa_pm_q6_check > 0)
+ ipa_pm_q6_check--;
+ else
+ IPACMERR(" ipa_pm_q6_check becomes negative !!!\n");
#endif
- }
+ }
+ } // end of delete_only
for (tx_index = 0; tx_index < iface_query->num_tx_props; tx_index++)
{
@@ -4774,6 +4942,14 @@
return IPACM_FAILURE;
}
}
+
+ /* support delete only, not post wan_down event */
+ if(delete_only)
+ {
+ IPACMDBG_H(" Only delete default WAN routing rules (%d)\n", delete_only);
+ return IPACM_SUCCESS;
+ }
+
ipacm_event_iface_up *wandown_data;
wandown_data = (ipacm_event_iface_up *)malloc(sizeof(ipacm_event_iface_up));
if (wandown_data == NULL)
@@ -4813,24 +4989,19 @@
if(delete_offload_frag_rule())
{
IPACMERR("Failed to delete DL frag rule \n");
- return IPACM_FAILURE;
+ ret = IPACM_FAILURE;
}
- /* Delete MHI icmpv6 exception rule */
- if(delete_icmpv6_exception_rule())
- {
- 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;
+ ret = IPACM_FAILURE;
}
+ return ret;
}
else
{
-
wandown_data->backhaul_type = m_is_sta_mode;
memcpy(wandown_data->ipv6_prefix, ipv6_prefix, sizeof(wandown_data->ipv6_prefix));
evt_data.event = IPA_HANDLE_WAN_DOWN_V6;
@@ -4849,6 +5020,13 @@
{
memset(IPACM_Wan::wan_up_dev_name, 0, sizeof(IPACM_Wan::wan_up_dev_name));
}
+ /* Delete MHI icmpv6 exception rule */
+ if(delete_icmpv6_exception_rule())
+ {
+ IPACMERR("Failed to delete icmpv6 rule \n");
+ return IPACM_FAILURE;
+ }
+
}
}
else
@@ -4909,6 +5087,20 @@
IPACMERR("Failed to send WAN_IOC_NOTIFY_WAN_STATE as up %d\n ", wan_state.up);
}
close(fd_wwan_ioctl);
+
+ /* Store the Offload state. */
+ FILE *fp = NULL;
+ fp = fopen(IPA_OFFLOAD_TETHER_STATE_FILE_NAME, "w");
+ if (fp == NULL)
+ {
+ IPACMERR("Failed to write offload state to %s, error is %d - %s\n",
+ IPA_OFFLOAD_TETHER_STATE_FILE_NAME, errno, strerror(errno));
+ }
+ else
+ {
+ fprintf(fp, "UPSTREAM=%s,STATE=DOWN", dev_name);
+ fclose(fp);
+ }
}
if (ipa_pm_q6_check > 0)
ipa_pm_q6_check--;
@@ -5152,17 +5344,6 @@
handle_route_del_evt(IPA_IP_v4);
IPACMDBG_H("Delete default v4 routing rules\n");
- if(m_is_sta_mode == Q6_MHI_WAN)
- {
- /* Delete default v4 RT rule */
- IPACMDBG_H("Delete default v4 routing rules\n");
- if (m_routing.DeleteRoutingHdl(dft_rt_rule_hdl[0], IPA_IP_v4) == false)
- {
- IPACMERR("Routing v6-lan-RT rule deletion failed!\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- }
#ifdef FEATURE_IPA_ANDROID
/* posting wan_down_tether for lan clients */
@@ -5194,18 +5375,6 @@
handle_route_del_evt(IPA_IP_v6);
IPACMDBG_H("Delete default v6 routing rules\n");
- if(m_is_sta_mode == Q6_MHI_WAN)
- {
- /* Delete default v6 RT rule */
- IPACMDBG_H("Delete default v6 routing rules\n");
- if (m_routing.DeleteRoutingHdl(dft_rt_rule_hdl[1], IPA_IP_v6) == false)
- {
- IPACMERR("Routing v6-wan-RT rule deletion failed!\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- }
-
#ifdef FEATURE_IPA_ANDROID
/* posting wan_down_tether for lan clients */
#ifdef FEATURE_IPACM_HAL
@@ -5227,37 +5396,51 @@
#endif
}
- if(m_is_sta_mode != Q6_MHI_WAN)
+ /* Delete default v4 RT rule */
+ if (ip_type != IPA_IP_v6 && wan_v4_addr_set)
{
- /* Delete default v4 RT rule */
- if (ip_type != IPA_IP_v6)
+ /* no need delete v4 RSC routing rules */
+ IPACMDBG_H("Delete default v4 routing rules\n");
+ if (m_routing.DeleteRoutingHdl(dft_rt_rule_hdl[0], IPA_IP_v4) == false)
{
- /* no need delete v4 RSC routing rules */
- 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");
+ res = IPACM_FAILURE;
+ goto fail;
+ }
+ }
+
+ /* delete default v6 RT rule */
+ if (ip_type != IPA_IP_v4)
+ {
+ IPACMDBG_H("Delete default v6 routing rules\n");
+ /* May have multiple ipv6 iface-routing rules*/
+ for (i = 0; i < 2*num_dft_rt_v6; i++)
+ {
+ if (m_routing.DeleteRoutingHdl(dft_rt_rule_hdl[MAX_DEFAULT_v4_ROUTE_RULES+i], IPA_IP_v6) == false)
{
IPACMERR("Routing rule deletion failed!\n");
res = IPACM_FAILURE;
goto fail;
}
}
+ IPACMDBG_H("finished delete default v6 RT rules\n ");
+ }
- /* delete default v6 RT rule */
- if (ip_type != IPA_IP_v4)
+ /* check software routing fl rule hdl */
+ if (softwarerouting_act == true)
+ {
+ if(m_is_sta_mode == Q6_MHI_WAN)
{
- IPACMDBG_H("Delete default v6 routing rules\n");
- /* May have multiple ipv6 iface-routing rules*/
- for (i = 0; i < 2*num_dft_rt_v6; i++)
- {
- if (m_routing.DeleteRoutingHdl(dft_rt_rule_hdl[MAX_DEFAULT_v4_ROUTE_RULES+i], IPA_IP_v6) == false)
- {
- IPACMERR("Routing rule deletion failed!\n");
- res = IPACM_FAILURE;
- goto fail;
- }
- }
- IPACMDBG_H("finished delete default v6 RT rules\n ");
+ handle_software_routing_disable(true);
}
+ else
+ {
+ handle_software_routing_disable(false);
+ }
+ }
+
+ if(m_is_sta_mode != Q6_MHI_WAN)
+ {
/* clean wan-client header, routing rules */
IPACMDBG_H("left %d wan clients need to be deleted \n ", num_wan_client);
for (i = 0; i < num_wan_client; i++)
@@ -5306,18 +5489,6 @@
/* free the edm clients cache */
IPACMDBG_H("Free wan clients cache\n");
- /* check software routing fl rule hdl */
- if (softwarerouting_act == true)
- {
- 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)
{
@@ -5453,8 +5624,13 @@
goto fail;
}
+#ifndef IPA_MTU_EVENT_MAX
/* reset the mtu size */
- mtu_size = DEFAULT_MTU_SIZE;
+ mtu_v4 = DEFAULT_MTU_SIZE;
+ mtu_v4_set = false;
+ mtu_v6 = DEFAULT_MTU_SIZE;
+ mtu_v6_set = false;
+#endif
if(ip_type == IPA_IP_v4)
{
@@ -6019,7 +6195,7 @@
/* handle STA WAN-client */
/* handle WAN client initial, construct full headers (tx property) */
-int IPACM_Wan::handle_wan_hdr_init(uint8_t *mac_addr)
+int IPACM_Wan::handle_wan_hdr_init(uint8_t *mac_addr, bool replaced, int entry)
{
#define WAN_IFACE_INDEX_LEN 2
@@ -6031,38 +6207,41 @@
uint32_t cnt;
int clnt_indx;
- clnt_indx = get_wan_client_index(mac_addr);
-
- if (clnt_indx != IPACM_INVALID_INDEX)
- {
- IPACMERR("eth client is found/attached already with index %d \n", clnt_indx);
- return IPACM_FAILURE;
- }
-
- /* add header to IPA */
- if (num_wan_client >= IPA_MAX_NUM_WAN_CLIENTS)
- {
- IPACMERR("Reached maximum number(%d) of eth clients\n", IPA_MAX_NUM_WAN_CLIENTS);
- return IPACM_FAILURE;
- }
-
IPACMDBG_H("WAN client number: %d\n", num_wan_client);
- memcpy(get_client_memptr(wan_client, num_wan_client)->mac,
+ if(!replaced)
+ {
+ clnt_indx = get_wan_client_index(mac_addr);
+
+ if (clnt_indx != IPACM_INVALID_INDEX)
+ {
+ IPACMERR("eth client is found/attached already with index %d \n", clnt_indx);
+ return IPACM_FAILURE;
+ }
+
+ /* add header to IPA */
+ if (num_wan_client >= IPA_MAX_NUM_WAN_CLIENTS)
+ {
+ IPACMERR("Reached maximum number(%d) of eth clients\n", IPA_MAX_NUM_WAN_CLIENTS);
+ return IPACM_FAILURE;
+ }
+
+ memcpy(get_client_memptr(wan_client, num_wan_client)->mac,
mac_addr,
sizeof(get_client_memptr(wan_client, num_wan_client)->mac));
- IPACMDBG_H("Received Client MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
+ IPACMDBG_H("Received Client MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
mac_addr[0], mac_addr[1], mac_addr[2],
mac_addr[3], mac_addr[4], mac_addr[5]);
- IPACMDBG_H("stored MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
+ IPACMDBG_H("stored MAC %02x:%02x:%02x:%02x:%02x:%02x\n",
get_client_memptr(wan_client, num_wan_client)->mac[0],
get_client_memptr(wan_client, num_wan_client)->mac[1],
get_client_memptr(wan_client, num_wan_client)->mac[2],
get_client_memptr(wan_client, num_wan_client)->mac[3],
get_client_memptr(wan_client, num_wan_client)->mac[4],
get_client_memptr(wan_client, num_wan_client)->mac[5]);
+ }
/* add header to IPA */
if(tx_prop != NULL)
@@ -6163,13 +6342,23 @@
goto fail;
}
- get_client_memptr(wan_client, num_wan_client)->hdr_hdl_v4 = pHeaderDescriptor->hdr[0].hdr_hdl;
- IPACMDBG_H("eth-client(%d) v4 full header name:%s header handle:(0x%x)\n",
+ if (!replaced)
+ {
+ get_client_memptr(wan_client, num_wan_client)->hdr_hdl_v4 = pHeaderDescriptor->hdr[0].hdr_hdl;
+ IPACMDBG_H("eth-client(%d) v4 full header name:%s header handle:(0x%x)\n",
num_wan_client,
pHeaderDescriptor->hdr[0].name,
get_client_memptr(wan_client, num_wan_client)->hdr_hdl_v4);
get_client_memptr(wan_client, num_wan_client)->ipv4_header_set=true;
-
+ } else
+ {
+ get_client_memptr(wan_client, entry)->hdr_hdl_v4 = pHeaderDescriptor->hdr[0].hdr_hdl;
+ IPACMDBG_H("replaced eth-client(%d) v4 full header name:%s header handle:(0x%x)\n",
+ entry,
+ pHeaderDescriptor->hdr[0].name,
+ get_client_memptr(wan_client, entry)->hdr_hdl_v4);
+ get_client_memptr(wan_client, entry)->ipv4_header_set=true;
+ }
break;
}
}
@@ -6259,24 +6448,45 @@
goto fail;
}
- get_client_memptr(wan_client, num_wan_client)->hdr_hdl_v6 = pHeaderDescriptor->hdr[0].hdr_hdl;
- IPACMDBG_H("eth-client(%d) v6 full header name:%s header handle:(0x%x)\n",
+ if (!replaced)
+ {
+ get_client_memptr(wan_client, num_wan_client)->hdr_hdl_v6 = pHeaderDescriptor->hdr[0].hdr_hdl;
+ IPACMDBG_H("eth-client(%d) v6 full header name:%s header handle:(0x%x)\n",
num_wan_client,
pHeaderDescriptor->hdr[0].name,
get_client_memptr(wan_client, num_wan_client)->hdr_hdl_v6);
-
get_client_memptr(wan_client, num_wan_client)->ipv6_header_set=true;
+ }
+ else
+ {
+ get_client_memptr(wan_client, entry)->hdr_hdl_v6 = pHeaderDescriptor->hdr[0].hdr_hdl;
+ IPACMDBG_H("replaced eth-client(%d) v6 full header name:%s header handle:(0x%x)\n",
+ entry,
+ pHeaderDescriptor->hdr[0].name,
+ get_client_memptr(wan_client, entry)->hdr_hdl_v6);
+ get_client_memptr(wan_client, entry)->ipv6_header_set=true;
+ }
break;
}
}
/* initialize wifi client*/
- get_client_memptr(wan_client, num_wan_client)->route_rule_set_v4 = false;
- get_client_memptr(wan_client, num_wan_client)->route_rule_set_v6 = 0;
- get_client_memptr(wan_client, num_wan_client)->ipv4_set = false;
- get_client_memptr(wan_client, num_wan_client)->ipv6_set = 0;
- num_wan_client++;
+ if (!replaced)
+ {
+ get_client_memptr(wan_client, num_wan_client)->route_rule_set_v4 = false;
+ get_client_memptr(wan_client, num_wan_client)->route_rule_set_v6 = 0;
+ get_client_memptr(wan_client, num_wan_client)->ipv4_set = false;
+ get_client_memptr(wan_client, num_wan_client)->ipv6_set = 0;
+ num_wan_client++;
+ }
+ else
+ {
+ get_client_memptr(wan_client, entry)->route_rule_set_v4 = false;
+ get_client_memptr(wan_client, entry)->route_rule_set_v6 = 0;
+ get_client_memptr(wan_client, entry)->ipv4_set = false;
+ get_client_memptr(wan_client, entry)->ipv6_set = 0;
+ }
header_name_count++; //keep increasing header_name_count
res = IPACM_SUCCESS;
IPACMDBG_H("eth client number: %d\n", num_wan_client);
@@ -7828,11 +8038,126 @@
return IPACM_FAILURE;
}
IPACMDBG_H("mtu=[%d]\n", if_mtu.ifr_mtu);
- if (if_mtu.ifr_mtu < DEFAULT_MTU_SIZE) {
- mtu_size = if_mtu.ifr_mtu;
- IPACMDBG_H("replaced mtu=[%d] for (%s)\n", mtu_size, dev_name);
+ if (if_mtu.ifr_mtu <= DEFAULT_MTU_SIZE) {
+ mtu_v4 = mtu_v6 = if_mtu.ifr_mtu;
+ }else {
+ mtu_v4 = mtu_v6 = DEFAULT_MTU_SIZE;
}
+ IPACMDBG_H("Updated mtu=[%d] for (%s)\n", mtu_v4, dev_name);
close(fd);
return IPACM_SUCCESS;
}
+
+/* construct complete ethernet header */
+int IPACM_Wan::handle_gw_mac_renew(ipacm_event_data_all *data, int index_client)
+{
+ int index = IPACM_INVALID_INDEX;
+
+ /* checking if client has same ipv4, v6 will put future work */
+ if (data->iptype == IPA_IP_v4)
+ {
+ index = get_wan_client_index_ipv4(data->ipv4_addr);
+ if (index != IPACM_INVALID_INDEX)
+ {
+ IPACMDBG_H("Matched client index: %d\n", index);
+ IPACMDBG_H("Client MAC in cache %02x:%02x:%02x:%02x:%02x:%02x\n",
+ get_client_memptr(wan_client, index)->mac[0],
+ get_client_memptr(wan_client, index)->mac[1],
+ get_client_memptr(wan_client, index)->mac[2],
+ get_client_memptr(wan_client, index)->mac[3],
+ get_client_memptr(wan_client, index)->mac[4],
+ get_client_memptr(wan_client, index)->mac[5]);
+
+ /* check mac same or not */
+ if ((data->mac_addr[0] == get_client_memptr(wan_client, index)->mac[0]) &&
+ (data->mac_addr[1] == get_client_memptr(wan_client, index)->mac[1]) &&
+ (data->mac_addr[2] == get_client_memptr(wan_client, index)->mac[2]) &&
+ (data->mac_addr[3] == get_client_memptr(wan_client, index)->mac[3]) &&
+ (data->mac_addr[4] == get_client_memptr(wan_client, index)->mac[4]) &&
+ (data->mac_addr[5] == get_client_memptr(wan_client, index)->mac[5]))
+ {
+ IPACMDBG_H(" No need client (%d) mac renew with IPv4 (0x%x)\n", index, data->ipv4_addr);
+ return IPACM_FAILURE;
+ }
+ else
+ {
+ IPACMDBG_H(" client %d need mac renew with IPv4 (0x%x)\n", index, data->ipv4_addr);
+
+ /* Del NAT rules before ipv4 RT rules are delete */
+ if(get_client_memptr(wan_client, index)->ipv4_set == true)
+ {
+ IPACMDBG_H("Clean Nat Rules for ipv4:0x%x\n", get_client_memptr(wan_client, index)->v4_addr);
+ CtList->HandleSTAClientDelEvt(get_client_memptr(wan_client, index)->v4_addr);
+ }
+
+ /* clean up STA header / routing rule */
+ if (data->ipv4_addr == wan_v4_addr_gw && active_v4)
+ {
+ handle_route_del_evt(IPA_IP_v4, true);
+ IPACMDBG_H("Delete default v4 routing rules\n");
+ hdr_hdl_sta_v4 = 0;
+ header_set_v4 = false;
+ header_partial_default_wan_v4 = true;
+
+ if (active_v6)
+ {
+ handle_route_del_evt(IPA_IP_v6, true);
+ IPACMDBG_H("Delete default v6 routing rules\n");
+ header_partial_default_wan_v6 = true;
+ }
+ hdr_hdl_sta_v6 = 0;
+ header_set_v6 = false;
+ }
+
+ /* clean up client header routing rule entry */
+ if(delete_wan_rtrules(index, IPA_IP_v4))
+ {
+ IPACMERR("unbale to delete wan-client v4 route rules for index %d\n", index);
+ return IPACM_FAILURE;
+ }
+
+ get_client_memptr(wan_client, index)->route_rule_set_v4 = false;
+ get_client_memptr(wan_client, index)->ipv4_set = false;
+
+ IPACMDBG_H("Delete client %d header\n", index);
+ if(get_client_memptr(wan_client, index)->ipv4_header_set == true)
+ {
+ if (m_header.DeleteHeaderHdl(get_client_memptr(wan_client, index)->hdr_hdl_v4) == false)
+ {
+ IPACMERR("unable to delete client v4 header for index %d\n", index);
+ return IPACM_FAILURE;
+ }
+ get_client_memptr(wan_client, index)->ipv4_header_set = false;
+ }
+
+ if(delete_wan_rtrules(index, IPA_IP_v6))
+ {
+ IPACMERR("unbale to delete wan-client v6 route rules for index %d\n", index);
+ return IPACM_FAILURE;
+ }
+ get_client_memptr(wan_client, index)->route_rule_set_v6 = 0;
+ get_client_memptr(wan_client, index)->ipv6_set = 0;
+ if(get_client_memptr(wan_client, index)->ipv6_header_set == true)
+ {
+ if (m_header.DeleteHeaderHdl(get_client_memptr(wan_client, index)->hdr_hdl_v6) == false)
+ {
+ IPACMERR("unable to delete client v6 header for index %d\n", index);
+ return IPACM_FAILURE;
+ }
+ get_client_memptr(wan_client, index)->ipv6_header_set = false;
+ }
+ /* replacing the old mac to new_mac on same entry */
+ get_client_memptr(wan_client, index)->mac[0] = data->mac_addr[0];
+ get_client_memptr(wan_client, index)->mac[1] = data->mac_addr[1];
+ get_client_memptr(wan_client, index)->mac[2] = data->mac_addr[2];
+ get_client_memptr(wan_client, index)->mac[3] = data->mac_addr[3];
+ get_client_memptr(wan_client, index)->mac[4] = data->mac_addr[4];
+ get_client_memptr(wan_client, index)->mac[5] = data->mac_addr[5];
+ index_client = index;
+ return IPACM_SUCCESS;
+ }
+ }
+ }
+ return IPACM_FAILURE;
+}
diff --git a/ipacm/src/IPACM_Wlan.cpp b/ipacm/src/IPACM_Wlan.cpp
index 689cc78..460b6c0 100644
--- a/ipacm/src/IPACM_Wlan.cpp
+++ b/ipacm/src/IPACM_Wlan.cpp
@@ -651,6 +651,35 @@
}
break;
}
+#ifdef IPA_MTU_EVENT_MAX
+ case IPA_MTU_UPDATE:
+ {
+ IPACMDBG_H("Received IPA_MTU_UPDATE");
+ ipacm_event_mtu_info *evt_data = (ipacm_event_mtu_info *)param;
+ ipa_mtu_info *data = &(evt_data->mtu_info);
+
+ /* IPA_IP_MAX means both ipv4 and ipv6 */
+ if ((data->ip_type == IPA_IP_v4 || data->ip_type == IPA_IP_MAX) && IPACM_Wan::isWanUP(ipa_if_num))
+ {
+ handle_private_subnet_android(IPA_IP_v4);
+ }
+
+ /* IPA_IP_MAX means both ipv4 and ipv6 */
+ if ((data->ip_type == IPA_IP_v6 || data->ip_type == IPA_IP_MAX) && IPACM_Wan::isWanUP_V6(ipa_if_num))
+ {
+ //check if the prefix + MTU rules are installed
+ if (ipv6_prefix_flt_rule_hdl[0] && ipv6_prefix_flt_rule_hdl[1]) {
+ modify_ipv6_prefix_flt_rule(IPACM_Wan::backhaul_ipv6_prefix);
+ }
+ else
+ {
+ IPACMERR("failed to update prefix MTU rules, no prefix rules set");
+ }
+ }
+ }
+ break;
+#endif
+
#else
case IPA_HANDLE_WAN_UP:
IPACMDBG_H("Received IPA_HANDLE_WAN_UP event\n");