sdm660-common: data-ipa-cfg-mgr: Merge tag 'LA.UM.8.2.r1-06900-sdm660.0'
From https://source.codeaurora.org/quic/la/platform/vendor/qcom-opensource/data-ipa-cfg-mgr "LA.UM.8.2.r1-06900-sdm660.0" Change-Id: I7385f0516558bbc313843efe0c7ea5d7286be042
This commit is contained in:
parent
a07824280f
commit
712e313a89
7 changed files with 192 additions and 3 deletions
|
@ -68,6 +68,7 @@ private:
|
||||||
bool isCTReg;
|
bool isCTReg;
|
||||||
bool isNatThreadStart;
|
bool isNatThreadStart;
|
||||||
bool WanUp;
|
bool WanUp;
|
||||||
|
bool isProcessCTDone;
|
||||||
NatApp *nat_inst;
|
NatApp *nat_inst;
|
||||||
|
|
||||||
int NatIfaceCnt;
|
int NatIfaceCnt;
|
||||||
|
@ -77,6 +78,7 @@ private:
|
||||||
uint32_t nonnat_iface_ipv4_addr[MAX_IFACE_ADDRESS];
|
uint32_t nonnat_iface_ipv4_addr[MAX_IFACE_ADDRESS];
|
||||||
uint32_t sta_clnt_ipv4_addr[MAX_STA_CLNT_IFACES];
|
uint32_t sta_clnt_ipv4_addr[MAX_STA_CLNT_IFACES];
|
||||||
IPACM_Config *pConfig;
|
IPACM_Config *pConfig;
|
||||||
|
struct nf_conntrack **ct_entries;
|
||||||
#ifdef CT_OPT
|
#ifdef CT_OPT
|
||||||
IPACM_LanToLan *p_lan2lan;
|
IPACM_LanToLan *p_lan2lan;
|
||||||
#endif
|
#endif
|
||||||
|
@ -104,6 +106,7 @@ public:
|
||||||
char wan_ifname[IPA_IFACE_NAME_LEN];
|
char wan_ifname[IPA_IFACE_NAME_LEN];
|
||||||
uint32_t wan_ipaddr;
|
uint32_t wan_ipaddr;
|
||||||
ipacm_wan_iface_type backhaul_mode;
|
ipacm_wan_iface_type backhaul_mode;
|
||||||
|
bool isReadCTDone;
|
||||||
IPACM_ConntrackListener();
|
IPACM_ConntrackListener();
|
||||||
void event_callback(ipa_cm_event_id, void *data);
|
void event_callback(ipa_cm_event_id, void *data);
|
||||||
inline bool isWanUp()
|
inline bool isWanUp()
|
||||||
|
@ -116,6 +119,8 @@ public:
|
||||||
void HandleSTAClientAddEvt(uint32_t);
|
void HandleSTAClientAddEvt(uint32_t);
|
||||||
void HandleSTAClientDelEvt(uint32_t);
|
void HandleSTAClientDelEvt(uint32_t);
|
||||||
int CreateConnTrackThreads(void);
|
int CreateConnTrackThreads(void);
|
||||||
|
void readConntrack(void);
|
||||||
|
void processConntrack(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern IPACM_ConntrackListener *CtList;
|
extern IPACM_ConntrackListener *CtList;
|
||||||
|
|
|
@ -109,6 +109,11 @@ extern "C"
|
||||||
#define NUM_IPV6_PREFIX_FLT_RULE 1
|
#define NUM_IPV6_PREFIX_FLT_RULE 1
|
||||||
#define NUM_IPV6_PREFIX_MTU_RULE 1
|
#define NUM_IPV6_PREFIX_MTU_RULE 1
|
||||||
|
|
||||||
|
#define MAX_CONNTRACK_ENTRIES 100
|
||||||
|
#define CT_ENTRIES_BUFFER_SIZE 8096
|
||||||
|
#define LOOPBACK_MASK 0xFF000000
|
||||||
|
#define LOOPBACK_ADDR 0x7F000000
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------
|
/*---------------------------------------------------------------------------
|
||||||
Return values indicating error status
|
Return values indicating error status
|
||||||
---------------------------------------------------------------------------*/
|
---------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -19,6 +19,9 @@ BOARD_PLATFORM_LIST := msm8909
|
||||||
BOARD_PLATFORM_LIST += msm8916
|
BOARD_PLATFORM_LIST += msm8916
|
||||||
BOARD_PLATFORM_LIST += msm8917
|
BOARD_PLATFORM_LIST += msm8917
|
||||||
BOARD_PLATFORM_LIST += qm215
|
BOARD_PLATFORM_LIST += qm215
|
||||||
|
ifeq ($(TARGET_BOARD_SUFFIX),_gvmq)
|
||||||
|
BOARD_PLATFORM_LIST += msmnile
|
||||||
|
endif
|
||||||
BOARD_IPAv3_LIST := msm8998
|
BOARD_IPAv3_LIST := msm8998
|
||||||
BOARD_IPAv3_LIST += sdm845
|
BOARD_IPAv3_LIST += sdm845
|
||||||
BOARD_IPAv3_LIST += sdm710
|
BOARD_IPAv3_LIST += sdm710
|
||||||
|
|
|
@ -421,6 +421,17 @@ void* IPACM_ConntrackClient::TCPRegisterWithConnTrack(void *)
|
||||||
unsigned subscrips = 0;
|
unsigned subscrips = 0;
|
||||||
|
|
||||||
IPACMDBG("\n");
|
IPACMDBG("\n");
|
||||||
|
/* In Android we get conntrack handles once after tethering is enabled but we
|
||||||
|
loose connections info for embedded traffic if running before. So no NAT
|
||||||
|
entries are added for embedded traffic due to which we see NAT exception and
|
||||||
|
data takes S/W path which results in less throughput. Hence for embedded
|
||||||
|
traffic info, framework sends conntrack dump before providing handles. Here
|
||||||
|
reading ct entries before creating filter on Fd in order to have NAT entries
|
||||||
|
for both TCP/UDP embedded traffic. */
|
||||||
|
if(CtList != NULL && !CtList->isReadCTDone)
|
||||||
|
{
|
||||||
|
CtList->readConntrack();
|
||||||
|
}
|
||||||
|
|
||||||
pClient = IPACM_ConntrackClient::GetInstance();
|
pClient = IPACM_ConntrackClient::GetInstance();
|
||||||
if(pClient == NULL)
|
if(pClient == NULL)
|
||||||
|
|
|
@ -35,6 +35,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "IPACM_EvtDispatcher.h"
|
#include "IPACM_EvtDispatcher.h"
|
||||||
#include "IPACM_Iface.h"
|
#include "IPACM_Iface.h"
|
||||||
#include "IPACM_Wan.h"
|
#include "IPACM_Wan.h"
|
||||||
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
|
||||||
IPACM_ConntrackListener::IPACM_ConntrackListener()
|
IPACM_ConntrackListener::IPACM_ConntrackListener()
|
||||||
{
|
{
|
||||||
|
@ -43,11 +44,14 @@ IPACM_ConntrackListener::IPACM_ConntrackListener()
|
||||||
isNatThreadStart = false;
|
isNatThreadStart = false;
|
||||||
isCTReg = false;
|
isCTReg = false;
|
||||||
WanUp = false;
|
WanUp = false;
|
||||||
|
isReadCTDone = false;
|
||||||
|
isProcessCTDone = false;
|
||||||
nat_inst = NatApp::GetInstance();
|
nat_inst = NatApp::GetInstance();
|
||||||
|
|
||||||
NatIfaceCnt = 0;
|
NatIfaceCnt = 0;
|
||||||
StaClntCnt = 0;
|
StaClntCnt = 0;
|
||||||
pNatIfaces = NULL;
|
pNatIfaces = NULL;
|
||||||
|
ct_entries = NULL;
|
||||||
pConfig = IPACM_Config::GetInstance();;
|
pConfig = IPACM_Config::GetInstance();;
|
||||||
|
|
||||||
memset(nat_iface_ipv4_addr, 0, sizeof(nat_iface_ipv4_addr));
|
memset(nat_iface_ipv4_addr, 0, sizeof(nat_iface_ipv4_addr));
|
||||||
|
@ -97,6 +101,10 @@ void IPACM_ConntrackListener::event_callback(ipa_cm_event_id evt,
|
||||||
IPACMDBG_H("Received IPA_HANDLE_WAN_UP event\n");
|
IPACMDBG_H("Received IPA_HANDLE_WAN_UP event\n");
|
||||||
CreateConnTrackThreads();
|
CreateConnTrackThreads();
|
||||||
TriggerWANUp(data);
|
TriggerWANUp(data);
|
||||||
|
if(isReadCTDone && !isProcessCTDone)
|
||||||
|
{
|
||||||
|
processConntrack();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IPA_HANDLE_WAN_DOWN:
|
case IPA_HANDLE_WAN_DOWN:
|
||||||
|
@ -1201,3 +1209,157 @@ void IPACM_ConntrackListener::HandleSTAClientDelEvt(uint32_t clnt_ip_addr)
|
||||||
nat_inst->FlushTempEntries(clnt_ip_addr, false);
|
nat_inst->FlushTempEntries(clnt_ip_addr, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isLocalHostAddr(uint32_t src_ip_addr, uint32_t dst_ip_addr) {
|
||||||
|
|
||||||
|
src_ip_addr = ntohl(src_ip_addr);
|
||||||
|
dst_ip_addr = ntohl(dst_ip_addr);
|
||||||
|
if ((src_ip_addr & LOOPBACK_MASK) == LOOPBACK_ADDR || (dst_ip_addr & LOOPBACK_MASK) == LOOPBACK_ADDR) /* (loopback) */
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IPACM_ConntrackListener::readConntrack() {
|
||||||
|
|
||||||
|
IPACM_ConntrackClient *pClient;
|
||||||
|
int len_fil = 0, recv_bytes = -1, index = 0, len =0;
|
||||||
|
char buffer[CT_ENTRIES_BUFFER_SIZE];
|
||||||
|
char *buf = &buffer[0];
|
||||||
|
struct nf_conntrack *ct;
|
||||||
|
struct nlmsghdr *nl_header;
|
||||||
|
static struct sockaddr_nl nlAddr = {
|
||||||
|
.nl_family = AF_NETLINK
|
||||||
|
};
|
||||||
|
unsigned int addr_len = sizeof(nlAddr);
|
||||||
|
|
||||||
|
pClient = IPACM_ConntrackClient::GetInstance();
|
||||||
|
len = MAX_CONNTRACK_ENTRIES * sizeof(struct nf_conntrack **);
|
||||||
|
|
||||||
|
ct_entries = (struct nf_conntrack **) malloc(len);
|
||||||
|
memset(ct_entries, 0, len);
|
||||||
|
|
||||||
|
if( pClient->fd_tcp < 0)
|
||||||
|
{
|
||||||
|
IPACMDBG_H("Invalid fd %d \n",pClient->fd_tcp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
IPACMDBG_H("receiving conntrack entries started.\n");
|
||||||
|
while(len_fil < sizeof(buffer) && index < MAX_CONNTRACK_ENTRIES)
|
||||||
|
{
|
||||||
|
recv_bytes = recvfrom( pClient->fd_tcp, buf, sizeof(buffer)-len_fil, 0, (struct sockaddr *)&nlAddr, (socklen_t *)&addr_len);
|
||||||
|
if(recv_bytes < 0)
|
||||||
|
{
|
||||||
|
IPACMDBG_H("error in receiving conntrack entries %d%s",errno, strerror(errno));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nl_header = (struct nlmsghdr *)buf;
|
||||||
|
|
||||||
|
if (NLMSG_OK(nl_header, recv_bytes) == 0 || nl_header->nlmsg_type == NLMSG_ERROR)
|
||||||
|
{
|
||||||
|
IPACMDBG_H("recv_bytes is %d\n",recv_bytes);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ct = nfct_new();
|
||||||
|
if (ct != NULL)
|
||||||
|
{
|
||||||
|
int parseResult = nfct_parse_conntrack((nf_conntrack_msg_type) NFCT_T_ALL,nl_header, ct);
|
||||||
|
if(parseResult != NFCT_T_ERROR)
|
||||||
|
{
|
||||||
|
ct_entries[index++] = ct;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IPACMDBG_H("error in parsing %d%s \n", errno, strerror(errno));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IPACMDBG_H("ct allocation failed");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((nl_header->nlmsg_type & NLM_F_MULTI) == 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
len_fil += recv_bytes;
|
||||||
|
buf = buf + recv_bytes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isReadCTDone = true;
|
||||||
|
IPACMDBG_H("receiving conntrack entries ended.\n");
|
||||||
|
if(isWanUp() && !isProcessCTDone)
|
||||||
|
{
|
||||||
|
IPACMDBG_H("wan is up, process ct entries \n");
|
||||||
|
processConntrack();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IPACM_ConntrackListener::processConntrack() {
|
||||||
|
|
||||||
|
uint8_t ip_type;
|
||||||
|
int index = 0;
|
||||||
|
ipacm_ct_evt_data *ct_data;
|
||||||
|
enum nf_conntrack_msg_type type = NFCT_T_ALL;
|
||||||
|
IPACMDBG_H("process conntrack started \n");
|
||||||
|
if(ct_entries != NULL)
|
||||||
|
{
|
||||||
|
while(ct_entries[index] != NULL)
|
||||||
|
{
|
||||||
|
ip_type = nfct_get_attr_u8(ct_entries[index], ATTR_REPL_L3PROTO);
|
||||||
|
if(!(AF_INET6 == ip_type) && isLocalHostAddr(nfct_get_attr_u32(ct_entries[index], ATTR_ORIG_IPV4_SRC),
|
||||||
|
nfct_get_attr_u32(ct_entries[index], ATTR_ORIG_IPV4_DST)))
|
||||||
|
{
|
||||||
|
IPACMDBG_H(" loopback entry \n");
|
||||||
|
goto IGNORE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef CT_OPT
|
||||||
|
if(AF_INET6 == ip_type)
|
||||||
|
{
|
||||||
|
IPACMDBG("Ignoring ipv6(%d) connections\n", ip_type);
|
||||||
|
goto IGNORE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ct_data = (ipacm_ct_evt_data *)malloc(sizeof(ipacm_ct_evt_data));
|
||||||
|
if(ct_data == NULL)
|
||||||
|
{
|
||||||
|
IPACMERR("unable to allocate memory \n");
|
||||||
|
goto IGNORE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ct_data->ct = ct_entries[index];
|
||||||
|
ct_data->type = type;
|
||||||
|
|
||||||
|
#ifdef CT_OPT
|
||||||
|
if(AF_INET6 == ip_type)
|
||||||
|
{
|
||||||
|
ProcessCTV6Message(ct_data);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
ProcessCTMessage(ct_data);
|
||||||
|
#endif
|
||||||
|
index++;
|
||||||
|
free(ct_data);
|
||||||
|
continue;
|
||||||
|
IGNORE:
|
||||||
|
nfct_destroy(ct_entries[index]);
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IPACMDBG_H("ct entry is null\n");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
isProcessCTDone = true;
|
||||||
|
free(ct_entries);
|
||||||
|
IPACMDBG_H("process conntrack ended \n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
BOARD_PLATFORM_LIST := msm8909
|
BOARD_PLATFORM_LIST := msm8909
|
||||||
BOARD_PLATFORM_LIST += msm8916
|
BOARD_PLATFORM_LIST += msm8916
|
||||||
BOARD_PLATFORM_LIST += msm8917
|
BOARD_PLATFORM_LIST += msm8917
|
||||||
|
ifeq ($(TARGET_BOARD_SUFFIX),_gvmq)
|
||||||
|
BOARD_PLATFORM_LIST += msmnile
|
||||||
|
endif
|
||||||
TARGET_DISABLE_IPANAT := false
|
TARGET_DISABLE_IPANAT := false
|
||||||
|
|
||||||
ifeq ($(TARGET_USES_QMAA),true)
|
ifeq ($(TARGET_USES_QMAA),true)
|
||||||
|
|
Loading…
Reference in a new issue