From 53eb9cc4729cd0717dd3f7509f58f70ef8cfa6e6 Mon Sep 17 00:00:00 2001 From: Jabiyeff Date: Sat, 31 Oct 2020 23:41:31 +0400 Subject: [PATCH] santoni: Update data-ipa-cfg-mgr from LA.UM.9.6.2.r1-02500-89xx.0 Signed-off-by: Jabiyeff --- data-ipa-cfg-mgr/hal/Android.bp | 26 + data-ipa-cfg-mgr/hal/Android.mk | 29 - data-ipa-cfg-mgr/ipacm/Android.bp | 72 ++ data-ipa-cfg-mgr/ipacm/inc/IPACM_Config.h | 4 + .../ipacm/inc/IPACM_ConntrackListener.h | 2 +- data-ipa-cfg-mgr/ipacm/inc/IPACM_Defs.h | 4 - data-ipa-cfg-mgr/ipacm/src/Android.mk | 145 ---- data-ipa-cfg-mgr/ipacm/src/IPACM_Config.cpp | 23 + .../ipacm/src/IPACM_ConntrackClient.cpp | 11 - .../ipacm/src/IPACM_ConntrackListener.cpp | 99 ++- .../ipacm/src/IPACM_Conntrack_NATApp.cpp | 16 +- .../ipacm/src/IPACM_Filtering.cpp | 498 +++++------ data-ipa-cfg-mgr/ipacm/src/IPACM_Iface.cpp | 68 +- .../ipacm/src/IPACM_IfaceManager.cpp | 5 +- data-ipa-cfg-mgr/ipacm/src/IPACM_Lan.cpp | 812 +++++++++--------- data-ipa-cfg-mgr/ipacm/src/IPACM_Main.cpp | 36 +- data-ipa-cfg-mgr/ipacm/src/IPACM_Netlink.cpp | 1 - .../ipacm/src/IPACM_OffloadManager.cpp | 24 +- data-ipa-cfg-mgr/ipacm/src/IPACM_Wan.cpp | 356 ++++---- data-ipa-cfg-mgr/ipacm/src/IPACM_Wlan.cpp | 62 +- data-ipa-cfg-mgr/ipacm_vendor_product.mk | 44 + data-ipa-cfg-mgr/ipanat/Android.bp | 28 + data-ipa-cfg-mgr/ipanat/inc/ipa_nat_drvi.h | 3 +- data-ipa-cfg-mgr/ipanat/src/Android.mk | 43 - 24 files changed, 1208 insertions(+), 1203 deletions(-) create mode 100644 data-ipa-cfg-mgr/hal/Android.bp delete mode 100644 data-ipa-cfg-mgr/hal/Android.mk create mode 100644 data-ipa-cfg-mgr/ipacm/Android.bp delete mode 100644 data-ipa-cfg-mgr/ipacm/src/Android.mk create mode 100644 data-ipa-cfg-mgr/ipanat/Android.bp delete mode 100644 data-ipa-cfg-mgr/ipanat/src/Android.mk diff --git a/data-ipa-cfg-mgr/hal/Android.bp b/data-ipa-cfg-mgr/hal/Android.bp new file mode 100644 index 00000000..14d37457 --- /dev/null +++ b/data-ipa-cfg-mgr/hal/Android.bp @@ -0,0 +1,26 @@ +cc_library_shared { + name: "liboffloadhal", + srcs: [ + "src/CtUpdateAmbassador.cpp", + "src/HAL.cpp", + "src/IpaEventRelay.cpp", + "src/LocalLogBuffer.cpp", + "src/OffloadStatistics.cpp", + "src/PrefixParser.cpp", + ], + + shared_libs: [ + "libhidlbase", + "liblog", + "libcutils", + "libdl", + "libbase", + "libutils", + "libhardware_legacy", + "libhardware", + "android.hardware.tetheroffload.config@1.0", + "android.hardware.tetheroffload.control@1.0", + ], + export_include_dirs: ["inc"], + vendor: true, +} diff --git a/data-ipa-cfg-mgr/hal/Android.mk b/data-ipa-cfg-mgr/hal/Android.mk deleted file mode 100644 index 3ea338fe..00000000 --- a/data-ipa-cfg-mgr/hal/Android.mk +++ /dev/null @@ -1,29 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_ARM_MODE := arm -LOCAL_SRC_FILES := src/CtUpdateAmbassador.cpp \ - src/HAL.cpp \ - src/IpaEventRelay.cpp \ - src/LocalLogBuffer.cpp \ - src/OffloadStatistics.cpp \ - src/PrefixParser.cpp -LOCAL_C_INCLUDES := $(LOCAL_PATH)/inc -LOCAL_MODULE := liboffloadhal - -#LOCAL_CPP_FLAGS := -Wall -Werror -LOCAL_SHARED_LIBRARIES := libhidlbase \ - liblog \ - libcutils \ - libdl \ - libbase \ - libutils \ - libhardware_legacy \ - libhardware \ - android.hardware.tetheroffload.config@1.0 \ - android.hardware.tetheroffload.control@1.0 -LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/inc -LOCAL_VENDOR_MODULE := true -LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib -LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64 -include $(BUILD_SHARED_LIBRARY) diff --git a/data-ipa-cfg-mgr/ipacm/Android.bp b/data-ipa-cfg-mgr/ipacm/Android.bp new file mode 100644 index 00000000..c2d25a23 --- /dev/null +++ b/data-ipa-cfg-mgr/ipacm/Android.bp @@ -0,0 +1,72 @@ + +cc_binary { + name: "ipacm", + + local_include_dirs: ["src"] + ["inc"], + header_libs: ["generated_kernel_headers"], + + cflags: ["-v"] + ["-DFEATURE_IPA_ANDROID"] + ["-DFEATURE_IPACM_RESTART"] + [ + "-DFEATURE_IPACM_HAL", + "-DDEBUG", + "-Wall", + "-Werror", + "-Wno-error=macro-redefined", + ], + + srcs: [ + "src/IPACM_Main.cpp", + "src/IPACM_EvtDispatcher.cpp", + "src/IPACM_Config.cpp", + "src/IPACM_CmdQueue.cpp", + "src/IPACM_Filtering.cpp", + "src/IPACM_Routing.cpp", + "src/IPACM_Header.cpp", + "src/IPACM_Lan.cpp", + "src/IPACM_Iface.cpp", + "src/IPACM_Wlan.cpp", + "src/IPACM_Wan.cpp", + "src/IPACM_IfaceManager.cpp", + "src/IPACM_Neighbor.cpp", + "src/IPACM_Netlink.cpp", + "src/IPACM_Xml.cpp", + "src/IPACM_Conntrack_NATApp.cpp", + "src/IPACM_ConntrackClient.cpp", + "src/IPACM_ConntrackListener.cpp", + "src/IPACM_Log.cpp", + "src/IPACM_OffloadManager.cpp", + "src/IPACM_LanToLan.cpp", + ], + + init_rc: ["src/ipacm.rc"], + clang: true, + vendor: true, + + shared_libs: [ + "liboffloadhal", + "libipanat", + "libxml2", + "libnfnetlink", + "libnetfilter_conntrack", + "libhidlbase", + "liblog", + "libcutils", + "libdl", + "libbase", + "libutils", + "libhardware_legacy", + "libhardware", + "android.hardware.tetheroffload.config@1.0", + "android.hardware.tetheroffload.control@1.0", + ], +} + +//############################################################################### + +prebuilt_etc { + name: "IPACM_cfg.xml", + + vendor: true, + owner: "ipacm", + src: "src/IPACM_cfg.xml", + +} diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Config.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Config.h index 2792f626..1915fbc7 100644 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Config.h +++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Config.h @@ -261,6 +261,10 @@ class IPACM_Config enum ipa_hw_type GetIPAVer(bool get = false); + bool isEthBridgingSupported(); + + bool isIPAv3Supported(); + int Init(void); inline bool isPrivateSubnet(uint32_t ip_addr) diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_ConntrackListener.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_ConntrackListener.h index 6cc4188b..78314989 100644 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_ConntrackListener.h +++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_ConntrackListener.h @@ -119,7 +119,7 @@ class IPACM_ConntrackListener : public IPACM_Listener void HandleSTAClientAddEvt(uint32_t); void HandleSTAClientDelEvt(uint32_t); int CreateConnTrackThreads(void); - void readConntrack(void); + void readConntrack(int fd); void processConntrack(void); }; diff --git a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Defs.h b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Defs.h index f1113e8b..e60516ea 100644 --- a/data-ipa-cfg-mgr/ipacm/inc/IPACM_Defs.h +++ b/data-ipa-cfg-mgr/ipacm/inc/IPACM_Defs.h @@ -97,11 +97,7 @@ extern "C" #define IPA_DEVICE_NAME "/dev/ipa" #define MAX_NUM_PROP 2 -#ifndef FEATURE_IPA_V3 -#define IPA_MAX_FLT_RULE 50 -#else #define IPA_MAX_FLT_RULE 100 -#endif #define TCP_FIN_SHIFT 16 #define TCP_SYN_SHIFT 17 diff --git a/data-ipa-cfg-mgr/ipacm/src/Android.mk b/data-ipa-cfg-mgr/ipacm/src/Android.mk deleted file mode 100644 index f3534103..00000000 --- a/data-ipa-cfg-mgr/ipacm/src/Android.mk +++ /dev/null @@ -1,145 +0,0 @@ -TARGET_DISABLE_IPACM := false - -ifeq ($(TARGET_USES_QMAA),true) -ifneq ($(TARGET_USES_QMAA_OVERRIDE_DATA),true) - TARGET_DISABLE_IPACM := true -endif #TARGET_USES_QMAA_OVERRIDE_DATA -endif #TARGET_USES_QMAA - -BOARD_IPA_LOW_RAM_EXCP_LIST := bengal - -ifeq ($(TARGET_HAS_LOW_RAM),true) -ifneq ($(call is-board-platform-in-list,$(BOARD_IPA_LOW_RAM_EXCP_LIST)),true) - TARGET_DISABLE_IPACM := true -endif -endif - -ifneq ($(TARGET_DISABLE_IPACM),true) -BOARD_PLATFORM_LIST := msm8909 -BOARD_PLATFORM_LIST += msm8916 -BOARD_PLATFORM_LIST += msm8917 -BOARD_PLATFORM_LIST += qm215 -BOARD_IPAv3_LIST := msm8998 -BOARD_IPAv3_LIST += sdm845 -BOARD_IPAv3_LIST += sdm710 -BOARD_IPAv3_LIST += msmnile -BOARD_IPAv3_LIST += kona -BOARD_IPAv3_LIST += $(MSMSTEPPE) -BOARD_IPAv3_LIST += $(TRINKET) -BOARD_IPAv3_LIST += lito -BOARD_IPAv3_LIST += atoll -BOARD_IPAv3_LIST += bengal -BOARD_ETH_BRIDGE_LIST := msmnile -BOARD_ETH_BRIDGE_LIST += kona - -ifneq ($(call is-board-platform-in-list,$(BOARD_PLATFORM_LIST)),true) -ifneq (,$(filter $(QCOM_BOARD_PLATFORMS),$(TARGET_BOARD_PLATFORM))) -ifneq (, $(filter aarch64 arm arm64, $(TARGET_ARCH))) - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../src -LOCAL_C_INCLUDES += $(LOCAL_PATH)/../inc - -LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include -LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr - -LOCAL_CFLAGS := -v -LOCAL_CFLAGS += -DFEATURE_IPA_ANDROID -LOCAL_CFLAGS += -DFEATURE_IPACM_RESTART - -ifeq ($(call is-board-platform-in-list,$(BOARD_ETH_BRIDGE_LIST)),true) -LOCAL_CFLAGS += -DFEATURE_ETH_BRIDGE_LE -endif - -LOCAL_CFLAGS += -DFEATURE_IPACM_HAL -Wall -Werror -Wno-error=macro-redefined -ifneq (,$(filter userdebug eng, $(TARGET_BUILD_VARIANT))) -LOCAL_CFLAGS += -DDEBUG -endif - -ifeq ($(call is-board-platform-in-list,$(BOARD_IPAv3_LIST)),true) -LOCAL_CFLAGS += -DFEATURE_IPA_V3 -endif - -filetoadd = bionic/libc/kernel/arch-arm/asm/posix_types.h -LOCAL_CFLAGS += $(shell if [ -a $(filetoadd) ] ; then echo -include $(filetoadd) ; fi ;) -filetoadd = bionic/libc/kernel/arch-arm/asm/byteorder.h -LOCAL_CFLAGS += $(shell if [ -a $(filetoadd) ] ; then echo -include $(filetoadd) ; fi ;) - -LOCAL_SRC_FILES := IPACM_Main.cpp \ - IPACM_EvtDispatcher.cpp \ - IPACM_Config.cpp \ - IPACM_CmdQueue.cpp \ - IPACM_Filtering.cpp \ - IPACM_Routing.cpp \ - IPACM_Header.cpp \ - IPACM_Lan.cpp \ - IPACM_Iface.cpp \ - IPACM_Wlan.cpp \ - IPACM_Wan.cpp \ - IPACM_IfaceManager.cpp \ - IPACM_Neighbor.cpp \ - IPACM_Netlink.cpp \ - IPACM_Xml.cpp \ - IPACM_Conntrack_NATApp.cpp\ - IPACM_ConntrackClient.cpp \ - IPACM_ConntrackListener.cpp \ - IPACM_Log.cpp \ - IPACM_OffloadManager.cpp \ - IPACM_LanToLan.cpp - -LOCAL_MODULE := ipacm -LOCAL_INIT_RC := ipacm.rc -LOCAL_CLANG := false -LOCAL_MODULE_TAGS := optional - -LOCAL_SHARED_LIBRARIES := liboffloadhal -LOCAL_SHARED_LIBRARIES += libipanat -LOCAL_SHARED_LIBRARIES += libxml2 -LOCAL_SHARED_LIBRARIES += libnfnetlink -LOCAL_SHARED_LIBRARIES += libnetfilter_conntrack -LOCAL_SHARED_LIBRARIES += libhidlbase \ - liblog \ - libcutils \ - libdl \ - libbase \ - libutils \ - libhardware_legacy \ - libhardware \ - android.hardware.tetheroffload.config@1.0 \ - android.hardware.tetheroffload.control@1.0 - -LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_EXECUTABLES) - -LOCAL_CLANG := true -include $(BUILD_EXECUTABLE) - -################################################################################ - -define ADD_TEST - -include $(CLEAR_VARS) -LOCAL_MODULE := $1 -LOCAL_SRC_FILES := $1 -LOCAL_MODULE_CLASS := ipacm -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE_PATH := $(TARGET_OUT_ETC) -include $(BUILD_PREBUILT) - -endef - -include $(CLEAR_VARS) -LOCAL_MODULE := IPACM_cfg.xml -LOCAL_MODULE_CLASS := ETC -LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR_ETC) -LOCAL_MODULE_TAGS := optional -LOCAL_SRC_FILES := $(LOCAL_MODULE) -LOCAL_MODULE_OWNER := ipacm -include $(BUILD_PREBUILT) - -endif # $(TARGET_ARCH) -endif -endif -endif diff --git a/data-ipa-cfg-mgr/ipacm/src/IPACM_Config.cpp b/data-ipa-cfg-mgr/ipacm/src/IPACM_Config.cpp index 781f1cbf..c396c6cd 100644 --- a/data-ipa-cfg-mgr/ipacm/src/IPACM_Config.cpp +++ b/data-ipa-cfg-mgr/ipacm/src/IPACM_Config.cpp @@ -905,3 +905,26 @@ enum ipa_hw_type IPACM_Config::GetIPAVer(bool get) IPACMDBG_H("IPA version is %d.\n", ver); return ver; } + +bool IPACM_Config::isEthBridgingSupported() +{ + enum ipa_hw_type hw_type; + + hw_type = GetIPAVer(); + +#ifdef IPA_HW_v4_7 + return ((hw_type >= IPA_HW_v4_5) && + (hw_type != IPA_HW_v4_7)); +#else + return (hw_type >= IPA_HW_v4_5); +#endif +} + +bool IPACM_Config::isIPAv3Supported() +{ + enum ipa_hw_type hw_type; + + hw_type = GetIPAVer(); + + return (hw_type >= IPA_HW_v3_0); +} diff --git a/data-ipa-cfg-mgr/ipacm/src/IPACM_ConntrackClient.cpp b/data-ipa-cfg-mgr/ipacm/src/IPACM_ConntrackClient.cpp index dabd8e67..f6bc9a61 100644 --- a/data-ipa-cfg-mgr/ipacm/src/IPACM_ConntrackClient.cpp +++ b/data-ipa-cfg-mgr/ipacm/src/IPACM_ConntrackClient.cpp @@ -421,17 +421,6 @@ void* IPACM_ConntrackClient::TCPRegisterWithConnTrack(void *) unsigned subscrips = 0; 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(); if(pClient == NULL) diff --git a/data-ipa-cfg-mgr/ipacm/src/IPACM_ConntrackListener.cpp b/data-ipa-cfg-mgr/ipacm/src/IPACM_ConntrackListener.cpp index baddb4d2..9d064426 100644 --- a/data-ipa-cfg-mgr/ipacm/src/IPACM_ConntrackListener.cpp +++ b/data-ipa-cfg-mgr/ipacm/src/IPACM_ConntrackListener.cpp @@ -1219,25 +1219,26 @@ bool isLocalHostAddr(uint32_t src_ip_addr, uint32_t dst_ip_addr) { return false; } -void IPACM_ConntrackListener::readConntrack() { +void IPACM_ConntrackListener::readConntrack(int fd) { - IPACM_ConntrackClient *pClient; - int len_fil = 0, recv_bytes = -1, index = 0, len =0; + int 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 + struct iovec iov = { + .iov_base = buffer, + .iov_len = CT_ENTRIES_BUFFER_SIZE, + }; + struct sockaddr_nl addr; + struct msghdr msg = { + .msg_name = &addr, + .msg_namelen = sizeof(struct sockaddr_nl), + .msg_iov = &iov, + .msg_iovlen = 1, + .msg_control = NULL, + .msg_controllen = 0, + .msg_flags = 0, }; - unsigned int addr_len = sizeof(nlAddr); - - pClient = IPACM_ConntrackClient::GetInstance(); - if(pClient == NULL) - { - IPACMERR("unable to get conntrack client instance\n"); - return; - } len = MAX_CONNTRACK_ENTRIES * sizeof(struct nf_conntrack **); @@ -1249,17 +1250,18 @@ void IPACM_ConntrackListener::readConntrack() { } memset(ct_entries, 0, len); - if( pClient->fd_tcp < 0) + if( fd < 0) { - IPACMDBG_H("Invalid fd %d \n",pClient->fd_tcp); + IPACMDBG_H("Invalid fd %d \n",fd); free(ct_entries); return; } - IPACMDBG_H("receiving conntrack entries started.\n"); - while(len_fil < sizeof(buffer) && index < MAX_CONNTRACK_ENTRIES) + len = CT_ENTRIES_BUFFER_SIZE; + while (len > 0) { - recv_bytes = recvfrom( pClient->fd_tcp, buf, sizeof(buffer)-len_fil, 0, (struct sockaddr *)&nlAddr, (socklen_t *)&addr_len); + memset(buffer, 0, CT_ENTRIES_BUFFER_SIZE); + recv_bytes = recvmsg(fd, &msg, 0); if(recv_bytes < 0) { IPACMDBG_H("error in receiving conntrack entries %d%s",errno, strerror(errno)); @@ -1267,42 +1269,45 @@ void IPACM_ConntrackListener::readConntrack() { } else { - nl_header = (struct nlmsghdr *)buf; - - if (NLMSG_OK(nl_header, recv_bytes) == 0 || nl_header->nlmsg_type == NLMSG_ERROR) + len -= recv_bytes; + nl_header = (struct nlmsghdr *)buffer; + IPACMDBG_H("Number of bytes:%d to parse\n", recv_bytes); + while(NLMSG_OK(nl_header, recv_bytes) && (index < MAX_CONNTRACK_ENTRIES)) { - 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) + if (nl_header->nlmsg_type == NLMSG_ERROR) + { + IPACMDBG_H("Error, recv_bytes is %d\n",recv_bytes); + break; + } + ct = nfct_new(); + if (ct != NULL) { - ct_entries[index++] = ct; + 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("error in parsing %d%s \n", errno, strerror(errno)); + IPACMDBG_H("ct allocation failed"); } + if (nl_header->nlmsg_type == NLMSG_DONE) + { + IPACMDBG_H("Message is done.\n"); + break; + } + nl_header = NLMSG_NEXT(nl_header, recv_bytes); } - 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"); + IPACMDBG_H("receiving conntrack entries ended. No of entries: %d\n", index); if(isWanUp() && !isProcessCTDone) { IPACMDBG_H("wan is up, process ct entries \n"); @@ -1324,7 +1329,7 @@ void IPACM_ConntrackListener::processConntrack() { 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), + if((AF_INET == 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"); @@ -1372,6 +1377,6 @@ void IPACM_ConntrackListener::processConntrack() { } isProcessCTDone = true; free(ct_entries); - IPACMDBG_H("process conntrack ended \n"); + IPACMDBG_H("process conntrack ended. Number of entries:%d \n", index); return; } diff --git a/data-ipa-cfg-mgr/ipacm/src/IPACM_Conntrack_NATApp.cpp b/data-ipa-cfg-mgr/ipacm/src/IPACM_Conntrack_NATApp.cpp index 0cf101ff..a9c7140c 100644 --- a/data-ipa-cfg-mgr/ipacm/src/IPACM_Conntrack_NATApp.cpp +++ b/data-ipa-cfg-mgr/ipacm/src/IPACM_Conntrack_NATApp.cpp @@ -195,12 +195,6 @@ int NatApp::AddTable(uint32_t pub_ip, uint8_t mux_id) } } - /* configure NAT initialization paramater */ - pub_ip_addr = pub_ip; - pub_mux_id = mux_id; - IPACMDBG(" Set pub_mux_id: %d\t", pub_mux_id); - - /* Add back the cached NAT-entry */ if (pub_ip == pub_ip_addr_pre) { @@ -228,8 +222,6 @@ int NatApp::AddTable(uint32_t pub_ip, uint8_t mux_id) /* send connections info to pcie modem only with DL direction */ if ((CtList->backhaul_mode == Q6_MHI_WAN) && (cache[cnt].dst_nat == true || cache[cnt].protocol == IPPROTO_TCP)) { - /* propagate pub_ip info */ - cache[cnt].public_ip = pub_ip; ret = AddConnection(&cache[cnt]); if(ret > 0) { @@ -254,6 +246,9 @@ int NatApp::AddTable(uint32_t pub_ip, uint8_t mux_id) } } + pub_ip_addr = pub_ip; + pub_mux_id = mux_id; + IPACMDBG(" Set pub_mux_id: %d\t", pub_mux_id); return 0; } @@ -551,9 +546,8 @@ int NatApp::AddConnection(const nat_table_entry *rule) flt_rule_entry.rule.to_uc = 0; flt_rule_entry.rule.eq_attrib_type = 1; flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_SRC_PORT; flt_rule_entry.rule.attrib.src_port = rule->target_port; flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_DST_PORT; diff --git a/data-ipa-cfg-mgr/ipacm/src/IPACM_Filtering.cpp b/data-ipa-cfg-mgr/ipacm/src/IPACM_Filtering.cpp index 217f3102..875a7949 100644 --- a/data-ipa-cfg-mgr/ipacm/src/IPACM_Filtering.cpp +++ b/data-ipa-cfg-mgr/ipacm/src/IPACM_Filtering.cpp @@ -46,6 +46,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "IPACM_Filtering.h" #include #include "IPACM_Defs.h" +#include "IPACM_Iface.h" const char *IPACM_Filtering::DEVICE_NAME = "/dev/ipa"; @@ -235,156 +236,162 @@ bool IPACM_Filtering::AddFilteringRule_hw_index(struct ipa_ioc_add_flt_rule *rul bool IPACM_Filtering::AddFilteringRuleAfter_hw_index(struct ipa_ioc_add_flt_rule_after *ruleTable, int hw_counter_index) { bool ret = true; -#ifdef FEATURE_IPA_V3 int retval=0, cnt = 0, len = 0; struct ipa_ioc_add_flt_rule_after_v2 *ruleTable_v2; struct ipa_flt_rule_add_v2 flt_rule_entry; - IPACMDBG("Printing filter add attributes\n"); - IPACMDBG("ep: %d\n", ruleTable->ep); - IPACMDBG("ip type: %d\n", ruleTable->ip); - IPACMDBG("Number of rules: %d\n", ruleTable->num_rules); - IPACMDBG("add_after_hdl: %d\n", ruleTable->add_after_hdl); - IPACMDBG("commit value: %d\n", ruleTable->commit); - - /* change to v2 format*/ - len = sizeof(struct ipa_ioc_add_flt_rule_after_v2); - ruleTable_v2 = (struct ipa_ioc_add_flt_rule_after_v2*)malloc(len); - if (ruleTable_v2 == NULL) + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) { - IPACMERR("Error Locate ipa_ioc_add_flt_rule_after_v2 memory...\n"); - return false; - } - memset(ruleTable_v2, 0, len); - ruleTable_v2->rules = (uint64_t)calloc(ruleTable->num_rules, sizeof(struct ipa_flt_rule_add_v2)); - if (!ruleTable_v2->rules) { - IPACMERR("Failed to allocate memory for filtering rules\n"); - ret = false; - goto fail_tbl; - } + IPACMDBG("Printing filter add attributes\n"); + IPACMDBG("ep: %d\n", ruleTable->ep); + IPACMDBG("ip type: %d\n", ruleTable->ip); + IPACMDBG("Number of rules: %d\n", ruleTable->num_rules); + IPACMDBG("add_after_hdl: %d\n", ruleTable->add_after_hdl); + IPACMDBG("commit value: %d\n", ruleTable->commit); + + /* change to v2 format*/ + len = sizeof(struct ipa_ioc_add_flt_rule_after_v2); + ruleTable_v2 = (struct ipa_ioc_add_flt_rule_after_v2*)malloc(len); + if (ruleTable_v2 == NULL) + { + IPACMERR("Error Locate ipa_ioc_add_flt_rule_after_v2 memory...\n"); + return false; + } + memset(ruleTable_v2, 0, len); + ruleTable_v2->rules = (uint64_t)calloc(ruleTable->num_rules, sizeof(struct ipa_flt_rule_add_v2)); + if (!ruleTable_v2->rules) { + IPACMERR("Failed to allocate memory for filtering rules\n"); + ret = false; + goto fail_tbl; + } - ruleTable_v2->commit = ruleTable->commit; - ruleTable_v2->ep = ruleTable->ep; - ruleTable_v2->ip = ruleTable->ip; - ruleTable_v2->num_rules = ruleTable->num_rules; - ruleTable_v2->add_after_hdl = ruleTable->add_after_hdl; - ruleTable_v2->flt_rule_size = sizeof(struct ipa_flt_rule_add_v2); + ruleTable_v2->commit = ruleTable->commit; + ruleTable_v2->ep = ruleTable->ep; + ruleTable_v2->ip = ruleTable->ip; + ruleTable_v2->num_rules = ruleTable->num_rules; + ruleTable_v2->add_after_hdl = ruleTable->add_after_hdl; + ruleTable_v2->flt_rule_size = sizeof(struct ipa_flt_rule_add_v2); - for (cnt=0; cnt < ruleTable->num_rules; cnt++) - { - memset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add_v2)); - flt_rule_entry.at_rear = ruleTable->rules[cnt].at_rear; - flt_rule_entry.rule.retain_hdr = ruleTable->rules[cnt].rule.retain_hdr; - flt_rule_entry.rule.to_uc = ruleTable->rules[cnt].rule.to_uc; - flt_rule_entry.rule.action = ruleTable->rules[cnt].rule.action; - flt_rule_entry.rule.rt_tbl_hdl = ruleTable->rules[cnt].rule.rt_tbl_hdl; - flt_rule_entry.rule.rt_tbl_idx = ruleTable->rules[cnt].rule.rt_tbl_idx; - flt_rule_entry.rule.eq_attrib_type = ruleTable->rules[cnt].rule.eq_attrib_type; - flt_rule_entry.rule.max_prio = ruleTable->rules[cnt].rule.max_prio; - flt_rule_entry.rule.hashable = ruleTable->rules[cnt].rule.hashable; - flt_rule_entry.rule.rule_id = ruleTable->rules[cnt].rule.rule_id; - flt_rule_entry.rule.set_metadata = ruleTable->rules[cnt].rule.set_metadata; - flt_rule_entry.rule.pdn_idx = ruleTable->rules[cnt].rule.pdn_idx; - memcpy(&flt_rule_entry.rule.eq_attrib, - &ruleTable->rules[cnt].rule.eq_attrib, - sizeof(flt_rule_entry.rule.eq_attrib)); - memcpy(&flt_rule_entry.rule.attrib, - &ruleTable->rules[cnt].rule.attrib, - sizeof(flt_rule_entry.rule.attrib)); - IPACMDBG("Filter rule:%d attrib mask: 0x%x\n", cnt, - ruleTable->rules[cnt].rule.attrib.attrib_mask); - /* 0 means disable hw-counter-sats */ - if (hw_counter_index != 0) + for (cnt=0; cnt < ruleTable->num_rules; cnt++) { - flt_rule_entry.rule.enable_stats = 1; - flt_rule_entry.rule.cnt_idx = hw_counter_index; + memset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add_v2)); + flt_rule_entry.at_rear = ruleTable->rules[cnt].at_rear; + flt_rule_entry.rule.retain_hdr = ruleTable->rules[cnt].rule.retain_hdr; + flt_rule_entry.rule.to_uc = ruleTable->rules[cnt].rule.to_uc; + flt_rule_entry.rule.action = ruleTable->rules[cnt].rule.action; + flt_rule_entry.rule.rt_tbl_hdl = ruleTable->rules[cnt].rule.rt_tbl_hdl; + flt_rule_entry.rule.rt_tbl_idx = ruleTable->rules[cnt].rule.rt_tbl_idx; + flt_rule_entry.rule.eq_attrib_type = ruleTable->rules[cnt].rule.eq_attrib_type; + flt_rule_entry.rule.max_prio = ruleTable->rules[cnt].rule.max_prio; + flt_rule_entry.rule.hashable = ruleTable->rules[cnt].rule.hashable; + flt_rule_entry.rule.rule_id = ruleTable->rules[cnt].rule.rule_id; + flt_rule_entry.rule.set_metadata = ruleTable->rules[cnt].rule.set_metadata; + flt_rule_entry.rule.pdn_idx = ruleTable->rules[cnt].rule.pdn_idx; + memcpy(&flt_rule_entry.rule.eq_attrib, + &ruleTable->rules[cnt].rule.eq_attrib, + sizeof(flt_rule_entry.rule.eq_attrib)); + memcpy(&flt_rule_entry.rule.attrib, + &ruleTable->rules[cnt].rule.attrib, + sizeof(flt_rule_entry.rule.attrib)); + IPACMDBG("Filter rule:%d attrib mask: 0x%x\n", cnt, + ruleTable->rules[cnt].rule.attrib.attrib_mask); + /* 0 means disable hw-counter-sats */ + if (hw_counter_index != 0) + { + flt_rule_entry.rule.enable_stats = 1; + flt_rule_entry.rule.cnt_idx = hw_counter_index; + } + + /* copy to v2 table*/ + memcpy((void *)(ruleTable_v2->rules + (cnt * sizeof(struct ipa_flt_rule_add_v2))), + &flt_rule_entry, sizeof(flt_rule_entry)); } - /* copy to v2 table*/ - memcpy((void *)(ruleTable_v2->rules + (cnt * sizeof(struct ipa_flt_rule_add_v2))), - &flt_rule_entry, sizeof(flt_rule_entry)); - } + retval = ioctl(fd, IPA_IOC_ADD_FLT_RULE_AFTER_V2, ruleTable_v2); + if (retval != 0) + { + IPACMERR("Failed adding Filtering rule %pK\n", ruleTable_v2); + PERROR("unable to add filter rule:"); - retval = ioctl(fd, IPA_IOC_ADD_FLT_RULE_AFTER_V2, ruleTable_v2); - if (retval != 0) - { - IPACMERR("Failed adding Filtering rule %pK\n", ruleTable_v2); - PERROR("unable to add filter rule:"); + for (int cnt = 0; cnt < ruleTable_v2->num_rules; cnt++) + { + if (((struct ipa_flt_rule_add_v2 *)ruleTable_v2->rules)[cnt].status != 0) + { + IPACMERR("Adding Filter rule:%d failed with status:%d\n", + cnt, ((struct ipa_flt_rule_add_v2 *)ruleTable_v2->rules)[cnt].status); + } + } + ret = false; + goto fail_rule; + } - for (int cnt = 0; cnt < ruleTable_v2->num_rules; cnt++) + /* copy results from v2 to v1 format */ + for (int cnt = 0; cnt < ruleTable->num_rules; cnt++) { - if (((struct ipa_flt_rule_add_v2 *)ruleTable_v2->rules)[cnt].status != 0) + /* copy status to v1 format */ + ruleTable->rules[cnt].status = ((struct ipa_flt_rule_add_v2 *)ruleTable_v2->rules)[cnt].status; + ruleTable->rules[cnt].flt_rule_hdl = ((struct ipa_flt_rule_add_v2 *)ruleTable_v2->rules)[cnt].flt_rule_hdl; + + if(((struct ipa_flt_rule_add_v2 *)ruleTable_v2->rules)[cnt].status != 0) { IPACMERR("Adding Filter rule:%d failed with status:%d\n", - cnt, ((struct ipa_flt_rule_add_v2 *)ruleTable_v2->rules)[cnt].status); + cnt, ((struct ipa_flt_rule_add_v2 *) ruleTable_v2->rules)[cnt].status); } } - ret = false; - goto fail_rule; - } - /* copy results from v2 to v1 format */ - for (int cnt = 0; cnt < ruleTable->num_rules; cnt++) - { - /* copy status to v1 format */ - ruleTable->rules[cnt].status = ((struct ipa_flt_rule_add_v2 *)ruleTable_v2->rules)[cnt].status; - ruleTable->rules[cnt].flt_rule_hdl = ((struct ipa_flt_rule_add_v2 *)ruleTable_v2->rules)[cnt].flt_rule_hdl; + IPACMDBG("Added Filtering rule %pK\n", ruleTable_v2); - if(((struct ipa_flt_rule_add_v2 *)ruleTable_v2->rules)[cnt].status != 0) - { - IPACMERR("Adding Filter rule:%d failed with status:%d\n", - cnt, ((struct ipa_flt_rule_add_v2 *) ruleTable_v2->rules)[cnt].status); - } + fail_rule: + if((void *)ruleTable_v2->rules != NULL) + free((void *)ruleTable_v2->rules); + fail_tbl: + if (ruleTable_v2 != NULL) + free(ruleTable_v2); + } + else + { + if (ruleTable) + IPACMERR("Not support adding Filtering rule %pK\n", ruleTable); } - - IPACMDBG("Added Filtering rule %pK\n", ruleTable_v2); - -fail_rule: - if((void *)ruleTable_v2->rules != NULL) - free((void *)ruleTable_v2->rules); -fail_tbl: - if (ruleTable_v2 != NULL) - free(ruleTable_v2); -#else - if (ruleTable) - IPACMERR("Not support adding Filtering rule %pK\n", ruleTable); -#endif return ret; } #endif //IPA_IOCTL_SET_FNR_COUNTER_INFO bool IPACM_Filtering::AddFilteringRuleAfter(struct ipa_ioc_add_flt_rule_after const *ruleTable) { -#ifdef FEATURE_IPA_V3 int retval = 0; - IPACMDBG("Printing filter add attributes\n"); - IPACMDBG("ip type: %d\n", ruleTable->ip); - IPACMDBG("Number of rules: %d\n", ruleTable->num_rules); - IPACMDBG("End point: %d\n", ruleTable->ep); - IPACMDBG("commit value: %d\n", ruleTable->commit); + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + { + IPACMDBG("Printing filter add attributes\n"); + IPACMDBG("ip type: %d\n", ruleTable->ip); + IPACMDBG("Number of rules: %d\n", ruleTable->num_rules); + IPACMDBG("End point: %d\n", ruleTable->ep); + IPACMDBG("commit value: %d\n", ruleTable->commit); - retval = ioctl(fd, IPA_IOC_ADD_FLT_RULE_AFTER, ruleTable); + retval = ioctl(fd, IPA_IOC_ADD_FLT_RULE_AFTER, ruleTable); - for (int cnt = 0; cntnum_rules; cnt++) - { - if(ruleTable->rules[cnt].status != 0) + for (int cnt = 0; cntnum_rules; cnt++) { - IPACMERR("Adding Filter rule:%d failed with status:%d\n", - cnt, ruleTable->rules[cnt].status); + if(ruleTable->rules[cnt].status != 0) + { + IPACMERR("Adding Filter rule:%d failed with status:%d\n", + cnt, ruleTable->rules[cnt].status); + } } - } - if (retval != 0) + if (retval != 0) + { + IPACMERR("Failed adding Filtering rule %pK\n", ruleTable); + return false; + } + IPACMDBG("Added Filtering rule %pK\n", ruleTable); + } + else { - IPACMERR("Failed adding Filtering rule %pK\n", ruleTable); - return false; + if (ruleTable) + IPACMERR("Not support adding Filtering rule %pK\n", ruleTable); } - IPACMDBG("Added Filtering rule %pK\n", ruleTable); -#else - if (ruleTable) - IPACMERR("Not support adding Filtering rule %pK\n", ruleTable); -#endif return true; } @@ -502,9 +509,7 @@ bool IPACM_Filtering::AddWanDLFilteringRule(struct ipa_ioc_add_flt_rule const *r { int ret = 0, cnt, num_rules = 0, pos = 0; ipa_install_fltr_rule_req_msg_v01 qmi_rule_msg; -#ifdef FEATURE_IPA_V3 ipa_install_fltr_rule_req_ex_msg_v01 qmi_rule_ex_msg; -#endif memset(&qmi_rule_msg, 0, sizeof(qmi_rule_msg)); int fd_wwan_ioctl = open(WWAN_QMI_IOCTL_DEVICE_NAME, O_RDWR); @@ -526,175 +531,178 @@ bool IPACM_Filtering::AddWanDLFilteringRule(struct ipa_ioc_add_flt_rule const *r } /* if it is not IPA v3, use old QMI format */ -#ifndef FEATURE_IPA_V3 - if(num_rules > QMI_IPA_MAX_FILTERS_V01) - { - IPACMERR("The number of filtering rules exceed limit.\n"); - close(fd_wwan_ioctl); - return false; - } - else + if (!IPACM_Iface::ipacmcfg->isIPAv3Supported()) { - if (num_rules > 0) + if(num_rules > QMI_IPA_MAX_FILTERS_V01) { - qmi_rule_msg.filter_spec_list_valid = true; + IPACMERR("The number of filtering rules exceed limit.\n"); + close(fd_wwan_ioctl); + return false; } else { - qmi_rule_msg.filter_spec_list_valid = false; - } + if (num_rules > 0) + { + qmi_rule_msg.filter_spec_list_valid = true; + } + else + { + qmi_rule_msg.filter_spec_list_valid = false; + } - qmi_rule_msg.filter_spec_list_len = num_rules; - qmi_rule_msg.source_pipe_index_valid = 0; + qmi_rule_msg.filter_spec_list_len = num_rules; + qmi_rule_msg.source_pipe_index_valid = 0; - IPACMDBG_H("Get %d WAN DL filtering rules in total.\n", num_rules); + IPACMDBG_H("Get %d WAN DL filtering rules in total.\n", num_rules); - if(rule_table_v4 != NULL) - { - for(cnt = rule_table_v4->num_rules - 1; cnt >= 0; cnt--) + if(rule_table_v4 != NULL) { - if (pos < QMI_IPA_MAX_FILTERS_V01) - { - qmi_rule_msg.filter_spec_list[pos].filter_spec_identifier = pos; - qmi_rule_msg.filter_spec_list[pos].ip_type = QMI_IPA_IP_TYPE_V4_V01; - qmi_rule_msg.filter_spec_list[pos].filter_action = GetQmiFilterAction(rule_table_v4->rules[cnt].rule.action); - qmi_rule_msg.filter_spec_list[pos].is_routing_table_index_valid = 1; - qmi_rule_msg.filter_spec_list[pos].route_table_index = rule_table_v4->rules[cnt].rule.rt_tbl_idx; - qmi_rule_msg.filter_spec_list[pos].is_mux_id_valid = 1; - qmi_rule_msg.filter_spec_list[pos].mux_id = mux_id; - memcpy(&qmi_rule_msg.filter_spec_list[pos].filter_rule, - &rule_table_v4->rules[cnt].rule.eq_attrib, - sizeof(struct ipa_filter_rule_type_v01)); - pos++; - } - else + for(cnt = rule_table_v4->num_rules - 1; cnt >= 0; cnt--) { - IPACMERR(" QMI only support max %d rules, current (%d)\n ",QMI_IPA_MAX_FILTERS_V01, pos); + if (pos < QMI_IPA_MAX_FILTERS_V01) + { + qmi_rule_msg.filter_spec_list[pos].filter_spec_identifier = pos; + qmi_rule_msg.filter_spec_list[pos].ip_type = QMI_IPA_IP_TYPE_V4_V01; + qmi_rule_msg.filter_spec_list[pos].filter_action = GetQmiFilterAction(rule_table_v4->rules[cnt].rule.action); + qmi_rule_msg.filter_spec_list[pos].is_routing_table_index_valid = 1; + qmi_rule_msg.filter_spec_list[pos].route_table_index = rule_table_v4->rules[cnt].rule.rt_tbl_idx; + qmi_rule_msg.filter_spec_list[pos].is_mux_id_valid = 1; + qmi_rule_msg.filter_spec_list[pos].mux_id = mux_id; + memcpy(&qmi_rule_msg.filter_spec_list[pos].filter_rule, + &rule_table_v4->rules[cnt].rule.eq_attrib, + sizeof(struct ipa_filter_rule_type_v01)); + pos++; + } + else + { + IPACMERR(" QMI only support max %d rules, current (%d)\n ",QMI_IPA_MAX_FILTERS_V01, pos); + } } } - } - if(rule_table_v6 != NULL) - { - for(cnt = rule_table_v6->num_rules - 1; cnt >= 0; cnt--) + if(rule_table_v6 != NULL) { - if (pos < QMI_IPA_MAX_FILTERS_V01) - { - qmi_rule_msg.filter_spec_list[pos].filter_spec_identifier = pos; - qmi_rule_msg.filter_spec_list[pos].ip_type = QMI_IPA_IP_TYPE_V6_V01; - qmi_rule_msg.filter_spec_list[pos].filter_action = GetQmiFilterAction(rule_table_v6->rules[cnt].rule.action); - qmi_rule_msg.filter_spec_list[pos].is_routing_table_index_valid = 1; - qmi_rule_msg.filter_spec_list[pos].route_table_index = rule_table_v6->rules[cnt].rule.rt_tbl_idx; - qmi_rule_msg.filter_spec_list[pos].is_mux_id_valid = 1; - qmi_rule_msg.filter_spec_list[pos].mux_id = mux_id; - memcpy(&qmi_rule_msg.filter_spec_list[pos].filter_rule, - &rule_table_v6->rules[cnt].rule.eq_attrib, - sizeof(struct ipa_filter_rule_type_v01)); - pos++; - } - else + for(cnt = rule_table_v6->num_rules - 1; cnt >= 0; cnt--) { - IPACMERR(" QMI only support max %d rules, current (%d)\n ",QMI_IPA_MAX_FILTERS_V01, pos); + if (pos < QMI_IPA_MAX_FILTERS_V01) + { + qmi_rule_msg.filter_spec_list[pos].filter_spec_identifier = pos; + qmi_rule_msg.filter_spec_list[pos].ip_type = QMI_IPA_IP_TYPE_V6_V01; + qmi_rule_msg.filter_spec_list[pos].filter_action = GetQmiFilterAction(rule_table_v6->rules[cnt].rule.action); + qmi_rule_msg.filter_spec_list[pos].is_routing_table_index_valid = 1; + qmi_rule_msg.filter_spec_list[pos].route_table_index = rule_table_v6->rules[cnt].rule.rt_tbl_idx; + qmi_rule_msg.filter_spec_list[pos].is_mux_id_valid = 1; + qmi_rule_msg.filter_spec_list[pos].mux_id = mux_id; + memcpy(&qmi_rule_msg.filter_spec_list[pos].filter_rule, + &rule_table_v6->rules[cnt].rule.eq_attrib, + sizeof(struct ipa_filter_rule_type_v01)); + pos++; + } + else + { + IPACMERR(" QMI only support max %d rules, current (%d)\n ",QMI_IPA_MAX_FILTERS_V01, pos); + } } } - } - ret = ioctl(fd_wwan_ioctl, WAN_IOC_ADD_FLT_RULE, &qmi_rule_msg); - if (ret != 0) - { - IPACMERR("Failed adding Filtering rule %p with ret %d\n ", &qmi_rule_msg, ret); - close(fd_wwan_ioctl); - return false; + ret = ioctl(fd_wwan_ioctl, WAN_IOC_ADD_FLT_RULE, &qmi_rule_msg); + if (ret != 0) + { + IPACMERR("Failed adding Filtering rule %p with ret %d\n ", &qmi_rule_msg, ret); + close(fd_wwan_ioctl); + return false; + } } - } /* if it is IPA v3, use new QMI format */ -#else - if(num_rules > QMI_IPA_MAX_FILTERS_EX_V01) - { - IPACMERR("The number of filtering rules exceed limit.\n"); - close(fd_wwan_ioctl); - return false; } else { - memset(&qmi_rule_ex_msg, 0, sizeof(qmi_rule_ex_msg)); - - if (num_rules > 0) + if(num_rules > QMI_IPA_MAX_FILTERS_EX_V01) { - qmi_rule_ex_msg.filter_spec_ex_list_valid = true; + IPACMERR("The number of filtering rules exceed limit.\n"); + close(fd_wwan_ioctl); + return false; } else { - qmi_rule_ex_msg.filter_spec_ex_list_valid = false; - } - qmi_rule_ex_msg.filter_spec_ex_list_len = num_rules; - qmi_rule_ex_msg.source_pipe_index_valid = 0; - - IPACMDBG_H("Get %d WAN DL filtering rules in total.\n", num_rules); + memset(&qmi_rule_ex_msg, 0, sizeof(qmi_rule_ex_msg)); - if(rule_table_v4 != NULL) - { - for(cnt = rule_table_v4->num_rules - 1; cnt >= 0; cnt--) + if (num_rules > 0) { - if (pos < QMI_IPA_MAX_FILTERS_EX_V01) - { - qmi_rule_ex_msg.filter_spec_ex_list[pos].ip_type = QMI_IPA_IP_TYPE_V4_V01; - qmi_rule_ex_msg.filter_spec_ex_list[pos].filter_action = GetQmiFilterAction(rule_table_v4->rules[cnt].rule.action); - qmi_rule_ex_msg.filter_spec_ex_list[pos].is_routing_table_index_valid = 1; - qmi_rule_ex_msg.filter_spec_ex_list[pos].route_table_index = rule_table_v4->rules[cnt].rule.rt_tbl_idx; - qmi_rule_ex_msg.filter_spec_ex_list[pos].is_mux_id_valid = 1; - qmi_rule_ex_msg.filter_spec_ex_list[pos].mux_id = mux_id; - qmi_rule_ex_msg.filter_spec_ex_list[pos].rule_id = rule_table_v4->rules[cnt].rule.rule_id; - qmi_rule_ex_msg.filter_spec_ex_list[pos].is_rule_hashable = rule_table_v4->rules[cnt].rule.hashable; - memcpy(&qmi_rule_ex_msg.filter_spec_ex_list[pos].filter_rule, - &rule_table_v4->rules[cnt].rule.eq_attrib, - sizeof(struct ipa_filter_rule_type_v01)); + qmi_rule_ex_msg.filter_spec_ex_list_valid = true; + } + else + { + qmi_rule_ex_msg.filter_spec_ex_list_valid = false; + } + qmi_rule_ex_msg.filter_spec_ex_list_len = num_rules; + qmi_rule_ex_msg.source_pipe_index_valid = 0; - pos++; - } - else + IPACMDBG_H("Get %d WAN DL filtering rules in total.\n", num_rules); + + if(rule_table_v4 != NULL) + { + for(cnt = rule_table_v4->num_rules - 1; cnt >= 0; cnt--) { - IPACMERR(" QMI only support max %d rules, current (%d)\n ",QMI_IPA_MAX_FILTERS_EX_V01, pos); + if (pos < QMI_IPA_MAX_FILTERS_EX_V01) + { + qmi_rule_ex_msg.filter_spec_ex_list[pos].ip_type = QMI_IPA_IP_TYPE_V4_V01; + qmi_rule_ex_msg.filter_spec_ex_list[pos].filter_action = GetQmiFilterAction(rule_table_v4->rules[cnt].rule.action); + qmi_rule_ex_msg.filter_spec_ex_list[pos].is_routing_table_index_valid = 1; + qmi_rule_ex_msg.filter_spec_ex_list[pos].route_table_index = rule_table_v4->rules[cnt].rule.rt_tbl_idx; + qmi_rule_ex_msg.filter_spec_ex_list[pos].is_mux_id_valid = 1; + qmi_rule_ex_msg.filter_spec_ex_list[pos].mux_id = mux_id; + qmi_rule_ex_msg.filter_spec_ex_list[pos].rule_id = rule_table_v4->rules[cnt].rule.rule_id; + qmi_rule_ex_msg.filter_spec_ex_list[pos].is_rule_hashable = rule_table_v4->rules[cnt].rule.hashable; + memcpy(&qmi_rule_ex_msg.filter_spec_ex_list[pos].filter_rule, + &rule_table_v4->rules[cnt].rule.eq_attrib, + sizeof(struct ipa_filter_rule_type_v01)); + + pos++; + } + else + { + IPACMERR(" QMI only support max %d rules, current (%d)\n ",QMI_IPA_MAX_FILTERS_EX_V01, pos); + } } } - } - if(rule_table_v6 != NULL) - { - for(cnt = rule_table_v6->num_rules - 1; cnt >= 0; cnt--) + if(rule_table_v6 != NULL) { - if (pos < QMI_IPA_MAX_FILTERS_EX_V01) - { - qmi_rule_ex_msg.filter_spec_ex_list[pos].ip_type = QMI_IPA_IP_TYPE_V6_V01; - qmi_rule_ex_msg.filter_spec_ex_list[pos].filter_action = GetQmiFilterAction(rule_table_v6->rules[cnt].rule.action); - qmi_rule_ex_msg.filter_spec_ex_list[pos].is_routing_table_index_valid = 1; - qmi_rule_ex_msg.filter_spec_ex_list[pos].route_table_index = rule_table_v6->rules[cnt].rule.rt_tbl_idx; - qmi_rule_ex_msg.filter_spec_ex_list[pos].is_mux_id_valid = 1; - qmi_rule_ex_msg.filter_spec_ex_list[pos].mux_id = mux_id; - qmi_rule_ex_msg.filter_spec_ex_list[pos].rule_id = rule_table_v6->rules[cnt].rule.rule_id; - qmi_rule_ex_msg.filter_spec_ex_list[pos].is_rule_hashable = rule_table_v6->rules[cnt].rule.hashable; - memcpy(&qmi_rule_ex_msg.filter_spec_ex_list[pos].filter_rule, - &rule_table_v6->rules[cnt].rule.eq_attrib, - sizeof(struct ipa_filter_rule_type_v01)); - - pos++; - } - else + for(cnt = rule_table_v6->num_rules - 1; cnt >= 0; cnt--) { - IPACMERR(" QMI only support max %d rules, current (%d)\n ",QMI_IPA_MAX_FILTERS_EX_V01, pos); + if (pos < QMI_IPA_MAX_FILTERS_EX_V01) + { + qmi_rule_ex_msg.filter_spec_ex_list[pos].ip_type = QMI_IPA_IP_TYPE_V6_V01; + qmi_rule_ex_msg.filter_spec_ex_list[pos].filter_action = GetQmiFilterAction(rule_table_v6->rules[cnt].rule.action); + qmi_rule_ex_msg.filter_spec_ex_list[pos].is_routing_table_index_valid = 1; + qmi_rule_ex_msg.filter_spec_ex_list[pos].route_table_index = rule_table_v6->rules[cnt].rule.rt_tbl_idx; + qmi_rule_ex_msg.filter_spec_ex_list[pos].is_mux_id_valid = 1; + qmi_rule_ex_msg.filter_spec_ex_list[pos].mux_id = mux_id; + qmi_rule_ex_msg.filter_spec_ex_list[pos].rule_id = rule_table_v6->rules[cnt].rule.rule_id; + qmi_rule_ex_msg.filter_spec_ex_list[pos].is_rule_hashable = rule_table_v6->rules[cnt].rule.hashable; + memcpy(&qmi_rule_ex_msg.filter_spec_ex_list[pos].filter_rule, + &rule_table_v6->rules[cnt].rule.eq_attrib, + sizeof(struct ipa_filter_rule_type_v01)); + + pos++; + } + else + { + IPACMERR(" QMI only support max %d rules, current (%d)\n ",QMI_IPA_MAX_FILTERS_EX_V01, pos); + } } } - } - ret = ioctl(fd_wwan_ioctl, WAN_IOC_ADD_FLT_RULE_EX, &qmi_rule_ex_msg); - if (ret != 0) - { - IPACMERR("Failed adding Filtering rule %pK with ret %d\n ", &qmi_rule_ex_msg, ret); - close(fd_wwan_ioctl); - return false; + ret = ioctl(fd_wwan_ioctl, WAN_IOC_ADD_FLT_RULE_EX, &qmi_rule_ex_msg); + if (ret != 0) + { + IPACMERR("Failed adding Filtering rule %pK with ret %d\n ", &qmi_rule_ex_msg, ret); + close(fd_wwan_ioctl); + return false; + } } } -#endif close(fd_wwan_ioctl); return true; diff --git a/data-ipa-cfg-mgr/ipacm/src/IPACM_Iface.cpp b/data-ipa-cfg-mgr/ipacm/src/IPACM_Iface.cpp index c63fa9b6..82829155 100644 --- a/data-ipa-cfg-mgr/ipacm/src/IPACM_Iface.cpp +++ b/data-ipa-cfg-mgr/ipacm/src/IPACM_Iface.cpp @@ -133,9 +133,8 @@ int IPACM_Iface::handle_software_routing_enable(bool mhip) flt_rule_entry.flt_rule_hdl = -1; flt_rule_entry.status = -1; flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule_entry.rule.attrib)); @@ -772,10 +771,11 @@ int IPACM_Iface::init_fl_rule(ipa_ip_type iptype) flt_rule_entry.flt_rule_hdl = -1; flt_rule_entry.status = -1; flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.at_rear = false; - flt_rule_entry.rule.hashable = false; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + { + flt_rule_entry.at_rear = false; + flt_rule_entry.rule.hashable = false; + } IPACMDBG_H("rx property attrib mask:0x%x\n", rx_prop->rx[0].attrib.attrib_mask); memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, @@ -791,19 +791,21 @@ int IPACM_Iface::init_fl_rule(ipa_ip_type iptype) flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR; flt_rule_entry.rule.attrib.u.v4.dst_addr_mask = 0xF0000000; flt_rule_entry.rule.attrib.u.v4.dst_addr = 0xE0000000; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.at_rear = true; - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + { + flt_rule_entry.at_rear = true; + flt_rule_entry.rule.hashable = true; + } memcpy(&(m_pFilteringTable->rules[1]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add)); /* Configuring Broadcast Filtering Rule */ flt_rule_entry.rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF; flt_rule_entry.rule.attrib.u.v4.dst_addr = 0xFFFFFFFF; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.at_rear = true; - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + { + flt_rule_entry.at_rear = true; + flt_rule_entry.rule.hashable = true; + } memcpy(&(m_pFilteringTable->rules[2]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add)); #ifdef IPA_IOCTL_SET_FNR_COUNTER_INFO @@ -886,10 +888,11 @@ int IPACM_Iface::init_fl_rule(ipa_ip_type iptype) flt_rule_entry.rule.attrib.u.v6.dst_addr[1] = 0x00000000; flt_rule_entry.rule.attrib.u.v6.dst_addr[2] = 0x00000000; flt_rule_entry.rule.attrib.u.v6.dst_addr[3] = 0X00000000; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.at_rear = true; - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + { + flt_rule_entry.at_rear = true; + flt_rule_entry.rule.hashable = true; + } memcpy(&(m_pFilteringTable->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add)); /* Configuring fe80::/10 Link-Scoped Unicast Filtering Rule */ @@ -901,10 +904,11 @@ int IPACM_Iface::init_fl_rule(ipa_ip_type iptype) flt_rule_entry.rule.attrib.u.v6.dst_addr[1] = 0x00000000; flt_rule_entry.rule.attrib.u.v6.dst_addr[2] = 0x00000000; flt_rule_entry.rule.attrib.u.v6.dst_addr[3] = 0X00000000; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.at_rear = true; - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + { + flt_rule_entry.at_rear = true; + flt_rule_entry.rule.hashable = true; + } memcpy(&(m_pFilteringTable->rules[1]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add)); /* Configuring fec0::/10 Reserved by IETF Filtering Rule */ @@ -916,10 +920,11 @@ int IPACM_Iface::init_fl_rule(ipa_ip_type iptype) flt_rule_entry.rule.attrib.u.v6.dst_addr[1] = 0x00000000; flt_rule_entry.rule.attrib.u.v6.dst_addr[2] = 0x00000000; flt_rule_entry.rule.attrib.u.v6.dst_addr[3] = 0X00000000; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.at_rear = true; - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + { + flt_rule_entry.at_rear = true; + flt_rule_entry.rule.hashable = true; + } memcpy(&(m_pFilteringTable->rules[2]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add)); /* Configuring fd00::/8 Unique Local Ipv6 Address */ @@ -931,10 +936,11 @@ int IPACM_Iface::init_fl_rule(ipa_ip_type iptype) flt_rule_entry.rule.attrib.u.v6.dst_addr[1] = 0x00000000; flt_rule_entry.rule.attrib.u.v6.dst_addr[2] = 0x00000000; flt_rule_entry.rule.attrib.u.v6.dst_addr[3] = 0X00000000; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.at_rear = true; - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + { + flt_rule_entry.at_rear = true; + flt_rule_entry.rule.hashable = true; + } memcpy(&(m_pFilteringTable->rules[3]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add)); #ifdef FEATURE_IPA_ANDROID diff --git a/data-ipa-cfg-mgr/ipacm/src/IPACM_IfaceManager.cpp b/data-ipa-cfg-mgr/ipacm/src/IPACM_IfaceManager.cpp index 89106fe4..7ba5a809 100644 --- a/data-ipa-cfg-mgr/ipacm/src/IPACM_IfaceManager.cpp +++ b/data-ipa-cfg-mgr/ipacm/src/IPACM_IfaceManager.cpp @@ -406,9 +406,8 @@ int IPACM_IfaceManager::create_iface_instance(ipacm_ifacemgr_data *param) IPACM_EvtDispatcher::registr(IPA_HANDLE_WAN_DOWN_V6, wl); #endif IPACM_EvtDispatcher::registr(IPA_PRIVATE_SUBNET_CHANGE_EVENT, wl); // register for IPA_PRIVATE_SUBNET_CHANGE_EVENT event -#ifdef FEATURE_ETH_BRIDGE_LE - IPACM_EvtDispatcher::registr(IPA_CFG_CHANGE_EVENT, wl); -#endif + if (IPACM_Iface::ipacmcfg->isEthBridgingSupported()) + IPACM_EvtDispatcher::registr(IPA_CFG_CHANGE_EVENT, wl); IPACM_EvtDispatcher::registr(IPA_CRADLE_WAN_MODE_SWITCH, wl); IPACM_EvtDispatcher::registr(IPA_WLAN_LINK_DOWN_EVENT, wl); #ifndef FEATURE_IPA_ANDROID diff --git a/data-ipa-cfg-mgr/ipacm/src/IPACM_Lan.cpp b/data-ipa-cfg-mgr/ipacm/src/IPACM_Lan.cpp index 5e1c4ff6..65bd3cab 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-2019, The Linux Foundation. All rights reserved. +Copyright (c) 2013-2020, 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 @@ -342,20 +342,21 @@ void IPACM_Lan::event_callback(ipa_cm_event_id event, void *param) } #endif -#ifdef FEATURE_ETH_BRIDGE_LE - if(rx_prop != NULL) - { - free(rx_prop); - } - if(tx_prop != NULL) - { - free(tx_prop); - } - if(iface_query != NULL) + if (IPACM_Iface::ipacmcfg->isEthBridgingSupported()) { - free(iface_query); + if(rx_prop != NULL) + { + free(rx_prop); + } + if(tx_prop != NULL) + { + free(tx_prop); + } + if(iface_query != NULL) + { + free(iface_query); + } } -#endif delete this; } break; @@ -1273,12 +1274,15 @@ int IPACM_Lan::handle_wan_down(ipacm_wan_iface_type backhaul_mode) return IPACM_FAILURE; } flt_index.install_status = IPA_QMI_RESULT_SUCCESS_V01; -#ifndef FEATURE_IPA_V3 - flt_index.filter_index_list_len = 0; -#else /* defined (FEATURE_IPA_V3) */ - flt_index.rule_id_valid = 1; - flt_index.rule_id_len = 0; -#endif + if (!IPACM_Iface::ipacmcfg->isIPAv3Supported()) + { + flt_index.filter_index_list_len = 0; + } + else /* IPAv3 */ + { + flt_index.rule_id_valid = 1; + flt_index.rule_id_len = 0; + } flt_index.embedded_pipe_index_valid = 1; flt_index.embedded_pipe_index = ioctl(fd, IPA_IOC_QUERY_EP_MAPPING, IPA_CLIENT_APPS_LAN_WAN_PROD); if ((int)flt_index.embedded_pipe_index == -1) @@ -1371,9 +1375,8 @@ int IPACM_Lan::handle_addr_evt(ipacm_event_data_addr *data) strlcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_lan_v4.name, sizeof(rt_rule->rt_tbl_name)); rt_rule_entry->rule.attrib.u.v4.dst_addr = data->ipv4_addr; rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF; -#ifdef FEATURE_IPA_V3 - rt_rule_entry->rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + rt_rule_entry->rule.hashable = true; if (false == m_routing.AddRoutingRule(rt_rule)) { IPACMERR("Routing rule addition failed!\n"); @@ -1449,9 +1452,8 @@ int IPACM_Lan::handle_addr_evt(ipacm_event_data_addr *data) ipv6_addr[num_dft_rt_v6][1] = data->ipv6_addr[1]; ipv6_addr[num_dft_rt_v6][2] = data->ipv6_addr[2]; ipv6_addr[num_dft_rt_v6][3] = data->ipv6_addr[3]; -#ifdef FEATURE_IPA_V3 - rt_rule_entry->rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + rt_rule_entry->rule.hashable = true; if (false == m_routing.AddRoutingRule(rt_rule)) { IPACMERR("Routing rule addition failed!\n"); @@ -1581,9 +1583,8 @@ int IPACM_Lan::handle_private_subnet(ipa_ip_type iptype) flt_rule_entry.flt_rule_hdl = -1; flt_rule_entry.status = -1; flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; /* Support private subnet feature including guest-AP can't talk to primary AP etc */ flt_rule_entry.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_default_v4.hdl; IPACMDBG_H(" private filter rule use table: %s\n",IPACM_Iface::ipacmcfg->rt_tbl_default_v4.name); @@ -1707,9 +1708,8 @@ int IPACM_Lan::handle_wan_up(ipa_ip_type ip_type) { flt_rule_entry.rule.action = IPA_PASS_TO_SRC_NAT; //IPA_PASS_TO_ROUTING } -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; flt_rule_entry.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_wan_v4.hdl; memcpy(&flt_rule_entry.rule.attrib, @@ -1796,9 +1796,8 @@ int IPACM_Lan::handle_wan_up(ipa_ip_type ip_type) flt_rule_entry.flt_rule_hdl = -1; flt_rule_entry.status = -1; flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; flt_rule_entry.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_v6.hdl; memcpy(&flt_rule_entry.rule.attrib, @@ -2458,9 +2457,8 @@ int IPACM_Lan::handle_eth_client_route_rule(uint8_t *mac_addr, ipa_ip_type iptyp rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF; rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF; rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF; -#ifdef FEATURE_IPA_V3 - rt_rule_entry->rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + rt_rule_entry->rule.hashable = true; if (false == m_routing.AddRoutingRule(rt_rule)) { IPACMERR("Routing rule addition failed!\n"); @@ -2490,9 +2488,8 @@ int IPACM_Lan::handle_eth_client_route_rule(uint8_t *mac_addr, ipa_ip_type iptyp rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF; rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF; rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF; -#ifdef FEATURE_IPA_V3 - rt_rule_entry->rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + rt_rule_entry->rule.hashable = true; if (false == m_routing.AddRoutingRule(rt_rule)) { IPACMERR("Routing rule addition failed!\n"); @@ -2773,9 +2770,8 @@ int IPACM_Lan::handle_odu_route_add() { rt_rule_entry->rule.attrib.u.v4.dst_addr = 0; rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0; -#ifdef FEATURE_IPA_V3 - rt_rule_entry->rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + rt_rule_entry->rule.hashable = true; if (false == m_routing.AddRoutingRule(rt_rule)) { IPACMERR("Routing rule addition failed!\n"); @@ -2798,9 +2794,8 @@ int IPACM_Lan::handle_odu_route_add() rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0; rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0; rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0; -#ifdef FEATURE_IPA_V3 - rt_rule_entry->rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + rt_rule_entry->rule.hashable = true; if (false == m_routing.AddRoutingRule(rt_rule)) { IPACMERR("Routing rule addition failed!\n"); @@ -3281,25 +3276,25 @@ int IPACM_Lan::handle_down_evt() IPACM_Iface::ipacmcfg->DelRmDepend(IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[rx_prop->rx[0].src_pipe]); IPACMDBG_H("Finished delete dependency \n "); } -#ifndef FEATURE_ETH_BRIDGE_LE - free(rx_prop); -#endif + if (!(IPACM_Iface::ipacmcfg->isEthBridgingSupported())) + free(rx_prop); } if (eth_client != NULL) { free(eth_client); } -#ifndef FEATURE_ETH_BRIDGE_LE - if (tx_prop != NULL) - { - free(tx_prop); - } - if (iface_query != NULL) + if (!(IPACM_Iface::ipacmcfg->isEthBridgingSupported())) { - free(iface_query); + if (tx_prop != NULL) + { + free(tx_prop); + } + if (iface_query != NULL) + { + free(iface_query); + } } -#endif is_active = false; post_del_self_evt(); @@ -3356,12 +3351,15 @@ int IPACM_Lan::handle_uplink_filter_rule(ipacm_ext_prop *prop, ipa_ip_type iptyp } flt_index.install_status = IPA_QMI_RESULT_SUCCESS_V01; -#ifndef FEATURE_IPA_V3 - flt_index.filter_index_list_len = prop->num_ext_props; -#else /* defined (FEATURE_IPA_V3) */ - flt_index.rule_id_valid = 1; - flt_index.rule_id_len = prop->num_ext_props; -#endif + if (!IPACM_Iface::ipacmcfg->isIPAv3Supported()) + { + flt_index.filter_index_list_len = prop->num_ext_props; + } + else /* IPAv3 */ + { + flt_index.rule_id_valid = 1; + flt_index.rule_id_len = prop->num_ext_props; + } flt_index.embedded_pipe_index_valid = 1; flt_index.embedded_pipe_index = ioctl(fd, IPA_IOC_QUERY_EP_MAPPING, IPA_CLIENT_APPS_LAN_WAN_PROD); if ((int)flt_index.embedded_pipe_index == -1) @@ -3377,13 +3375,16 @@ int IPACM_Lan::handle_uplink_filter_rule(ipacm_ext_prop *prop, ipa_ip_type iptyp qmap_id = IPACM_Iface::ipacmcfg->GetQmapId(); xlat_debug = IPACM_Wan::getXlat_Mux_Id(); flt_index.embedded_call_mux_id = qmap_id; -#ifndef FEATURE_IPA_V3 - IPACMDBG_H("flt_index: src pipe: %d, num of rules: %d, ebd pipe: %d, mux id: %d, xlat_mux id: %d, wan-debug %d\n", - flt_index.source_pipe_index, flt_index.filter_index_list_len, flt_index.embedded_pipe_index, flt_index.embedded_call_mux_id, xlat_mux_id, xlat_debug); -#else /* defined (FEATURE_IPA_V3) */ - IPACMDBG_H("flt_index: src pipe: %d, num of rules: %d, ebd pipe: %d, mux id: %d, xlat_mux id: %d, wan-debug %d\n", - flt_index.source_pipe_index, flt_index.rule_id_len, flt_index.embedded_pipe_index, flt_index.embedded_call_mux_id, xlat_mux_id, xlat_debug); -#endif + if (!IPACM_Iface::ipacmcfg->isIPAv3Supported()) + { + IPACMDBG_H("flt_index: src pipe: %d, num of rules: %d, ebd pipe: %d, mux id: %d, xlat_mux id: %d, wan-debug %d\n", + flt_index.source_pipe_index, flt_index.filter_index_list_len, flt_index.embedded_pipe_index, flt_index.embedded_call_mux_id, xlat_mux_id, xlat_debug); + } + else /* IPAv3 */ + { + IPACMDBG_H("flt_index: src pipe: %d, num of rules: %d, ebd pipe: %d, mux id: %d, xlat_mux id: %d, wan-debug %d\n", + flt_index.source_pipe_index, flt_index.rule_id_len, flt_index.embedded_pipe_index, flt_index.embedded_call_mux_id, xlat_mux_id, xlat_debug); + } len = sizeof(struct ipa_ioc_add_flt_rule) + prop->num_ext_props * sizeof(struct ipa_flt_rule_add); pFilteringTable = (struct ipa_ioc_add_flt_rule*)malloc(len); if (pFilteringTable == NULL) @@ -3402,10 +3403,9 @@ int IPACM_Lan::handle_uplink_filter_rule(ipacm_ext_prop *prop, ipa_ip_type iptyp memset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add)); // Zero All Fields flt_rule_entry.at_rear = 1; -#ifdef FEATURE_IPA_V3 - if (flt_rule_entry.rule.eq_attrib.ipv4_frag_eq_present) - flt_rule_entry.at_rear = 0; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + if (flt_rule_entry.rule.eq_attrib.ipv4_frag_eq_present) + flt_rule_entry.at_rear = 0; flt_rule_entry.flt_rule_hdl = -1; flt_rule_entry.status = -1; @@ -3482,25 +3482,28 @@ int IPACM_Lan::handle_uplink_filter_rule(ipacm_ext_prop *prop, ipa_ip_type iptyp { flt_rule_entry.rule.eq_attrib.num_offset_meq_32++; 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); - } -#else - if(eq_index == 0) + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) { - flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<2); + 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 { - flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<3); + 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; @@ -3518,88 +3521,95 @@ int IPACM_Lan::handle_uplink_filter_rule(ipacm_ext_prop *prop, ipa_ip_type iptyp { 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) + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) { - flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<3); - } - else - { - 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]; - *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].mask + 4) - = 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]; - *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].mask + 12) - = 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]; - *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].value + 4) - = 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]; - *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].value + 12) - = prefix[IPA_IP_v6].v6Addr[0]; -#else - if(eq_index == 0) - { - flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<9); + if(eq_index == 0) + { + flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<3); + } + else + { + 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]; + *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].mask + 4) + = 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]; + *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].mask + 12) + = 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]; + *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].value + 4) + = 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]; + *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].value + 12) + = prefix[IPA_IP_v6].v6Addr[0]; } else { - flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<10); + if(eq_index == 0) + { + flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<9); + } + else + { + 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]; + *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].mask + 4) + = 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]; + *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].mask + 12) + = 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]; + *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].value + 4) + = 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]; + *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].value + 12) + = prefix[IPA_IP_v6].v6Addr[3]; } - *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].mask + 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]; - *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].mask + 8) - = 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]; - *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].value + 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]; - *(uint32_t *)(flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].value + 8) - = 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]; -#endif flt_rule_entry.rule.eq_attrib.offset_meq_128[eq_index].offset = 8; } else { IPACMERR("Run out of MEQ128 equation.\n"); - flt_rule_entry.rule.eq_attrib.num_offset_meq_128--; + flt_rule_entry.rule.eq_attrib.num_offset_meq_128--; } } -#endif -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = prop->prop[cnt].is_rule_hashable; - flt_rule_entry.rule.rule_id = prop->prop[cnt].rule_id; - if(rx_prop->rx[0].attrib.attrib_mask & IPA_FLT_META_DATA) //turn on meta-data equation +#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) { - flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<9); - flt_rule_entry.rule.eq_attrib.metadata_meq32_present = 1; - flt_rule_entry.rule.eq_attrib.metadata_meq32.offset = 0; - flt_rule_entry.rule.eq_attrib.metadata_meq32.value |= rx_prop->rx[0].attrib.meta_data; - flt_rule_entry.rule.eq_attrib.metadata_meq32.mask |= rx_prop->rx[0].attrib.meta_data_mask; + flt_rule_entry.rule.hashable = prop->prop[cnt].is_rule_hashable; + flt_rule_entry.rule.rule_id = prop->prop[cnt].rule_id; + if(rx_prop->rx[0].attrib.attrib_mask & IPA_FLT_META_DATA) //turn on meta-data equation + { + flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<9); + flt_rule_entry.rule.eq_attrib.metadata_meq32_present = 1; + flt_rule_entry.rule.eq_attrib.metadata_meq32.offset = 0; + flt_rule_entry.rule.eq_attrib.metadata_meq32.value |= rx_prop->rx[0].attrib.meta_data; + flt_rule_entry.rule.eq_attrib.metadata_meq32.mask |= rx_prop->rx[0].attrib.meta_data_mask; + } } -#endif memcpy(&pFilteringTable->rules[cnt], &flt_rule_entry, sizeof(flt_rule_entry)); IPACMDBG_H("Modem UL filtering rule %d has index %d\n", cnt, index); -#ifndef FEATURE_IPA_V3 - flt_index.filter_index_list[cnt].filter_index = index; - flt_index.filter_index_list[cnt].filter_handle = prop->prop[cnt].filter_hdl; -#else /* defined (FEATURE_IPA_V3) */ - flt_index.rule_id[cnt] = prop->prop[cnt].rule_id; -#endif + if (!IPACM_Iface::ipacmcfg->isIPAv3Supported()) + { + flt_index.filter_index_list[cnt].filter_index = index; + flt_index.filter_index_list[cnt].filter_handle = prop->prop[cnt].filter_hdl; + } + else /* IPAv3 */ + { + flt_index.rule_id[cnt] = prop->prop[cnt].rule_id; + } index++; } @@ -3717,12 +3727,15 @@ int IPACM_Lan::handle_wan_down_v6(ipacm_wan_iface_type backhaul_mode) return IPACM_FAILURE; } flt_index.install_status = IPA_QMI_RESULT_SUCCESS_V01; -#ifndef FEATURE_IPA_V3 - flt_index.filter_index_list_len = 0; -#else /* defined (FEATURE_IPA_V3) */ - flt_index.rule_id_valid = 1; - flt_index.rule_id_len = 0; -#endif + if (!IPACM_Iface::ipacmcfg->isIPAv3Supported()) + { + flt_index.filter_index_list_len = 0; + } + else /* IPAv3 */ + { + flt_index.rule_id_valid = 1; + flt_index.rule_id_len = 0; + } flt_index.embedded_pipe_index_valid = 1; flt_index.embedded_pipe_index = ioctl(fd, IPA_IOC_QUERY_EP_MAPPING, IPA_CLIENT_APPS_LAN_WAN_PROD); if ((int)flt_index.embedded_pipe_index == -1) @@ -3947,9 +3960,8 @@ int IPACM_Lan::install_ipv4_icmp_flt_rule() flt_rule_entry.flt_rule_hdl = -1; flt_rule_entry.status = -1; flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule_entry.rule.attrib)); flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_PROTOCOL; @@ -4020,9 +4032,8 @@ int IPACM_Lan::install_ipv6_icmp_flt_rule() flt_rule_entry.flt_rule_hdl = -1; flt_rule_entry.status = -1; flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = false; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = false; 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_NEXT_HDR; flt_rule_entry.rule.attrib.u.v6.next_hdr = (uint8_t)IPACM_FIREWALL_IPPROTO_ICMP6; @@ -4099,9 +4110,8 @@ int IPACM_Lan::add_dummy_private_subnet_flt_rule(ipa_ip_type iptype) flt_rule.flt_rule_hdl = -1; flt_rule.status = -1; flt_rule.rule.action = IPA_PASS_TO_EXCEPTION; -#ifdef FEATURE_IPA_V3 - flt_rule.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule.rule.hashable = true; memcpy(&flt_rule.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule.rule.attrib)); @@ -4334,9 +4344,8 @@ int IPACM_Lan::install_ipv6_prefix_flt_rule(uint32_t* prefix) flt_rule_entry.flt_rule_hdl = -1; flt_rule_entry.status = -1; flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; 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]; @@ -5050,9 +5059,8 @@ int IPACM_Lan::eth_bridge_add_rt_rule(uint8_t *mac, char *rt_tbl_name, uint32_t rt_rule.at_rear = false; rt_rule.status = -1; rt_rule.rt_rule_hdl = -1; -#ifdef FEATURE_IPA_V3 - rt_rule.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + rt_rule.rule.hashable = true; rt_rule.rule.hdr_hdl = 0; rt_rule.rule.hdr_proc_ctx_hdl = hdr_proc_ctx_hdl; @@ -5184,9 +5192,8 @@ int IPACM_Lan::eth_bridge_modify_rt_rule(uint8_t *mac, uint32_t hdr_proc_ctx_hdl rt_rule_entry->rule.hdr_hdl = 0; rt_rule_entry->rule.hdr_proc_ctx_hdl = hdr_proc_ctx_hdl; -#ifdef FEATURE_IPA_V3 - rt_rule_entry->rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + rt_rule_entry->rule.hashable = true; memcpy(&rt_rule_entry->rule.attrib, &tx_prop->tx[index].attrib, sizeof(rt_rule_entry->rule.attrib)); if(peer_l2_hdr_type == IPA_HDR_L2_ETHERNET_II) @@ -5225,90 +5232,92 @@ int IPACM_Lan::eth_bridge_modify_rt_rule(uint8_t *mac, uint32_t hdr_proc_ctx_hdl int IPACM_Lan::eth_bridge_add_flt_rule(uint8_t *mac, uint32_t rt_tbl_hdl, ipa_ip_type iptype, uint32_t *flt_rule_hdl) { int res = IPACM_SUCCESS; - - IPACMDBG_H("Received client MAC 0x%02x%02x%02x%02x%02x%02x.\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); - IPACMDBG_H("Received rt_tbl_hdl :%d iptype %d\n", rt_tbl_hdl,iptype); - *flt_rule_hdl = 0; - -#ifdef FEATURE_IPA_V3 int len; struct ipa_flt_rule_add flt_rule_entry; struct ipa_ioc_add_flt_rule_after *pFilteringTable = NULL; bool result; - if (rx_prop == NULL || tx_prop == NULL) + IPACMDBG_H("Received client MAC 0x%02x%02x%02x%02x%02x%02x.\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + IPACMDBG_H("Received rt_tbl_hdl :%d iptype %d\n", rt_tbl_hdl,iptype); + *flt_rule_hdl = 0; + + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) { - IPACMDBG_H("No rx or tx properties registered for iface %s\n", dev_name); - return IPACM_FAILURE; - } + if (rx_prop == NULL || tx_prop == NULL) + { + IPACMDBG_H("No rx or tx properties registered for iface %s\n", dev_name); + return IPACM_FAILURE; + } - len = sizeof(struct ipa_ioc_add_flt_rule_after) + sizeof(struct ipa_flt_rule_add); - pFilteringTable = (struct ipa_ioc_add_flt_rule_after*)malloc(len); - if (!pFilteringTable) - { - IPACMERR("Failed to allocate ipa_ioc_add_flt_rule_after memory...\n"); - return IPACM_FAILURE; - } - memset(pFilteringTable, 0, len); + len = sizeof(struct ipa_ioc_add_flt_rule_after) + sizeof(struct ipa_flt_rule_add); + pFilteringTable = (struct ipa_ioc_add_flt_rule_after*)malloc(len); + if (!pFilteringTable) + { + IPACMERR("Failed to allocate ipa_ioc_add_flt_rule_after memory...\n"); + return IPACM_FAILURE; + } + memset(pFilteringTable, 0, len); - /* add mac based rule*/ - pFilteringTable->commit = 1; - pFilteringTable->ep = rx_prop->rx[0].src_pipe; - pFilteringTable->ip = iptype; - pFilteringTable->num_rules = 1; - pFilteringTable->add_after_hdl = eth_bridge_flt_rule_offset[iptype]; + /* add mac based rule*/ + pFilteringTable->commit = 1; + pFilteringTable->ep = rx_prop->rx[0].src_pipe; + pFilteringTable->ip = iptype; + pFilteringTable->num_rules = 1; + pFilteringTable->add_after_hdl = eth_bridge_flt_rule_offset[iptype]; - memset(&flt_rule_entry, 0, sizeof(flt_rule_entry)); - flt_rule_entry.at_rear = 1; + memset(&flt_rule_entry, 0, sizeof(flt_rule_entry)); + flt_rule_entry.at_rear = 1; - flt_rule_entry.rule.retain_hdr = 0; - flt_rule_entry.rule.to_uc = 0; - flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; - flt_rule_entry.rule.eq_attrib_type = 0; - flt_rule_entry.rule.rt_tbl_hdl = rt_tbl_hdl; - flt_rule_entry.rule.hashable = true; + flt_rule_entry.rule.retain_hdr = 0; + flt_rule_entry.rule.to_uc = 0; + flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; + flt_rule_entry.rule.eq_attrib_type = 0; + flt_rule_entry.rule.rt_tbl_hdl = rt_tbl_hdl; + flt_rule_entry.rule.hashable = true; - memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule_entry.rule.attrib)); - if(tx_prop->tx[0].hdr_l2_type == IPA_HDR_L2_ETHERNET_II) - { - flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_ETHER_II; - } - else - { - flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_802_3; - } + memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule_entry.rule.attrib)); + if(tx_prop->tx[0].hdr_l2_type == IPA_HDR_L2_ETHERNET_II) + { + flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_ETHER_II; + } + else + { + flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_802_3; + } - memcpy(flt_rule_entry.rule.attrib.dst_mac_addr, mac, sizeof(flt_rule_entry.rule.attrib.dst_mac_addr)); - memset(flt_rule_entry.rule.attrib.dst_mac_addr_mask, 0xFF, sizeof(flt_rule_entry.rule.attrib.dst_mac_addr_mask)); + memcpy(flt_rule_entry.rule.attrib.dst_mac_addr, mac, sizeof(flt_rule_entry.rule.attrib.dst_mac_addr)); + memset(flt_rule_entry.rule.attrib.dst_mac_addr_mask, 0xFF, sizeof(flt_rule_entry.rule.attrib.dst_mac_addr_mask)); - memcpy(&(pFilteringTable->rules[0]), &flt_rule_entry, sizeof(flt_rule_entry)); + memcpy(&(pFilteringTable->rules[0]), &flt_rule_entry, sizeof(flt_rule_entry)); #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.AddFilteringRuleAfter_hw_index(pFilteringTable, IPACM_Iface::ipacmcfg->hw_counter_offset + UL_ALL); - } else { - result = m_filtering.AddFilteringRuleAfter(pFilteringTable); - } + /* 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.AddFilteringRuleAfter_hw_index(pFilteringTable, IPACM_Iface::ipacmcfg->hw_counter_offset + UL_ALL); + } else { + result = m_filtering.AddFilteringRuleAfter(pFilteringTable); + } #else - result = m_filtering.AddFilteringRuleAfter(pFilteringTable); + result = m_filtering.AddFilteringRuleAfter(pFilteringTable); #endif - if (result == false) - { - IPACMERR("Failed to add client filtering rules.\n"); - res = IPACM_FAILURE; - goto end; - } - *flt_rule_hdl = pFilteringTable->rules[0].flt_rule_hdl; + if (result == false) + { + IPACMERR("Failed to add client filtering rules.\n"); + res = IPACM_FAILURE; + goto end; + } + *flt_rule_hdl = pFilteringTable->rules[0].flt_rule_hdl; end: - free(pFilteringTable); -#else - IPACMDBG_H("Received client MAC 0x%02x%02x%02x%02x%02x%02x.\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); - IPACMDBG_H("Not support rt_tbl_hdl %d flt_rule_hdl %p ip-type %d\n", rt_tbl_hdl, flt_rule_hdl, iptype); -#endif + free(pFilteringTable); + } + else + { + IPACMDBG_H("Received client MAC 0x%02x%02x%02x%02x%02x%02x.\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + IPACMDBG_H("Not support rt_tbl_hdl %d flt_rule_hdl %p ip-type %d\n", rt_tbl_hdl, flt_rule_hdl, iptype); + } return res; } @@ -5909,78 +5918,79 @@ int IPACM_Lan::add_l2tp_flt_rule(uint8_t *dst_mac, uint32_t *flt_rule_hdl) struct ipa_ioc_add_flt_rule_after *pFilteringTable = NULL; ipa_ioc_get_rt_tbl rt_tbl; -#ifdef FEATURE_IPA_V3 - if (rx_prop == NULL || tx_prop == NULL) + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) { - IPACMDBG_H("No rx or tx properties registered for iface %s\n", dev_name); - return IPACM_FAILURE; - } + if (rx_prop == NULL || tx_prop == NULL) + { + IPACMDBG_H("No rx or tx properties registered for iface %s\n", dev_name); + return IPACM_FAILURE; + } - len = sizeof(struct ipa_ioc_add_flt_rule_after) + sizeof(struct ipa_flt_rule_add); - pFilteringTable = (struct ipa_ioc_add_flt_rule_after*)malloc(len); - if (!pFilteringTable) - { - IPACMERR("Failed to allocate ipa_ioc_add_flt_rule_after memory...\n"); - return IPACM_FAILURE; - } - memset(pFilteringTable, 0, len); + len = sizeof(struct ipa_ioc_add_flt_rule_after) + sizeof(struct ipa_flt_rule_add); + pFilteringTable = (struct ipa_ioc_add_flt_rule_after*)malloc(len); + if (!pFilteringTable) + { + IPACMERR("Failed to allocate ipa_ioc_add_flt_rule_after memory...\n"); + return IPACM_FAILURE; + } + memset(pFilteringTable, 0, len); - pFilteringTable->commit = 1; - pFilteringTable->ep = rx_prop->rx[0].src_pipe; - pFilteringTable->ip = IPA_IP_v6; - pFilteringTable->num_rules = 1; - pFilteringTable->add_after_hdl = eth_bridge_flt_rule_offset[IPA_IP_v6]; + pFilteringTable->commit = 1; + pFilteringTable->ep = rx_prop->rx[0].src_pipe; + pFilteringTable->ip = IPA_IP_v6; + pFilteringTable->num_rules = 1; + pFilteringTable->add_after_hdl = eth_bridge_flt_rule_offset[IPA_IP_v6]; - fd_ipa = open(IPA_DEVICE_NAME, O_RDWR); - if(fd_ipa == 0) - { - IPACMERR("Failed to open %s\n",IPA_DEVICE_NAME); - free(pFilteringTable); - return IPACM_FAILURE; - } + fd_ipa = open(IPA_DEVICE_NAME, O_RDWR); + if(fd_ipa == 0) + { + IPACMERR("Failed to open %s\n",IPA_DEVICE_NAME); + free(pFilteringTable); + return IPACM_FAILURE; + } - rt_tbl.ip = IPA_IP_v6; - snprintf(rt_tbl.name, sizeof(rt_tbl.name), "l2tp"); - rt_tbl.name[IPA_RESOURCE_NAME_MAX-1] = '\0'; - IPACMDBG_H("This flt rule points to rt tbl %s.\n", rt_tbl.name); - if(m_routing.GetRoutingTable(&rt_tbl) == false) - { - IPACMERR("Failed to get routing table from name\n"); - free(pFilteringTable); - close(fd_ipa); - return IPACM_FAILURE; - } + rt_tbl.ip = IPA_IP_v6; + snprintf(rt_tbl.name, sizeof(rt_tbl.name), "l2tp"); + rt_tbl.name[IPA_RESOURCE_NAME_MAX-1] = '\0'; + IPACMDBG_H("This flt rule points to rt tbl %s.\n", rt_tbl.name); + if(m_routing.GetRoutingTable(&rt_tbl) == false) + { + IPACMERR("Failed to get routing table from name\n"); + free(pFilteringTable); + close(fd_ipa); + return IPACM_FAILURE; + } - memset(&flt_rule_entry, 0, sizeof(flt_rule_entry)); - flt_rule_entry.at_rear = 1; + memset(&flt_rule_entry, 0, sizeof(flt_rule_entry)); + flt_rule_entry.at_rear = 1; - flt_rule_entry.rule.retain_hdr = 0; - flt_rule_entry.rule.to_uc = 0; - flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; - flt_rule_entry.rule.eq_attrib_type = 0; - flt_rule_entry.rule.rt_tbl_hdl = rt_tbl.hdl; - flt_rule_entry.rule.hashable = false; //ETH->WLAN direction rules need to be non-hashable due to encapsulation + flt_rule_entry.rule.retain_hdr = 0; + flt_rule_entry.rule.to_uc = 0; + flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; + flt_rule_entry.rule.eq_attrib_type = 0; + flt_rule_entry.rule.rt_tbl_hdl = rt_tbl.hdl; + flt_rule_entry.rule.hashable = false; //ETH->WLAN direction rules need to be non-hashable due to encapsulation + + memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule_entry.rule.attrib)); - memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule_entry.rule.attrib)); + /* flt rule is matching dst MAC within 62 bytes header */ + flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_L2TP; + memset(flt_rule_entry.rule.attrib.dst_mac_addr_mask, 0xFF, sizeof(flt_rule_entry.rule.attrib.dst_mac_addr_mask)); + memcpy(flt_rule_entry.rule.attrib.dst_mac_addr, dst_mac, sizeof(flt_rule_entry.rule.attrib.dst_mac_addr)); - /* flt rule is matching dst MAC within 62 bytes header */ - flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_L2TP; - memset(flt_rule_entry.rule.attrib.dst_mac_addr_mask, 0xFF, sizeof(flt_rule_entry.rule.attrib.dst_mac_addr_mask)); - memcpy(flt_rule_entry.rule.attrib.dst_mac_addr, dst_mac, sizeof(flt_rule_entry.rule.attrib.dst_mac_addr)); + memcpy(&(pFilteringTable->rules[0]), &flt_rule_entry, sizeof(flt_rule_entry)); + if(m_filtering.AddFilteringRuleAfter(pFilteringTable) == false) + { + IPACMERR("Failed to add client filtering rules.\n"); + free(pFilteringTable); + close(fd_ipa); + return IPACM_FAILURE; + } + *flt_rule_hdl = pFilteringTable->rules[0].flt_rule_hdl; - memcpy(&(pFilteringTable->rules[0]), &flt_rule_entry, sizeof(flt_rule_entry)); - if(m_filtering.AddFilteringRuleAfter(pFilteringTable) == false) - { - IPACMERR("Failed to add client filtering rules.\n"); free(pFilteringTable); close(fd_ipa); - return IPACM_FAILURE; } - *flt_rule_hdl = pFilteringTable->rules[0].flt_rule_hdl; - - free(pFilteringTable); - close(fd_ipa); -#endif return IPACM_SUCCESS; } @@ -6004,123 +6014,123 @@ int IPACM_Lan::add_l2tp_flt_rule(ipa_ip_type iptype, uint8_t *dst_mac, uint32_t struct ipa_ioc_add_flt_rule_after *pFilteringTable = NULL; ipa_ioc_get_rt_tbl rt_tbl; -#ifdef FEATURE_IPA_V3 - if (rx_prop == NULL || tx_prop == NULL) + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) { - IPACMDBG_H("No rx or tx properties registered for iface %s\n", dev_name); - return IPACM_FAILURE; - } + if (rx_prop == NULL || tx_prop == NULL) + { + IPACMDBG_H("No rx or tx properties registered for iface %s\n", dev_name); + return IPACM_FAILURE; + } - IPACMDBG_H("Dst client MAC 0x%02x%02x%02x%02x%02x%02x.\n", dst_mac[0], dst_mac[1], - dst_mac[2], dst_mac[3], dst_mac[4], dst_mac[5]); + IPACMDBG_H("Dst client MAC 0x%02x%02x%02x%02x%02x%02x.\n", dst_mac[0], dst_mac[1], + dst_mac[2], dst_mac[3], dst_mac[4], dst_mac[5]); - len = sizeof(struct ipa_ioc_add_flt_rule_after) + sizeof(struct ipa_flt_rule_add); - pFilteringTable = (struct ipa_ioc_add_flt_rule_after*)malloc(len); - if (!pFilteringTable) - { - IPACMERR("Failed to allocate ipa_ioc_add_flt_rule_after memory...\n"); - return IPACM_FAILURE; - } - memset(pFilteringTable, 0, len); + len = sizeof(struct ipa_ioc_add_flt_rule_after) + sizeof(struct ipa_flt_rule_add); + pFilteringTable = (struct ipa_ioc_add_flt_rule_after*)malloc(len); + if (!pFilteringTable) + { + IPACMERR("Failed to allocate ipa_ioc_add_flt_rule_after memory...\n"); + return IPACM_FAILURE; + } + memset(pFilteringTable, 0, len); - pFilteringTable->commit = 1; - pFilteringTable->ep = rx_prop->rx[0].src_pipe; - pFilteringTable->ip = iptype; - pFilteringTable->num_rules = 1; - pFilteringTable->add_after_hdl = eth_bridge_flt_rule_offset[iptype]; + pFilteringTable->commit = 1; + pFilteringTable->ep = rx_prop->rx[0].src_pipe; + pFilteringTable->ip = iptype; + pFilteringTable->num_rules = 1; + pFilteringTable->add_after_hdl = eth_bridge_flt_rule_offset[iptype]; - /* =========== add first pass flt rule (match dst MAC) ============= */ - rt_tbl.ip = iptype; - snprintf(rt_tbl.name, sizeof(rt_tbl.name), "l2tp"); - IPACMDBG_H("This flt rule points to rt tbl %s.\n", rt_tbl.name); + /* =========== add first pass flt rule (match dst MAC) ============= */ + rt_tbl.ip = iptype; + snprintf(rt_tbl.name, sizeof(rt_tbl.name), "l2tp"); + IPACMDBG_H("This flt rule points to rt tbl %s.\n", rt_tbl.name); - if(m_routing.GetRoutingTable(&rt_tbl) == false) - { - IPACMERR("Failed to get routing table.\n"); - free(pFilteringTable); - return IPACM_FAILURE; - } + if(m_routing.GetRoutingTable(&rt_tbl) == false) + { + IPACMERR("Failed to get routing table.\n"); + return IPACM_FAILURE; + } - memset(&flt_rule_entry, 0, sizeof(flt_rule_entry)); - flt_rule_entry.at_rear = 1; + memset(&flt_rule_entry, 0, sizeof(flt_rule_entry)); + flt_rule_entry.at_rear = 1; - flt_rule_entry.rule.retain_hdr = 0; - flt_rule_entry.rule.to_uc = 0; - flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; - flt_rule_entry.rule.eq_attrib_type = 0; - flt_rule_entry.rule.rt_tbl_hdl = rt_tbl.hdl; - flt_rule_entry.rule.hashable = false; //WLAN->ETH direction rules are set to non-hashable to keep consistent with the other direction + flt_rule_entry.rule.retain_hdr = 0; + flt_rule_entry.rule.to_uc = 0; + flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; + flt_rule_entry.rule.eq_attrib_type = 0; + flt_rule_entry.rule.rt_tbl_hdl = rt_tbl.hdl; + flt_rule_entry.rule.hashable = false; //WLAN->ETH direction rules are set to non-hashable to keep consistent with the other direction - memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule_entry.rule.attrib)); - if(tx_prop->tx[0].hdr_l2_type == IPA_HDR_L2_ETHERNET_II) - { - flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_ETHER_II; - } - else - { - flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_802_3; - } + memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule_entry.rule.attrib)); + if(tx_prop->tx[0].hdr_l2_type == IPA_HDR_L2_ETHERNET_II) + { + flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_ETHER_II; + } + else + { + flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_MAC_DST_ADDR_802_3; + } - memcpy(flt_rule_entry.rule.attrib.dst_mac_addr, dst_mac, sizeof(flt_rule_entry.rule.attrib.dst_mac_addr)); - memset(flt_rule_entry.rule.attrib.dst_mac_addr_mask, 0xFF, sizeof(flt_rule_entry.rule.attrib.dst_mac_addr_mask)); + memcpy(flt_rule_entry.rule.attrib.dst_mac_addr, dst_mac, sizeof(flt_rule_entry.rule.attrib.dst_mac_addr)); + memset(flt_rule_entry.rule.attrib.dst_mac_addr_mask, 0xFF, sizeof(flt_rule_entry.rule.attrib.dst_mac_addr_mask)); - memcpy(&(pFilteringTable->rules[0]), &flt_rule_entry, sizeof(flt_rule_entry)); - if (false == m_filtering.AddFilteringRuleAfter(pFilteringTable)) - { - IPACMERR("Failed to add first pass filtering rules.\n"); - free(pFilteringTable); - return IPACM_FAILURE; - } - *first_pass_flt_rule_hdl = pFilteringTable->rules[0].flt_rule_hdl; + memcpy(&(pFilteringTable->rules[0]), &flt_rule_entry, sizeof(flt_rule_entry)); + if (false == m_filtering.AddFilteringRuleAfter(pFilteringTable)) + { + IPACMERR("Failed to add first pass filtering rules.\n"); + free(pFilteringTable); + return IPACM_FAILURE; + } + *first_pass_flt_rule_hdl = pFilteringTable->rules[0].flt_rule_hdl; - /* =========== add second pass flt rule (match VLAN interface IPv6 address at client side) ============= */ - if(*second_pass_flt_rule_hdl != 0) - { - IPACMDBG_H("Second pass flt rule was added before, return.\n"); - free(pFilteringTable); - return IPACM_SUCCESS; - } + /* =========== add second pass flt rule (match VLAN interface IPv6 address at client side) ============= */ + if(*second_pass_flt_rule_hdl != 0) + { + IPACMDBG_H("Second pass flt rule was added before, return.\n"); + free(pFilteringTable); + return IPACM_SUCCESS; + } - rt_tbl.ip = IPA_IP_v6; - snprintf(rt_tbl.name, sizeof(rt_tbl.name), "l2tp"); - IPACMDBG_H("This flt rule points to rt tbl %s.\n", rt_tbl.name); + rt_tbl.ip = IPA_IP_v6; + snprintf(rt_tbl.name, sizeof(rt_tbl.name), "l2tp"); + IPACMDBG_H("This flt rule points to rt tbl %s.\n", rt_tbl.name); - if(m_routing.GetRoutingTable(&rt_tbl) == false) - { - IPACMERR("Failed to get routing table.\n"); - return IPACM_FAILURE; - } + if(m_routing.GetRoutingTable(&rt_tbl) == false) + { + IPACMERR("Failed to get routing table.\n"); + return IPACM_FAILURE; + } - pFilteringTable->ip = IPA_IP_v6; - pFilteringTable->add_after_hdl = eth_bridge_flt_rule_offset[IPA_IP_v6]; + pFilteringTable->ip = IPA_IP_v6; + pFilteringTable->add_after_hdl = eth_bridge_flt_rule_offset[IPA_IP_v6]; - memset(&flt_rule_entry, 0, sizeof(flt_rule_entry)); - flt_rule_entry.at_rear = 1; + memset(&flt_rule_entry, 0, sizeof(flt_rule_entry)); + flt_rule_entry.at_rear = 1; - flt_rule_entry.rule.retain_hdr = 0; - flt_rule_entry.rule.to_uc = 0; - flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; - flt_rule_entry.rule.eq_attrib_type = 0; - flt_rule_entry.rule.rt_tbl_hdl = rt_tbl.hdl; - flt_rule_entry.rule.hashable = false; //WLAN->ETH direction rules are set to non-hashable to keep consistent with the other direction + flt_rule_entry.rule.retain_hdr = 0; + flt_rule_entry.rule.to_uc = 0; + flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; + flt_rule_entry.rule.eq_attrib_type = 0; + flt_rule_entry.rule.rt_tbl_hdl = rt_tbl.hdl; + flt_rule_entry.rule.hashable = false; //WLAN->ETH direction rules are set to non-hashable to keep consistent with the other direction - 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; + 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; - memcpy(flt_rule_entry.rule.attrib.u.v6.dst_addr, vlan_client_ipv6_addr, sizeof(flt_rule_entry.rule.attrib.u.v6.dst_addr)); - memset(flt_rule_entry.rule.attrib.u.v6.dst_addr_mask, 0xFF, sizeof(flt_rule_entry.rule.attrib.u.v6.dst_addr_mask)); + memcpy(flt_rule_entry.rule.attrib.u.v6.dst_addr, vlan_client_ipv6_addr, sizeof(flt_rule_entry.rule.attrib.u.v6.dst_addr)); + memset(flt_rule_entry.rule.attrib.u.v6.dst_addr_mask, 0xFF, sizeof(flt_rule_entry.rule.attrib.u.v6.dst_addr_mask)); + + memcpy(&(pFilteringTable->rules[0]), &flt_rule_entry, sizeof(flt_rule_entry)); + if (false == m_filtering.AddFilteringRuleAfter(pFilteringTable)) + { + IPACMERR("Failed to add client filtering rules.\n"); + free(pFilteringTable); + return IPACM_FAILURE; + } + *second_pass_flt_rule_hdl = pFilteringTable->rules[0].flt_rule_hdl; - memcpy(&(pFilteringTable->rules[0]), &flt_rule_entry, sizeof(flt_rule_entry)); - if (false == m_filtering.AddFilteringRuleAfter(pFilteringTable)) - { - IPACMERR("Failed to add client filtering rules.\n"); free(pFilteringTable); - return IPACM_FAILURE; } - *second_pass_flt_rule_hdl = pFilteringTable->rules[0].flt_rule_hdl; - - free(pFilteringTable); -#endif return IPACM_SUCCESS; } @@ -6343,9 +6353,8 @@ int IPACM_Lan::add_connection(int client_index, int v6_num) flt_rule_entry.rule.to_uc = 0; flt_rule_entry.rule.eq_attrib_type = 1; flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR; flt_rule_entry.rule.attrib.u.v6.dst_addr[0] = get_client_memptr(eth_client, client_index)->v6_addr[v6_num][0]; flt_rule_entry.rule.attrib.u.v6.dst_addr[1] = get_client_memptr(eth_client, client_index)->v6_addr[v6_num][1]; @@ -6472,7 +6481,6 @@ int IPACM_Lan::construct_mtu_rule(struct ipa_flt_rule *rule, ipa_ip_type iptype, rule->eq_attrib_type = 1; rule->eq_attrib.rule_eq_bitmap = 0; rule->action = IPA_PASS_TO_EXCEPTION; - rule->rt_tbl_hdl = -1; /* generate eq */ memset(&flt_eq, 0, sizeof(flt_eq)); @@ -6496,11 +6504,7 @@ int IPACM_Lan::construct_mtu_rule(struct ipa_flt_rule *rule, ipa_ip_type iptype, &flt_eq.eq_attrib, sizeof(rule->eq_attrib)); //add IHL offsets -#ifdef FEATURE_IPA_V3 - rule->eq_attrib.rule_eq_bitmap |= (1<<10); -#else - rule->eq_attrib.rule_eq_bitmap |= (1<<4); -#endif + rule->eq_attrib.rule_eq_bitmap |= (1<<10); rule->eq_attrib.num_ihl_offset_range_16 = 1; if (iptype == IPA_IP_v4) rule->eq_attrib.ihl_offset_range_16[0].offset = 0x82; diff --git a/data-ipa-cfg-mgr/ipacm/src/IPACM_Main.cpp b/data-ipa-cfg-mgr/ipacm/src/IPACM_Main.cpp index dad1e983..ca75a4a0 100644 --- a/data-ipa-cfg-mgr/ipacm/src/IPACM_Main.cpp +++ b/data-ipa-cfg-mgr/ipacm/src/IPACM_Main.cpp @@ -450,12 +450,11 @@ void* ipa_driver_msg_notifier(void *param) } memcpy(event_ex, buffer + sizeof(struct ipa_msg_meta), length); data_ex = (ipacm_event_data_wlan_ex *)malloc(sizeof(ipacm_event_data_wlan_ex) + event_ex_o.num_of_attribs * sizeof(ipa_wlan_hdr_attrib_val)); - if (data_ex == NULL) - { + if (data_ex == NULL) + { IPACMERR("unable to allocate memory for event data\n"); - free(event_ex); - return NULL; - } + return NULL; + } data_ex->num_of_attribs = event_ex->num_of_attribs; memcpy(data_ex->attribs, @@ -761,10 +760,19 @@ void* ipa_driver_msg_notifier(void *param) IPACMERR("calling OffloadMng->elrInstance->onOffloadStopped \n"); OffloadMng->elrInstance->onOffloadStopped(IpaEventRelay::ERROR); } - /* WA to clean up wlan instances during SSR */ - evt_data.event = IPA_SSR_NOTICE; - evt_data.evt_data = NULL; - break; + /* Starting from Hastings, WLAN is not restarted as part of Modem SSR. + * No need to reset NAT Iface. + */ +#ifdef IPA_HW_v4_9 + if (IPACM_Iface::ipacmcfg->GetIPAVer() != IPA_HW_v4_9) +#endif + { + /* WA to clean up wlan instances during SSR */ + evt_data.event = IPA_SSR_NOTICE; + evt_data.evt_data = NULL; + break; + } + continue; case IPA_SSR_AFTER_POWERUP: IPACMDBG_H("Received IPA_SSR_AFTER_POWERUP\n"); OffloadMng = IPACM_OffloadManager::GetInstance(); @@ -952,11 +960,11 @@ int main(int argc, char **argv) IPACMDBG_H(" START IPACM_OffloadManager and link to android framework\n"); #endif -#ifdef FEATURE_ETH_BRIDGE_LE - IPACM_LanToLan* lan2lan = IPACM_LanToLan::get_instance(); - IPACMDBG_H("Staring IPACM_LanToLan instance %p\n", lan2lan); -#endif - + if (IPACM_Iface::ipacmcfg->isEthBridgingSupported()) + { + IPACM_LanToLan* lan2lan = IPACM_LanToLan::get_instance(); + IPACMDBG_H("Staring IPACM_LanToLan instance %p\n", lan2lan); + } CtList = new IPACM_ConntrackListener(); IPACMDBG_H("Staring IPA main\n"); diff --git a/data-ipa-cfg-mgr/ipacm/src/IPACM_Netlink.cpp b/data-ipa-cfg-mgr/ipacm/src/IPACM_Netlink.cpp index fa0f7acb..fa4b8b77 100644 --- a/data-ipa-cfg-mgr/ipacm/src/IPACM_Netlink.cpp +++ b/data-ipa-cfg-mgr/ipacm/src/IPACM_Netlink.cpp @@ -709,7 +709,6 @@ static int ipa_nl_decode_nlmsg if(ret_val != IPACM_SUCCESS) { IPACMERR("Error while getting interface name\n"); - free(data_fid); return IPACM_FAILURE; } IPACMDBG_H("Got a usb link_up event (Interface %s, %d) \n", dev_name, msg_ptr->nl_link_info.metainfo.ifi_index); diff --git a/data-ipa-cfg-mgr/ipacm/src/IPACM_OffloadManager.cpp b/data-ipa-cfg-mgr/ipacm/src/IPACM_OffloadManager.cpp index 79194139..b5afda71 100644 --- a/data-ipa-cfg-mgr/ipacm/src/IPACM_OffloadManager.cpp +++ b/data-ipa-cfg-mgr/ipacm/src/IPACM_OffloadManager.cpp @@ -120,6 +120,7 @@ RET IPACM_OffloadManager::unregisterCtTimeoutUpdater(ConntrackTimeoutUpdater* ) RET IPACM_OffloadManager::provideFd(int fd, unsigned int groups) { + struct timeval tv; IPACM_ConntrackClient *cc; int on = 1, rel; struct sockaddr_nl local; @@ -158,11 +159,30 @@ RET IPACM_OffloadManager::provideFd(int fd, unsigned int groups) cc->fd_udp = dup(fd); IPACMDBG_H("Received fd %d with groups %d.\n", fd, groups); /* set netlink buf */ - rel = setsockopt(cc->fd_tcp, SOL_NETLINK, NETLINK_NO_ENOBUFS, &on, sizeof(int) ); + rel = setsockopt(cc->fd_udp, SOL_NETLINK, NETLINK_NO_ENOBUFS, &on, sizeof(int) ); if (rel == -1) { - IPACMERR( "setsockopt returned error code %d ( %s )", errno, strerror( errno ) ); + IPACMERR("setsockopt returned error code %d ( %s )\n", errno, strerror(errno)); } + + /* Set receive timeout to 1s on the FD which is used to read conntrack dump. */ + memset(&tv,0, sizeof(struct timeval)); + tv.tv_sec = 1; /* 1s timeout */ + rel = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO,(struct timeval *)&tv,sizeof(struct timeval)); + if (rel == -1) + { + IPACMERR("setsockopt returned error code %d ( %s )\n", errno, strerror(errno)); + } + + /* 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. + */ + CtList->readConntrack(fd); } else { IPACMERR("Received unexpected fd with groups %d.\n", groups); } diff --git a/data-ipa-cfg-mgr/ipacm/src/IPACM_Wan.cpp b/data-ipa-cfg-mgr/ipacm/src/IPACM_Wan.cpp index 1828910f..397c820e 100644 --- a/data-ipa-cfg-mgr/ipacm/src/IPACM_Wan.cpp +++ b/data-ipa-cfg-mgr/ipacm/src/IPACM_Wan.cpp @@ -295,9 +295,8 @@ int IPACM_Wan::handle_addr_evt(ipacm_event_data_addr *data) ipv6_addr[num_dft_rt_v6][1] = data->ipv6_addr[1]; ipv6_addr[num_dft_rt_v6][2] = data->ipv6_addr[2]; ipv6_addr[num_dft_rt_v6][3] = data->ipv6_addr[3]; -#ifdef FEATURE_IPA_V3 - rt_rule_entry->rule.hashable = false; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + rt_rule_entry->rule.hashable = false; if(m_is_sta_mode == Q6_WAN) { strlcpy(hdr.name, tx_prop->tx[0].hdr_name, sizeof(hdr.name)); @@ -491,9 +490,8 @@ int IPACM_Wan::handle_addr_evt(ipacm_event_data_addr *data) flt_rule_entry.flt_rule_hdl = -1; flt_rule_entry.status = -1; flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; 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; @@ -599,9 +597,8 @@ int IPACM_Wan::handle_addr_evt(ipacm_event_data_addr *data) strlcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_lan_v4.name, sizeof(rt_rule->rt_tbl_name)); rt_rule_entry->rule.attrib.u.v4.dst_addr = data->ipv4_addr; rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF; -#ifdef FEATURE_IPA_V3 - rt_rule_entry->rule.hashable = false; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + rt_rule_entry->rule.hashable = false; if(m_is_sta_mode == Q6_WAN) { /* query qmap header*/ @@ -854,9 +851,8 @@ int IPACM_Wan::handle_addr_evt_mhi_q6(ipacm_event_data_addr *data) ipv6_addr[0][1] = data->ipv6_addr[1]; ipv6_addr[0][2] = data->ipv6_addr[2]; ipv6_addr[0][3] = data->ipv6_addr[3]; -#ifdef FEATURE_IPA_V3 - rt_rule_entry->rule.hashable = false; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + rt_rule_entry->rule.hashable = false; if (false == m_routing.AddRoutingRule(rt_rule)) { IPACMERR("Routing rule addition failed!\n"); @@ -935,9 +931,8 @@ int IPACM_Wan::handle_addr_evt_mhi_q6(ipacm_event_data_addr *data) strlcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_lan_v4.name, sizeof(rt_rule->rt_tbl_name)); rt_rule_entry->rule.attrib.u.v4.dst_addr = data->ipv4_addr; rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF; -#ifdef FEATURE_IPA_V3 - rt_rule_entry->rule.hashable = false; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + rt_rule_entry->rule.hashable = false; if (false == m_routing.AddRoutingRule(rt_rule)) { IPACMERR("Routing rule addition failed!\n"); @@ -1987,9 +1982,8 @@ int IPACM_Wan::handle_route_add_evt(ipa_ip_type iptype) { rt_rule_entry->rule.attrib.u.v4.dst_addr = 0; rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0; -#ifdef FEATURE_IPA_V3 - rt_rule_entry->rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + rt_rule_entry->rule.hashable = true; #ifdef IPA_IOCTL_SET_FNR_COUNTER_INFO /* use index hw-counter */ if((m_is_sta_mode == WLAN_WAN) && IPACM_Iface::ipacmcfg->hw_fnr_stats_support) @@ -2024,9 +2018,8 @@ int IPACM_Wan::handle_route_add_evt(ipa_ip_type iptype) rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0; rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0; rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0; -#ifdef FEATURE_IPA_V3 - rt_rule_entry->rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + rt_rule_entry->rule.hashable = true; #ifdef IPA_IOCTL_SET_FNR_COUNTER_INFO /* use index hw-counter */ if((m_is_sta_mode == WLAN_WAN) && IPACM_Iface::ipacmcfg->hw_fnr_stats_support) @@ -2098,9 +2091,8 @@ int IPACM_Wan::handle_route_add_evt(ipa_ip_type iptype) rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0; rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0; rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0; -#ifdef FEATURE_IPA_V3 - rt_rule_entry->rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + rt_rule_entry->rule.hashable = true; if (false == m_routing.AddRoutingRule(rt_rule)) { IPACMERR("Routing rule addition failed!\n"); @@ -2244,6 +2236,9 @@ int IPACM_Wan::handle_route_add_evt(ipa_ip_type iptype) } IPACMDBG_H("send WAN_IOC_NOTIFY_WAN_STATE up to IPA_PM\n"); wan_state.up = true; +#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); @@ -2591,10 +2586,11 @@ int IPACM_Wan::config_dft_firewall_rules(ipa_ip_type iptype) memset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add)); flt_rule_entry.at_rear = true; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.at_rear = false; - flt_rule_entry.rule.hashable = false; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + { + flt_rule_entry.at_rear = false; + flt_rule_entry.rule.hashable = false; + } flt_rule_entry.flt_rule_hdl = -1; flt_rule_entry.status = -1; flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION; @@ -2686,10 +2682,11 @@ int IPACM_Wan::config_dft_firewall_rules(ipa_ip_type iptype) flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; } } -#ifdef FEATURE_IPA_V3 - flt_rule_entry.at_rear = true; - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + { + flt_rule_entry.at_rear = true; + flt_rule_entry.rule.hashable = true; + } flt_rule_entry.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_lan_v4.hdl; memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, @@ -2783,9 +2780,8 @@ int IPACM_Wan::config_dft_firewall_rules(ipa_ip_type iptype) { flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION; } -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; memcpy(&flt_rule_entry.rule.attrib, &firewall_config.extd_firewall_entries[i].attrib, sizeof(struct ipa_rule_attrib)); @@ -2953,9 +2949,8 @@ int IPACM_Wan::config_dft_firewall_rules(ipa_ip_type iptype) flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; } } -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; flt_rule_entry.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_lan_v4.hdl; memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, @@ -3020,9 +3015,8 @@ int IPACM_Wan::config_dft_firewall_rules(ipa_ip_type iptype) flt_rule_entry.rule.retain_hdr = 1; flt_rule_entry.rule.eq_attrib_type = 0; flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, sizeof(struct ipa_rule_attrib)); @@ -3093,9 +3087,8 @@ int IPACM_Wan::config_dft_firewall_rules(ipa_ip_type iptype) flt_rule_entry.at_rear = true; flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; } -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, sizeof(struct ipa_rule_attrib)); @@ -3183,10 +3176,9 @@ int IPACM_Wan::config_dft_firewall_rules(ipa_ip_type iptype) { flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION; } -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif - flt_rule_entry.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_wan_v6.hdl; + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; + flt_rule_entry.rule.rt_tbl_hdl = IPACM_Iface::ipacmcfg->rt_tbl_wan_v6.hdl; memcpy(&flt_rule_entry.rule.attrib, &firewall_config.extd_firewall_entries[i].attrib, sizeof(struct ipa_rule_attrib)); @@ -3304,9 +3296,8 @@ int IPACM_Wan::config_dft_firewall_rules(ipa_ip_type iptype) flt_rule_entry.rule.retain_hdr = 1; flt_rule_entry.rule.eq_attrib_type = 0; flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, sizeof(struct ipa_rule_attrib)); @@ -3368,9 +3359,8 @@ int IPACM_Wan::config_dft_firewall_rules(ipa_ip_type iptype) flt_rule_entry.at_rear = true; flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; } -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, sizeof(struct ipa_rule_attrib)); @@ -3467,9 +3457,8 @@ int IPACM_Wan::config_dft_firewall_rules_ex(struct ipa_flt_rule_add *rules, int { memset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add)); flt_rule_entry.at_rear = true; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.at_rear = false; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.at_rear = false; flt_rule_entry.flt_rule_hdl = -1; flt_rule_entry.status = -1; @@ -3477,10 +3466,11 @@ int IPACM_Wan::config_dft_firewall_rules_ex(struct ipa_flt_rule_add *rules, int flt_rule_entry.rule.to_uc = 0; flt_rule_entry.rule.eq_attrib_type = 1; flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.at_rear = false; - flt_rule_entry.rule.hashable = false; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + { + flt_rule_entry.at_rear = false; + flt_rule_entry.rule.hashable = false; + } memset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx)); rt_tbl_idx.ip = IPA_IP_v6; strlcpy(rt_tbl_idx.name, IPACM_Iface::ipacmcfg->rt_tbl_wan_dl.name, IPA_RESOURCE_NAME_MAX); @@ -3546,9 +3536,8 @@ int IPACM_Wan::config_dft_firewall_rules_ex(struct ipa_flt_rule_add *rules, int { flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; } -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; memset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx)); rt_tbl_idx.ip = iptype; if(flt_rule_entry.rule.action == IPA_PASS_TO_ROUTING) @@ -3683,9 +3672,8 @@ int IPACM_Wan::config_dft_firewall_rules_ex(struct ipa_flt_rule_add *rules, int flt_rule_entry.rule.action = IPA_PASS_TO_DST_NAT; } } -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; memset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx)); rt_tbl_idx.ip = iptype; @@ -3758,9 +3746,8 @@ int IPACM_Wan::config_dft_firewall_rules_ex(struct ipa_flt_rule_add *rules, int flt_rule_entry.rule.to_uc = 0; flt_rule_entry.rule.eq_attrib_type = 1; flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; memset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx)); rt_tbl_idx.ip = iptype; @@ -3871,9 +3858,8 @@ int IPACM_Wan::config_dft_firewall_rules_ex(struct ipa_flt_rule_add *rules, int flt_rule_entry.rule.to_uc = 0; flt_rule_entry.rule.eq_attrib_type = 1; flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; memset(&rt_tbl_idx, 0, sizeof(rt_tbl_idx)); rt_tbl_idx.ip = iptype; /* firewall disable, all traffic are allowed */ @@ -4025,9 +4011,8 @@ int IPACM_Wan::add_icmp_alg_rules(struct ipa_flt_rule_add *rules, int rule_offse flt_rule_entry.rule.to_uc = 0; flt_rule_entry.rule.eq_attrib_type = 1; flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; flt_rule_entry.rule.rt_tbl_idx = rt_tbl_idx.idx; /* Configuring ICMP filtering rule */ @@ -4143,9 +4128,8 @@ int IPACM_Wan::add_icmp_alg_rules(struct ipa_flt_rule_add *rules, int rule_offse flt_rule_entry.rule.to_uc = 0; flt_rule_entry.rule.eq_attrib_type = 1; flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; flt_rule_entry.rule.rt_tbl_idx = rt_tbl_idx.idx; /* Configuring ICMP filtering rule */ @@ -4225,15 +4209,18 @@ int IPACM_Wan::query_ext_prop() for (cnt = 0; cnt < ext_prop->num_ext_props; cnt++) { -#ifndef FEATURE_IPA_V3 - IPACMDBG_H("Ex(%d): ip-type: %d, mux_id: %d, flt_action: %d\n, rt_tbl_idx: %d, is_xlat_rule: %d flt_hdl: %d\n", - cnt, ext_prop->ext[cnt].ip, ext_prop->ext[cnt].mux_id, ext_prop->ext[cnt].action, - ext_prop->ext[cnt].rt_tbl_idx, ext_prop->ext[cnt].is_xlat_rule, ext_prop->ext[cnt].filter_hdl); -#else /* defined (FEATURE_IPA_V3) */ - IPACMDBG_H("Ex(%d): ip-type: %d, mux_id: %d, flt_action: %d\n, rt_tbl_idx: %d, is_xlat_rule: %d rule_id: %d\n", - cnt, ext_prop->ext[cnt].ip, ext_prop->ext[cnt].mux_id, ext_prop->ext[cnt].action, - ext_prop->ext[cnt].rt_tbl_idx, ext_prop->ext[cnt].is_xlat_rule, ext_prop->ext[cnt].rule_id); -#endif + if (!IPACM_Iface::ipacmcfg->isIPAv3Supported()) + { + IPACMDBG_H("Ex(%d): ip-type: %d, mux_id: %d, flt_action: %d\n, rt_tbl_idx: %d, is_xlat_rule: %d flt_hdl: %d\n", + cnt, ext_prop->ext[cnt].ip, ext_prop->ext[cnt].mux_id, ext_prop->ext[cnt].action, + ext_prop->ext[cnt].rt_tbl_idx, ext_prop->ext[cnt].is_xlat_rule, ext_prop->ext[cnt].filter_hdl); + } + else /* IPA_V3 */ + { + IPACMDBG_H("Ex(%d): ip-type: %d, mux_id: %d, flt_action: %d\n, rt_tbl_idx: %d, is_xlat_rule: %d rule_id: %d\n", + cnt, ext_prop->ext[cnt].ip, ext_prop->ext[cnt].mux_id, ext_prop->ext[cnt].action, + ext_prop->ext[cnt].rt_tbl_idx, ext_prop->ext[cnt].is_xlat_rule, ext_prop->ext[cnt].rule_id); + } } if(IPACM_Wan::is_ext_prop_set == false) @@ -4343,9 +4330,8 @@ int IPACM_Wan::add_dft_filtering_rule(struct ipa_flt_rule_add *rules, int rule_o flt_rule_entry.rule.to_uc = 0; flt_rule_entry.rule.eq_attrib_type = 1; flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; flt_rule_entry.rule.rt_tbl_idx = rt_tbl_idx.idx; IPACMDBG_H("rx property attrib mask:0x%x\n", rx_prop->rx[0].attrib.attrib_mask); @@ -4426,9 +4412,8 @@ int IPACM_Wan::add_dft_filtering_rule(struct ipa_flt_rule_add *rules, int rule_o flt_rule_entry.rule.to_uc = 0; flt_rule_entry.rule.eq_attrib_type = 1; flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; flt_rule_entry.rule.rt_tbl_idx = rt_tbl_idx.idx; /* Configuring Multicast Filtering Rule */ @@ -4696,7 +4681,6 @@ int IPACM_Wan::handle_route_del_evt(ipa_ip_type iptype) 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); @@ -4733,6 +4717,9 @@ int IPACM_Wan::handle_route_del_evt(ipa_ip_type iptype) 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); @@ -4826,19 +4813,24 @@ int IPACM_Wan::handle_route_del_evt(ipa_ip_type iptype) if(delete_offload_frag_rule()) { IPACMERR("Failed to delete DL frag rule \n"); - ret = IPACM_FAILURE; + return 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"); - ret = IPACM_FAILURE; + return 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; @@ -4857,13 +4849,6 @@ int IPACM_Wan::handle_route_del_evt(ipa_ip_type iptype) { 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 @@ -4916,6 +4901,9 @@ int IPACM_Wan::handle_route_del_evt_ex(ipa_ip_type iptype) 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); @@ -5044,9 +5032,8 @@ int IPACM_Wan::config_dft_embms_rules(ipa_ioc_add_flt_rule *pFilteringTable_v4, flt_rule_entry.rule.to_uc = 0; flt_rule_entry.rule.eq_attrib_type = 1; flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; flt_rule_entry.rule.rt_tbl_idx = rt_tbl_idx.idx; memcpy(&flt_rule_entry.rule.attrib, @@ -5093,9 +5080,8 @@ int IPACM_Wan::config_dft_embms_rules(ipa_ioc_add_flt_rule *pFilteringTable_v4, flt_rule_entry.rule.to_uc = 0; flt_rule_entry.rule.eq_attrib_type = 1; flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; flt_rule_entry.rule.rt_tbl_idx = rt_tbl_idx.idx; memcpy(&flt_rule_entry.rule.attrib, @@ -5166,6 +5152,17 @@ int IPACM_Wan::handle_down_evt() 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 */ @@ -5197,6 +5194,18 @@ int IPACM_Wan::handle_down_evt() 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 @@ -5218,51 +5227,37 @@ int IPACM_Wan::handle_down_evt() #endif } - /* Delete default v4 RT rule */ - if (ip_type != IPA_IP_v6 && wan_v4_addr_set) - { - /* 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) + 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++) + /* Delete default v4 RT rule */ + if (ip_type != IPA_IP_v6) { - if (m_routing.DeleteRoutingHdl(dft_rt_rule_hdl[MAX_DEFAULT_v4_ROUTE_RULES+i], IPA_IP_v6) == 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; } } - IPACMDBG_H("finished delete default v6 RT rules\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 + /* delete default v6 RT rule */ + if (ip_type != IPA_IP_v4) { - handle_software_routing_disable(false); + 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 "); } - } - - 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++) @@ -5311,6 +5306,18 @@ int IPACM_Wan::handle_down_evt() /* 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) { @@ -5807,9 +5814,8 @@ int IPACM_Wan::install_wan_filtering_rule(bool is_sw_routing) flt_rule_entry.flt_rule_hdl = -1; flt_rule_entry.status = -1; flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; flt_rule_entry.rule.rt_tbl_idx = rt_tbl_idx.idx; @@ -5869,9 +5875,8 @@ int IPACM_Wan::install_wan_filtering_rule(bool is_sw_routing) flt_rule_entry.flt_rule_hdl = -1; flt_rule_entry.status = -1; flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; flt_rule_entry.rule.rt_tbl_idx = rt_tbl_idx.idx; memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, @@ -6499,9 +6504,8 @@ int IPACM_Wan::handle_wan_client_route_rule(uint8_t *mac_addr, ipa_ip_type iptyp rt_rule_entry->rule.hdr_hdl = get_client_memptr(wan_client, wan_index)->hdr_hdl_v4; rt_rule_entry->rule.attrib.u.v4.dst_addr = get_client_memptr(wan_client, wan_index)->v4_addr; rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF; -#ifdef FEATURE_IPA_V3 - rt_rule_entry->rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + rt_rule_entry->rule.hashable = true; if (false == m_routing.AddRoutingRule(rt_rule)) { IPACMERR("Routing rule addition failed!\n"); @@ -6549,9 +6553,8 @@ int IPACM_Wan::handle_wan_client_route_rule(uint8_t *mac_addr, ipa_ip_type iptyp rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF; rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF; rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF; -#ifdef FEATURE_IPA_V3 - rt_rule_entry->rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + rt_rule_entry->rule.hashable = true; if (false == m_routing.AddRoutingRule(rt_rule)) { IPACMERR("Routing rule addition failed!\n"); @@ -7125,9 +7128,8 @@ int IPACM_Wan::handle_coalesce_evt() strlcpy(rt_rule->rt_tbl_name, IPACM_Iface::ipacmcfg->rt_tbl_lan_v4.name, sizeof(rt_rule->rt_tbl_name)); rt_rule_entry->rule.attrib.u.v4.dst_addr = wan_v4_addr; rt_rule_entry->rule.attrib.u.v4.dst_addr_mask = 0xFFFFFFFF; -#ifdef FEATURE_IPA_V3 - rt_rule_entry->rule.hashable = false; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + rt_rule_entry->rule.hashable = false; /* query qmap header*/ memset(&hdr, 0, sizeof(hdr)); strlcpy(hdr.name, tx_prop->tx[0].hdr_name, sizeof(hdr.name)); @@ -7249,17 +7251,16 @@ int IPACM_Wan::handle_coalesce_evt() rt_rule_entry = &rt_rule->rules[0]; rt_rule_entry->at_rear = false; rt_rule_entry->rule.attrib.attrib_mask = IPA_FLT_DST_ADDR; - rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = ipv6_addr[num_dft_rt_v6][0]; - rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = ipv6_addr[num_dft_rt_v6][1]; - rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = ipv6_addr[num_dft_rt_v6][2]; - rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = ipv6_addr[num_dft_rt_v6][3]; + rt_rule_entry->rule.attrib.u.v6.dst_addr[0] = ipv6_addr[i][0]; + rt_rule_entry->rule.attrib.u.v6.dst_addr[1] = ipv6_addr[i][1]; + rt_rule_entry->rule.attrib.u.v6.dst_addr[2] = ipv6_addr[i][2]; + rt_rule_entry->rule.attrib.u.v6.dst_addr[3] = ipv6_addr[i][3]; rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[0] = 0xFFFFFFFF; rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF; rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF; rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF; -#ifdef FEATURE_IPA_V3 - rt_rule_entry->rule.hashable = false; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + rt_rule_entry->rule.hashable = false; strlcpy(hdr.name, tx_prop->tx[0].hdr_name, sizeof(hdr.name)); hdr.name[IPA_RESOURCE_NAME_MAX-1] = '\0'; if(m_header.GetHeaderHandle(&hdr) == false) @@ -7400,9 +7401,8 @@ int IPACM_Wan::add_offload_frag_rule() flt_rule_entry.rule.to_uc = 0; flt_rule_entry.rule.eq_attrib_type = 1; flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; IPACMDBG_H("rx property attrib mask:0x%x\n", rx_prop->rx[0].attrib.attrib_mask); memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, @@ -7541,9 +7541,8 @@ int IPACM_Wan::add_icmpv6_exception_rule() flt_rule_entry.flt_rule_hdl = -1; flt_rule_entry.status = -1; flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; IPACMDBG_H("rx property attrib mask:0x%x\n", rx_prop->rx[0].attrib.attrib_mask); memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule_entry.rule.attrib)); flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_NEXT_HDR; @@ -7714,11 +7713,10 @@ int IPACM_Wan::add_tcp_fin_rst_exception_rule() sizeof(flt_rule_entry.rule.eq_attrib)); /* set the bit mask to use MEQ32_IHL offset */ - #ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<7); - #else - flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<8); - #endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<7); + else + flt_rule_entry.rule.eq_attrib.rule_eq_bitmap |= (1<<8); /* add offset to compare TCP flags */ flt_rule_entry.rule.eq_attrib.num_ihl_offset_meq_32 = 1; diff --git a/data-ipa-cfg-mgr/ipacm/src/IPACM_Wlan.cpp b/data-ipa-cfg-mgr/ipacm/src/IPACM_Wlan.cpp index d5d38caa..689cc786 100644 --- a/data-ipa-cfg-mgr/ipacm/src/IPACM_Wlan.cpp +++ b/data-ipa-cfg-mgr/ipacm/src/IPACM_Wlan.cpp @@ -206,20 +206,21 @@ void IPACM_Wlan::event_callback(ipa_cm_event_id event, void *param) IPACMDBG_H("Received IPA_LAN_DELETE_SELF event.\n"); IPACMDBG_H("ipa_WLAN (%s):ipa_index (%d) instance close \n", IPACM_Iface::ipacmcfg->iface_table[ipa_if_num].iface_name, ipa_if_num); -#ifdef FEATURE_ETH_BRIDGE_LE - if(rx_prop != NULL) + if (IPACM_Iface::ipacmcfg->isEthBridgingSupported()) { - free(rx_prop); - } - if(tx_prop != NULL) - { - free(tx_prop); - } - if(iface_query != NULL) - { - free(iface_query); + if(rx_prop != NULL) + { + free(rx_prop); + } + if(tx_prop != NULL) + { + free(tx_prop); + } + if(iface_query != NULL) + { + free(iface_query); + } } -#endif delete this; } break; @@ -1633,9 +1634,8 @@ int IPACM_Wlan::handle_wlan_client_route_rule(uint8_t *mac_addr, ipa_ip_type ipt rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF; rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF; rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF; -#ifdef FEATURE_IPA_V3 - rt_rule_entry->rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + rt_rule_entry->rule.hashable = true; if (false == m_routing.AddRoutingRule(rt_rule)) { IPACMERR("Routing rule addition failed!\n"); @@ -1685,9 +1685,8 @@ int IPACM_Wlan::handle_wlan_client_route_rule(uint8_t *mac_addr, ipa_ip_type ipt rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[1] = 0xFFFFFFFF; rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[2] = 0xFFFFFFFF; rt_rule_entry->rule.attrib.u.v6.dst_addr_mask[3] = 0xFFFFFFFF; -#ifdef FEATURE_IPA_V3 - rt_rule_entry->rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + rt_rule_entry->rule.hashable = true; #ifdef IPA_IOCTL_SET_FNR_COUNTER_INFO /* use index hw-counter */ if(IPACM_Iface::ipacmcfg->hw_fnr_stats_support) @@ -2137,9 +2136,8 @@ int IPACM_Wlan::handle_down_evt() IPACMDBG_H("depend Got pipe %d rm index : %d \n", rx_prop->rx[0].src_pipe, IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[rx_prop->rx[0].src_pipe]); IPACM_Iface::ipacmcfg->DelRmDepend(IPACM_Iface::ipacmcfg->ipa_client_rm_map_tbl[rx_prop->rx[0].src_pipe]); } -#ifndef FEATURE_ETH_BRIDGE_LE - free(rx_prop); -#endif + if (!(IPACM_Iface::ipacmcfg->isEthBridgingSupported())) + free(rx_prop); } for (i = 0; i < num_wifi_client; i++) @@ -2153,17 +2151,18 @@ int IPACM_Wlan::handle_down_evt() { free(wlan_client); } -#ifndef FEATURE_ETH_BRIDGE_LE - if (tx_prop != NULL) + if (!(IPACM_Iface::ipacmcfg->isEthBridgingSupported())) { - free(tx_prop); - } + if (tx_prop != NULL) + { + free(tx_prop); + } - if (iface_query != NULL) - { - free(iface_query); + if (iface_query != NULL) + { + free(iface_query); + } } -#endif is_active = false; post_del_self_evt(); @@ -2504,9 +2503,8 @@ int IPACM_Wlan::add_connection(int client_index, int v6_num) flt_rule_entry.rule.to_uc = 0; flt_rule_entry.rule.eq_attrib_type = 1; flt_rule_entry.rule.action = IPA_PASS_TO_ROUTING; -#ifdef FEATURE_IPA_V3 - flt_rule_entry.rule.hashable = true; -#endif + if (IPACM_Iface::ipacmcfg->isIPAv3Supported()) + flt_rule_entry.rule.hashable = true; flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_DST_ADDR; flt_rule_entry.rule.attrib.u.v6.dst_addr[0] = get_client_memptr(wlan_client, client_index)->v6_addr[v6_num][0]; flt_rule_entry.rule.attrib.u.v6.dst_addr[1] = get_client_memptr(wlan_client, client_index)->v6_addr[v6_num][1]; diff --git a/data-ipa-cfg-mgr/ipacm_vendor_product.mk b/data-ipa-cfg-mgr/ipacm_vendor_product.mk index 96c61169..f225a303 100644 --- a/data-ipa-cfg-mgr/ipacm_vendor_product.mk +++ b/data-ipa-cfg-mgr/ipacm_vendor_product.mk @@ -1,6 +1,50 @@ +TARGET_DISABLE_IPACM := false + #IPACM_DATA IPACM_DATA += IPACM_cfg.xml IPACM_DATA += ipacm IPACM_DATA += ipacm.rc +ifeq ($(TARGET_USES_QMAA),true) +ifneq ($(TARGET_USES_QMAA_OVERRIDE_DATA),true) + TARGET_DISABLE_IPACM := true +endif #TARGET_USES_QMAA_OVERRIDE_DATA +endif #TARGET_USES_QMAA + +BOARD_IPA_LOW_RAM_EXCP_LIST := bengal + +ifeq ($(TARGET_HAS_LOW_RAM),true) +ifneq ($(call is-board-platform-in-list,$(BOARD_IPA_LOW_RAM_EXCP_LIST)),true) + TARGET_DISABLE_IPACM := true +endif +endif + +ifneq ($(TARGET_DISABLE_IPACM),true) +BOARD_PLATFORM_LIST := msm8909 +BOARD_PLATFORM_LIST += msm8916 +BOARD_PLATFORM_LIST += msm8917 +BOARD_PLATFORM_LIST += qm215 +BOARD_PLATFORM_LIST += msm8937 +BOARD_IPAv3_LIST := msm8998 +BOARD_IPAv3_LIST += sdm845 +BOARD_IPAv3_LIST += sdm710 +BOARD_IPAv3_LIST += msmnile +BOARD_IPAv3_LIST += kona +BOARD_IPAv3_LIST += $(MSMSTEPPE) +BOARD_IPAv3_LIST += $(TRINKET) +BOARD_IPAv3_LIST += lito +BOARD_IPAv3_LIST += atoll +BOARD_IPAv3_LIST += bengal +BOARD_ETH_BRIDGE_LIST := msmnile +BOARD_ETH_BRIDGE_LIST += kona + +ifneq ($(call is-board-platform-in-list,$(BOARD_PLATFORM_LIST)),true) +ifneq (,$(filter $(QCOM_BOARD_PLATFORMS),$(TARGET_BOARD_PLATFORM))) +ifneq (, $(filter aarch64 arm arm64, $(TARGET_ARCH))) + PRODUCT_PACKAGES += $(IPACM_DATA) + +endif # $(TARGET_ARCH) +endif +endif +endif diff --git a/data-ipa-cfg-mgr/ipanat/Android.bp b/data-ipa-cfg-mgr/ipanat/Android.bp new file mode 100644 index 00000000..3c8f9775 --- /dev/null +++ b/data-ipa-cfg-mgr/ipanat/Android.bp @@ -0,0 +1,28 @@ + + +cc_library_shared { + name: "libipanat", + + header_libs: ["generated_kernel_headers"], + + srcs: [ + "src/ipa_nat_drv.c", + "src/ipa_nat_drvi.c", + ], + + shared_libs: + ["libcutils", + "libdl", + "libbase", + "libutils", + ], + export_include_dirs: ["inc"], + vendor: true, + cflags: [ + "-DDEBUG", + "-Wall", + "-Werror", + ] + ["-DFEATURE_IPA_ANDROID"], + + clang: true, +} diff --git a/data-ipa-cfg-mgr/ipanat/inc/ipa_nat_drvi.h b/data-ipa-cfg-mgr/ipanat/inc/ipa_nat_drvi.h index 8015c984..292a47b9 100644 --- a/data-ipa-cfg-mgr/ipanat/inc/ipa_nat_drvi.h +++ b/data-ipa-cfg-mgr/ipanat/inc/ipa_nat_drvi.h @@ -30,9 +30,9 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef IPA_NAT_DRVI_H #define IPA_NAT_DRVI_H -#include #include #include +#include #include #include #include @@ -40,6 +40,7 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include +#include #include "ipa_nat_logi.h" diff --git a/data-ipa-cfg-mgr/ipanat/src/Android.mk b/data-ipa-cfg-mgr/ipanat/src/Android.mk deleted file mode 100644 index aaa84090..00000000 --- a/data-ipa-cfg-mgr/ipanat/src/Android.mk +++ /dev/null @@ -1,43 +0,0 @@ -BOARD_PLATFORM_LIST := msm8909 -BOARD_PLATFORM_LIST += msm8916 -BOARD_PLATFORM_LIST += msm8917 -TARGET_DISABLE_IPANAT := false - -ifeq ($(TARGET_USES_QMAA),true) -ifneq ($(TARGET_USES_QMAA_OVERRIDE_DATA),true) - TARGET_DISABLE_IPANAT := true -endif #TARGET_USES_QMAA_OVERRIDE_DATA -endif #TARGET_USES_QMAA - -ifneq ($(TARGET_DISABLE_IPANAT),true) -ifneq ($(call is-board-platform-in-list,$(BOARD_PLATFORM_LIST)),true) -ifneq (,$(filter $(QCOM_BOARD_PLATFORMS),$(TARGET_BOARD_PLATFORM))) -ifneq (, $(filter aarch64 arm arm64, $(TARGET_ARCH))) - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../inc -LOCAL_C_INCLUDES += $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr/include -LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ/usr - -LOCAL_SRC_FILES := ipa_nat_drv.c \ - ipa_nat_drvi.c - -LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/../inc -LOCAL_VENDOR_MODULE := true -LOCAL_MODULE_PATH_64 := $(TARGET_OUT_VENDOR)/lib64 -LOCAL_MODULE_PATH_32 := $(TARGET_OUT_VENDOR)/lib -LOCAL_CFLAGS := -DDEBUG -Wall -Werror -LOCAL_CFLAGS += -DFEATURE_IPA_ANDROID -LOCAL_MODULE := libipanat -LOCAL_MODULE_TAGS := optional -LOCAL_PRELINK_MODULE := false -LOCAL_CLANG := true -include $(BUILD_SHARED_LIBRARY) - -endif # $(TARGET_ARCH) -endif -endif -endif