From 4beda3ab6607825639f9c018456a83a8e79f2d72 Mon Sep 17 00:00:00 2001 From: ravi vaishnav Date: Thu, 12 Aug 2021 18:21:52 -0400 Subject: [PATCH] Wifi-3463. Fix for scan timeout with scan on same interface Successive scan requests on same interface cause scan timeout. Scan requests are enqueued at the Opensync layer and is designed to handle the requests sequentially. If there are successive scan requests for the same interface, then we end up deleteling an on-going scan context. This is due to the interface name being used as key for the AVL entries, and we were trying to reuse the AVL entry if one already exist. Solution is to always allocate a new entry without any reuse. Signed-off-by: ravi vaishnav --- .../opensync/patches/42-sm_dbg_log.patch | 44 +++++++++++++++++++ .../src/lib/target/src/stats_nl80211.c | 24 +++++----- 2 files changed, 57 insertions(+), 11 deletions(-) create mode 100644 feeds/wlan-ap/opensync/patches/42-sm_dbg_log.patch diff --git a/feeds/wlan-ap/opensync/patches/42-sm_dbg_log.patch b/feeds/wlan-ap/opensync/patches/42-sm_dbg_log.patch new file mode 100644 index 000000000..3616b0fc6 --- /dev/null +++ b/feeds/wlan-ap/opensync/patches/42-sm_dbg_log.patch @@ -0,0 +1,44 @@ +Index: opensync-2.0.5.0/src/sm/src/sm_scan_schedule.c +=================================================================== +--- opensync-2.0.5.0.orig/src/sm/src/sm_scan_schedule.c ++++ opensync-2.0.5.0/src/sm/src/sm_scan_schedule.c +@@ -155,6 +155,12 @@ clean: + + /* Remove processed context */ + ds_dlist_remove_head(&g_scan_ctx_list); ++ LOG(DEBUG, "sm_scan_schedule_cb. Scan done. Deleting scan_ctx. %p. %s %s %d\n", ++ scan_ctx, ++ radio_get_name_from_type(scan_ctx->scan_request.radio_cfg->type), ++ radio_get_scan_name_from_type(scan_ctx->scan_request.scan_type), ++ scan_ctx->scan_request.chan_list[0]); ++ + sm_scan_ctx_free(scan_ctx); + scan_ctx = NULL; + +@@ -163,6 +169,13 @@ clean: + if (scan_ctx) + { + scan_status = true; ++ ++ LOG(DEBUG, "sm_scan_schedule_cb. Schedule next scan request. %p. %s %s %d\n", ++ scan_ctx, ++ radio_get_name_from_type(scan_ctx->scan_request.radio_cfg->type), ++ radio_get_scan_name_from_type(scan_ctx->scan_request.scan_type), ++ scan_ctx->scan_request.chan_list[0]); ++ + rc = + sm_scan_schedule_process ( + scan_ctx); +@@ -303,6 +316,12 @@ bool sm_scan_schedule( + + if (NULL == scan_in_progress) { + /* Trigger the scan and wait for results */ ++ LOG(DEBUG, "sm_scan_schedule. Schedule scan request. %p. %s %s %d\n", ++ scan_ctx, ++ radio_get_name_from_type(scan_ctx->scan_request.radio_cfg->type), ++ radio_get_scan_name_from_type(scan_ctx->scan_request.scan_type), ++ scan_ctx->scan_request.chan_list[0]); ++ + rc = + sm_scan_schedule_process( + scan_ctx); diff --git a/feeds/wlan-ap/opensync/src/platform/openwrt/src/lib/target/src/stats_nl80211.c b/feeds/wlan-ap/opensync/src/platform/openwrt/src/lib/target/src/stats_nl80211.c index 8515b1833..144248ec0 100644 --- a/feeds/wlan-ap/opensync/src/platform/openwrt/src/lib/target/src/stats_nl80211.c +++ b/feeds/wlan-ap/opensync/src/platform/openwrt/src/lib/target/src/stats_nl80211.c @@ -54,6 +54,8 @@ struct nl80211_scan { static struct avl_tree nl80211_scan_tree = AVL_TREE_INIT(nl80211_scan_tree, avl_strcmp, false, NULL); +static void nl80211_scan_del(struct nl80211_scan *nl80211_scan); + static int nl80211_chainmask_recv(struct nl_msg *msg, void *arg) { struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); @@ -383,16 +385,17 @@ static int nl80211_scan_add(char *name, target_scan_cb_t *scan_cb, void *scan_ct { struct nl80211_scan *nl80211_scan = avl_find_element(&nl80211_scan_tree, name, nl80211_scan, avl); - if (!nl80211_scan) { - nl80211_scan = malloc(sizeof(*nl80211_scan)); - if (!nl80211_scan) - return -1; - memset(nl80211_scan, 0, sizeof(*nl80211_scan)); - strncpy(nl80211_scan->name, name, IF_NAMESIZE); - nl80211_scan->avl.key = nl80211_scan->name; - avl_insert(&nl80211_scan_tree, &nl80211_scan->avl); - LOGD("%s: added scan context", name); - } + if (nl80211_scan) + nl80211_scan_del(nl80211_scan); + + nl80211_scan = malloc(sizeof(*nl80211_scan)); + if (!nl80211_scan) + return -1; + memset(nl80211_scan, 0, sizeof(*nl80211_scan)); + strncpy(nl80211_scan->name, name, IF_NAMESIZE); + nl80211_scan->avl.key = nl80211_scan->name; + avl_insert(&nl80211_scan_tree, &nl80211_scan->avl); + LOGD("%s: added scan context", name); nl80211_scan->scan_cb = scan_cb; nl80211_scan->scan_ctx = scan_ctx; @@ -414,7 +417,6 @@ static void nl80211_scan_finish(char *name, bool state) if (nl80211_scan) { LOGD("%s: calling context cb", nl80211_scan->name); (*nl80211_scan->scan_cb)(nl80211_scan->scan_ctx, state); - nl80211_scan_del(nl80211_scan); } }