diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-13 23:17:33 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-07-13 23:17:33 +0000 |
commit | 9f96d8c89658e6d3207b51ef0840507b4aaf1940 (patch) | |
tree | 41770415552494960a36a282beb9c1aeadf4c660 | |
parent | f4bf9ccb9f0af1fe31662cf53e8222325510d2e2 (diff) | |
parent | 87bf01164a8ab09760e7082839dbaabf444f53a1 (diff) | |
download | wlan-9f96d8c89658e6d3207b51ef0840507b4aaf1940.tar.gz |
Snap for 10493005 from 87bf01164a8ab09760e7082839dbaabf444f53a1 to udc-d1-release
Change-Id: I6f53daad20b2c44558092ff34241647ef31aa0ce
-rwxr-xr-x | bcmdhd/wifi_hal/cpp_bindings.cpp | 4 | ||||
-rw-r--r-- | bcmdhd/wifi_hal/wifi_hal.cpp | 58 |
2 files changed, 49 insertions, 13 deletions
diff --git a/bcmdhd/wifi_hal/cpp_bindings.cpp b/bcmdhd/wifi_hal/cpp_bindings.cpp index fa120e7..a7d6241 100755 --- a/bcmdhd/wifi_hal/cpp_bindings.cpp +++ b/bcmdhd/wifi_hal/cpp_bindings.cpp @@ -653,8 +653,10 @@ int WifiCommand::requestResponse(WifiRequest& request) { int err = 0; struct nl_cb *cb = nl_cb_alloc(NL_CB_DEFAULT); - if (!cb) + if (!cb) { + ALOGE("nl80211: cb alloc failed"); goto out; + } err = nl_send_auto_complete(mInfo->cmd_sock, request.getMessage()); /* send message */ if (err < 0) diff --git a/bcmdhd/wifi_hal/wifi_hal.cpp b/bcmdhd/wifi_hal/wifi_hal.cpp index e6a2c50..74e869a 100644 --- a/bcmdhd/wifi_hal/wifi_hal.cpp +++ b/bcmdhd/wifi_hal/wifi_hal.cpp @@ -628,6 +628,13 @@ static void internal_cleaned_up_handler(wifi_handle handle) info->event_sock = NULL; } + if (info->interfaces) { + for (int i = 0; i < info->num_interfaces; i++) { + free(info->interfaces[i]); + } + free(info->interfaces); + } + DestroyResponseLock(); pthread_mutex_destroy(&info->cb_lock); free(info); @@ -1270,8 +1277,10 @@ class AndroidPktFilterCommand : public WifiCommand { int createSetPktFilterRequest(WifiRequest& request) { u8 *program = new u8[mProgramLen]; NULL_CHECK_RETURN(program, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY); + ALOGE("Success to allocate program of len: %d\n", mProgramLen); int result = request.create(GOOGLE_OUI, APF_SUBCMD_SET_FILTER); if (result < 0) { + ALOGE("Failed to create cmd: %d, err %d\n", APF_SUBCMD_SET_FILTER, result); delete[] program; return result; } @@ -1279,11 +1288,13 @@ class AndroidPktFilterCommand : public WifiCommand { nlattr *data = request.attr_start(NL80211_ATTR_VENDOR_DATA); result = request.put_u32(APF_ATTRIBUTE_PROGRAM_LEN, mProgramLen); if (result < 0) { + ALOGE("Failed to put the program_len %d, err %d\n", mProgramLen, result); goto exit; } memcpy(program, mProgram, mProgramLen); result = request.put(APF_ATTRIBUTE_PROGRAM, program, mProgramLen); if (result < 0) { + ALOGE("Failed to copy program_ptr %d, err %d\n", mProgramLen, result); goto exit; } exit: request.attr_end(data); @@ -1316,6 +1327,7 @@ exit: request.attr_end(data); WifiRequest request(familyId(), ifaceId()); int result = createRequest(request); if (result < 0) { + ALOGI("CreateRequest failed for APF, result = %d", result); return result; } result = requestResponse(request); @@ -1332,7 +1344,7 @@ exit: request.attr_end(data); } int handleResponse(WifiEvent& reply) { - ALOGD("In SetAPFCommand::handleResponse"); + ALOGE("In SetAPFCommand::handleResponse mReqType %d\n", mReqType); if (reply.get_cmd() != NL80211_CMD_VENDOR) { ALOGD("Ignoring reply with cmd = %d", reply.get_cmd()); @@ -1345,13 +1357,13 @@ exit: request.attr_end(data); nlattr *vendor_data = reply.get_attribute(NL80211_ATTR_VENDOR_DATA); int len = reply.get_vendor_data_len(); - ALOGD("Id = %0x, subcmd = %d, len = %d", id, subcmd, len); + ALOGI("Id = %0x, subcmd = %d, len = %d", id, subcmd, len); if (vendor_data == NULL || len == 0) { ALOGE("no vendor data in SetAPFCommand response; ignoring it"); return NL_SKIP; } - if( mReqType == SET_APF_PROGRAM) { - ALOGD("Response received for set packet filter command\n"); + if (mReqType == SET_APF_PROGRAM) { + ALOGE("Response received for set packet filter command\n"); } else if (mReqType == GET_APF_CAPABILITIES) { *mVersion = 0; *mMaxLen = 0; @@ -1718,6 +1730,11 @@ wifi_error wifi_init_interfaces(wifi_handle handle) if (is_wifi_interface(de->d_name)) { interface_info *ifinfo = (interface_info *)malloc(sizeof(interface_info)); if (!ifinfo) { + if (info->interfaces) { + for (int j = 0; j < i; j++) { + free(info->interfaces[j]); + } + } free(info->interfaces); info->num_interfaces = 0; closedir(d); @@ -1725,6 +1742,7 @@ wifi_error wifi_init_interfaces(wifi_handle handle) } memset(ifinfo, 0, sizeof(interface_info)); if (get_interface(de->d_name, ifinfo) != WIFI_SUCCESS) { + free(ifinfo); continue; } /* Mark as static iface */ @@ -1982,7 +2000,15 @@ static wifi_error wifi_get_packet_filter_capabilities(wifi_interface_handle hand static wifi_error wifi_set_packet_filter(wifi_interface_handle handle, const u8 *program, u32 len) { - ALOGD("Setting APF program, halHandle = %p\n", handle); + char iface_name[IFNAMSIZ]; + + ALOGE("Setting APF program, halHandle = %p\n", handle); + if (wifi_get_iface_name(handle, iface_name, sizeof(iface_name)) != WIFI_SUCCESS) { + ALOGE("%s : Invalid interface handle\n", __func__); + return WIFI_ERROR_INVALID_ARGS; + } + ALOGE("Set apf filter for iface = %s\n", iface_name); + AndroidPktFilterCommand *cmd = new AndroidPktFilterCommand(handle, program, len); NULL_CHECK_RETURN(cmd, "memory allocation failure", WIFI_ERROR_OUT_OF_MEMORY); wifi_error result = (wifi_error)cmd->start(); @@ -2658,26 +2684,34 @@ wifi_error wifi_virtual_interface_delete(wifi_handle handle, const char* ifname) return WIFI_ERROR_UNKNOWN; } + /* Check if interface delete requested on valid interface */ while (i < info->max_num_interfaces) { if (info->interfaces[i] != NULL && strncmp(info->interfaces[i]->name, ifname, sizeof(info->interfaces[i]->name)) == 0) { - if (info->interfaces[i]->is_virtual == false) { - ALOGI("%s: %s is static iface, skip delete\n", - __FUNCTION__, ifname); - return WIFI_SUCCESS; + if (!get_halutil_mode()) { + if (info->interfaces[i]->is_virtual == false) { + ALOGI("%s: %s is static iface, skip delete\n", + __FUNCTION__, ifname); + return WIFI_SUCCESS; + } + } else { + ALOGI("%s: %s delete iface", __FUNCTION__, ifname); + break; + } } - } i++; } - ALOGD("%s: iface name=%s\n", __FUNCTION__, ifname); + ALOGI("%s: iface name=%s\n", __FUNCTION__, ifname); wlan0Handle = wifi_get_wlan_interface((wifi_handle)handle, ifaceHandles, numIfaceHandles); VirtualIfaceConfig command(wlan0Handle, ifname, (nl80211_iftype)0, 0); ret = (wifi_error)command.deleteIface(); if (ret != WIFI_SUCCESS) { ALOGE("%s: Iface delete Error:%d", __FUNCTION__,ret); - return ret; + /* If lower layer returns an error, hang event is expected to do wifi reset + * and hal state needs to be cleared irrespectivily. Hence fall-through. + */ } /* Update dynamic interface list */ added_ifaces.erase(std::remove(added_ifaces.begin(), added_ifaces.end(), std::string(ifname)), |