Merge "ipacm: clean upstream if STA disconnected earlier"
diff --git a/ipacm/src/IPACM_CmdQueue.cpp b/ipacm/src/IPACM_CmdQueue.cpp
index c612b7f..3a2d470 100644
--- a/ipacm/src/IPACM_CmdQueue.cpp
+++ b/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 @@
MessageQueue *MsgQueueExternal = NULL;
Message *item = NULL;
param = NULL;
+ const char *eventName = NULL;
IPACMDBG("MessageQueue::Process()\n");
@@ -160,8 +161,12 @@
}
else
{
- IPACMDBG("Get event %s from internal 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 internal queue.\n",
+ eventName);
+ }
}
if(item == NULL)
@@ -196,7 +201,7 @@
return NULL;
}
- IPACMDBG("Processing item %p event ID: %d\n",item,item->evt.data.event);
+ IPACMDBG("Processing item %pK event ID: %d\n",item,item->evt.data.event);
item->evt.callback_ptr(&item->evt.data);
delete item;
item = NULL;
diff --git a/ipacm/src/IPACM_ConntrackClient.cpp b/ipacm/src/IPACM_ConntrackClient.cpp
index 3eab6fa..8a2499c 100644
--- a/ipacm/src/IPACM_ConntrackClient.cpp
+++ b/ipacm/src/IPACM_ConntrackClient.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
@@ -177,8 +177,6 @@
/* retrieve bridge interface ipv4 address */
memset(&ifr, 0, sizeof(struct ifreq));
ifr.ifr_addr.sa_family = AF_INET;
- (void)strlcpy(ifr.ifr_name, IPACM_Iface::ipacmcfg->ipa_virtual_iface_name, sizeof(ifr.ifr_name));
- IPACMDBG("bridge interface name (%s)\n", ifr.ifr_name);
if(strlen(IPACM_Iface::ipacmcfg->ipa_virtual_iface_name) >= sizeof(ifr.ifr_name))
{
@@ -187,6 +185,8 @@
close(fd);
return -1;
}
+ (void)strlcpy(ifr.ifr_name, IPACM_Iface::ipacmcfg->ipa_virtual_iface_name, sizeof(ifr.ifr_name));
+ IPACMDBG("bridge interface name (%s)\n", ifr.ifr_name);
ret = ioctl(fd, SIOCGIFADDR, &ifr);
if (ret < 0)
diff --git a/ipacm/src/IPACM_ConntrackListener.cpp b/ipacm/src/IPACM_ConntrackListener.cpp
index 4a0c1c1..29a70b9 100644
--- a/ipacm/src/IPACM_ConntrackListener.cpp
+++ b/ipacm/src/IPACM_ConntrackListener.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
@@ -1037,9 +1037,9 @@
nat_entry.ct = ct;
nat_entry.type = type;
- memset(&rule, 0, sizeof(rule));
- IPACMDBG("Received type:%d with proto:%d\n", type, l4proto);
- status = nfct_get_attr_u32(ct, ATTR_STATUS);
+ memset(&rule, 0, sizeof(rule));
+ IPACMDBG("Received type:%d with proto:%d\n", type, l4proto);
+ status = nfct_get_attr_u32(ct, ATTR_STATUS);
/* Retrieve Protocol */
rule.protocol = nfct_get_attr_u8(ct, ATTR_REPL_L4PROTO);
@@ -1089,47 +1089,40 @@
#ifdef CT_OPT
HandleLan2Lan(ct, type, &rule);
#endif
- return;
+ IPACMDBG("Neither source Nor destination nat\n");
+ goto IGNORE;
}
- }
+ }
- if(IPS_DST_NAT == status || IPS_SRC_NAT == status)
- {
- PopulateTCPorUDPEntry(ct, status, &rule);
- rule.public_ip = wan_ipaddr;
- }
- else
- {
- IPACMDBG("Neither source Nor destination nat\n");
- goto IGNORE;
- }
+ PopulateTCPorUDPEntry(ct, status, &rule);
+ rule.public_ip = wan_ipaddr;
- if (rule.private_ip != wan_ipaddr)
- {
- isAdd = AddIface(&rule, &nat_entry.isTempEntry);
- if (!isAdd)
- {
- goto IGNORE;
- }
- }
- else
- {
- if (isStaMode)
- {
- IPACMDBG("In STA mode, ignore connections destinated to STA interface\n");
- goto IGNORE;
- }
+ if (rule.private_ip != wan_ipaddr)
+ {
+ isAdd = AddIface(&rule, &nat_entry.isTempEntry);
+ if (!isAdd)
+ {
+ goto IGNORE;
+ }
+ }
+ else
+ {
+ if (isStaMode)
+ {
+ IPACMDBG("In STA mode, ignore connections destinated to STA interface\n");
+ goto IGNORE;
+ }
- IPACMDBG("For embedded connections add dummy nat rule\n");
- IPACMDBG("Change private port %d to %d\n",
- rule.private_port, rule.public_port);
- rule.private_port = rule.public_port;
- }
+ IPACMDBG("For embedded connections add dummy nat rule\n");
+ IPACMDBG("Change private port %d to %d\n",
+ rule.private_port, rule.public_port);
+ rule.private_port = rule.public_port;
+ }
- CheckSTAClient(&rule, &nat_entry.isTempEntry);
- nat_entry.rule = &rule;
- AddORDeleteNatEntry(&nat_entry);
- return;
+ CheckSTAClient(&rule, &nat_entry.isTempEntry);
+ nat_entry.rule = &rule;
+ AddORDeleteNatEntry(&nat_entry);
+ return;
IGNORE:
IPACMDBG_H("ignoring below Nat Entry\n");
diff --git a/ipacm/src/IPACM_Conntrack_NATApp.cpp b/ipacm/src/IPACM_Conntrack_NATApp.cpp
index 27bf95a..4004597 100644
--- a/ipacm/src/IPACM_Conntrack_NATApp.cpp
+++ b/ipacm/src/IPACM_Conntrack_NATApp.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
@@ -94,11 +94,7 @@
}
memset(pALGPorts, 0, sizeof(ipacm_alg) * nALGPort);
- if(pConfig->GetAlgPorts(nALGPort, pALGPorts) != 0)
- {
- IPACMERR("Unable to retrieve ALG prots\n");
- goto fail;
- }
+ pConfig->GetAlgPorts(nALGPort, pALGPorts);
IPACMDBG("Printing %d alg ports information\n", nALGPort);
for(int cnt=0; cnt<nALGPort; cnt++)
@@ -106,12 +102,23 @@
IPACMDBG("%d: Proto[%d], port[%d]\n", cnt, pALGPorts[cnt].protocol, pALGPorts[cnt].port);
}
}
+ else
+ {
+ IPACMERR("Unable to retrieve ALG prot count\n");
+ goto fail;
+ }
return 0;
fail:
- free(cache);
- free(pALGPorts);
+ if(cache != NULL)
+ {
+ free(cache);
+ }
+ if(pALGPorts != NULL)
+ {
+ free(pALGPorts);
+ }
return -1;
}
diff --git a/ipacm/src/IPACM_EvtDispatcher.cpp b/ipacm/src/IPACM_EvtDispatcher.cpp
index edb5901..2914f66 100644
--- a/ipacm/src/IPACM_EvtDispatcher.cpp
+++ b/ipacm/src/IPACM_EvtDispatcher.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
@@ -92,7 +92,7 @@
IPACMDBG("Enqueing item\n");
MsgQueue->enqueue(item);
- IPACMDBG("Enqueued item %p\n", item);
+ IPACMDBG("Enqueued item %pK\n", item);
if(pthread_cond_signal(&cond_var) != 0)
{
@@ -141,7 +141,7 @@
if(data->evt_data != NULL)
{
- IPACMDBG("free the event:%d data: %p\n", data->event, data->evt_data);
+ IPACMDBG("free the event:%d data: %pK\n", data->event, data->evt_data);
free(data->evt_data);
}
return;
diff --git a/ipacm/src/IPACM_Filtering.cpp b/ipacm/src/IPACM_Filtering.cpp
index 411fe90..3545d81 100644
--- a/ipacm/src/IPACM_Filtering.cpp
+++ b/ipacm/src/IPACM_Filtering.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
@@ -87,7 +87,7 @@
retval = ioctl(fd, IPA_IOC_ADD_FLT_RULE, ruleTable);
if (retval != 0)
{
- IPACMERR("Failed adding Filtering rule %p\n", ruleTable);
+ IPACMERR("Failed adding Filtering rule %pK\n", ruleTable);
PERROR("unable to add filter rule:");
for (int cnt = 0; cnt < ruleTable->num_rules; cnt++)
@@ -110,7 +110,7 @@
}
}
- IPACMDBG("Added Filtering rule %p\n", ruleTable);
+ IPACMDBG("Added Filtering rule %pK\n", ruleTable);
return true;
}
@@ -138,13 +138,13 @@
if (retval != 0)
{
- IPACMERR("Failed adding Filtering rule %p\n", ruleTable);
+ IPACMERR("Failed adding Filtering rule %pK\n", ruleTable);
return false;
}
- IPACMDBG("Added Filtering rule %p\n", ruleTable);
+ IPACMDBG("Added Filtering rule %pK\n", ruleTable);
#else
if (ruleTable)
- IPACMERR("Not support adding Filtering rule %p\n", ruleTable);
+ IPACMERR("Not support adding Filtering rule %pK\n", ruleTable);
#endif
return true;
}
@@ -156,11 +156,11 @@
retval = ioctl(fd, IPA_IOC_DEL_FLT_RULE, ruleTable);
if (retval != 0)
{
- IPACMERR("Failed deleting Filtering rule %p\n", ruleTable);
+ IPACMERR("Failed deleting Filtering rule %pK\n", ruleTable);
return false;
}
- IPACMDBG("Deleted Filtering rule %p\n", ruleTable);
+ IPACMDBG("Deleted Filtering rule %pK\n", ruleTable);
return true;
}
@@ -450,7 +450,7 @@
ret = ioctl(fd_wwan_ioctl, WAN_IOC_ADD_FLT_RULE_EX, &qmi_rule_ex_msg);
if (ret != 0)
{
- IPACMERR("Failed adding Filtering rule %p with ret %d\n ", &qmi_rule_ex_msg, ret);
+ IPACMERR("Failed adding Filtering rule %pK with ret %d\n ", &qmi_rule_ex_msg, ret);
close(fd_wwan_ioctl);
return false;
}
@@ -474,12 +474,12 @@
ret = ioctl(fd_wwan_ioctl, WAN_IOC_ADD_FLT_RULE_INDEX, table);
if (ret != 0)
{
- IPACMERR("Failed adding filtering rule index %p with ret %d\n", table, ret);
+ IPACMERR("Failed adding filtering rule index %pK with ret %d\n", table, ret);
close(fd_wwan_ioctl);
return false;
}
- IPACMDBG("Added Filtering rule index %p\n", table);
+ IPACMDBG("Added Filtering rule index %pK\n", table);
close(fd_wwan_ioctl);
return true;
}
@@ -520,7 +520,7 @@
ret = ioctl(fd, IPA_IOC_MDFY_FLT_RULE, ruleTable);
if (ret != 0)
{
- IPACMERR("Failed modifying filtering rule %p\n", ruleTable);
+ IPACMERR("Failed modifying filtering rule %pK\n", ruleTable);
for (i = 0; i < ruleTable->num_rules; i++)
{
diff --git a/ipacm/src/IPACM_Lan.cpp b/ipacm/src/IPACM_Lan.cpp
index a1d2ab6..532269f 100644
--- a/ipacm/src/IPACM_Lan.cpp
+++ b/ipacm/src/IPACM_Lan.cpp
@@ -193,6 +193,14 @@
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) /* LTE */
+ {
+ IPACMDBG_H(" Skip the Upstream falg 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 @@
}
int ipa_interface_index;
+ uint32_t i;
ipacm_ext_prop* ext_prop;
ipacm_event_iface_up_tehter* data_wan_tether;
@@ -516,6 +525,45 @@
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("unbale 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)
{
@@ -847,6 +895,14 @@
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");
diff --git a/ipacm/src/IPACM_OffloadManager.cpp b/ipacm/src/IPACM_OffloadManager.cpp
index a42f919..85ef7e4 100644
--- a/ipacm/src/IPACM_OffloadManager.cpp
+++ b/ipacm/src/IPACM_OffloadManager.cpp
@@ -442,6 +442,17 @@
/* reset the stats when switch from LTE->STA */
if (index != default_gw_index) {
IPACMDBG_H(" interface switched to %s\n", upstream_name);
+ if (upstream_v4_up == true) {
+ IPACMDBG_H("clean upstream for ipv4-fam(%d) upstream_v4_up(%d)\n", gw_addr_v4.fam, upstream_v4_up);
+ post_route_evt(IPA_IP_v4, default_gw_index, IPA_WAN_UPSTREAM_ROUTE_DEL_EVENT, gw_addr_v4);
+ upstream_v4_up = false;
+ }
+ if (upstream_v6_up == true) {
+ IPACMDBG_H("clean upstream for ipv6-fam(%d) upstream_v6_up(%d)\n", gw_addr_v6.fam, upstream_v6_up);
+ post_route_evt(IPA_IP_v6, default_gw_index, IPA_WAN_UPSTREAM_ROUTE_DEL_EVENT, gw_addr_v6);
+ upstream_v6_up = false;
+ }
+ default_gw_index = INVALID_IFACE;
if(memcmp(upstream_name, "wlan0", sizeof("wlan0")) == 0)
{
IPACMDBG_H("switch to STA mode, need reset wlan-fw stats\n");