mirror of
				https://github.com/Telecominfraproject/wlan-ap.git
				synced 2025-11-04 04:18:07 +00:00 
			
		
		
		
	Wifi-3522. Correcting an earlier commit for scan failures.
Correcting an earlier commit 4beda3ab66
to consider all the cases where the avl entry needs be deleted when
a scan is either completed or aborted for any reason.
Signed-off-by: ravi vaishnav <ravi.vaishnav@netexperience.com>
			
			
This commit is contained in:
		@@ -2,20 +2,22 @@ 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.orig/src/sm/src/sm_scan_schedule.c
 | 
				
			||||||
+++ opensync-2.0.5.0/src/sm/src/sm_scan_schedule.c
 | 
					+++ opensync-2.0.5.0/src/sm/src/sm_scan_schedule.c
 | 
				
			||||||
@@ -155,6 +155,12 @@ clean:
 | 
					@@ -155,6 +155,14 @@ clean:
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
     /* Remove processed context */
 | 
					     /* Remove processed context */
 | 
				
			||||||
     ds_dlist_remove_head(&g_scan_ctx_list);
 | 
					     ds_dlist_remove_head(&g_scan_ctx_list);
 | 
				
			||||||
+    LOG(DEBUG, "sm_scan_schedule_cb. Scan done. Deleting scan_ctx. %p. %s %s %d\n",
 | 
					+    if (scan_ctx) {
 | 
				
			||||||
 | 
					+	LOG(DEBUG, "sm_scan_schedule_cb. Scan done. Deleting scan_ctx. %p. %s %s %d\n",
 | 
				
			||||||
+		scan_ctx,
 | 
					+		scan_ctx,
 | 
				
			||||||
+		radio_get_name_from_type(scan_ctx->scan_request.radio_cfg->type),
 | 
					+		radio_get_name_from_type(scan_ctx->scan_request.radio_cfg->type),
 | 
				
			||||||
+		radio_get_scan_name_from_type(scan_ctx->scan_request.scan_type),
 | 
					+		radio_get_scan_name_from_type(scan_ctx->scan_request.scan_type),
 | 
				
			||||||
+		scan_ctx->scan_request.chan_list[0]);
 | 
					+		scan_ctx->scan_request.chan_list[0]);
 | 
				
			||||||
 | 
					+    }
 | 
				
			||||||
+
 | 
					+
 | 
				
			||||||
     sm_scan_ctx_free(scan_ctx);
 | 
					     sm_scan_ctx_free(scan_ctx);
 | 
				
			||||||
     scan_ctx = NULL;
 | 
					     scan_ctx = NULL;
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
@@ -163,6 +169,13 @@ clean:
 | 
					@@ -163,6 +171,13 @@ clean:
 | 
				
			||||||
     if (scan_ctx)
 | 
					     if (scan_ctx)
 | 
				
			||||||
     {
 | 
					     {
 | 
				
			||||||
         scan_status = true;
 | 
					         scan_status = true;
 | 
				
			||||||
@@ -29,7 +31,7 @@ Index: opensync-2.0.5.0/src/sm/src/sm_scan_schedule.c
 | 
				
			|||||||
         rc =
 | 
					         rc =
 | 
				
			||||||
             sm_scan_schedule_process (
 | 
					             sm_scan_schedule_process (
 | 
				
			||||||
                     scan_ctx);
 | 
					                     scan_ctx);
 | 
				
			||||||
@@ -303,6 +316,12 @@ bool sm_scan_schedule(
 | 
					@@ -303,6 +318,12 @@ bool sm_scan_schedule(
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
     if (NULL == scan_in_progress) {
 | 
					     if (NULL == scan_in_progress) {
 | 
				
			||||||
         /* Trigger the scan and wait for results */
 | 
					         /* Trigger the scan and wait for results */
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -383,25 +383,29 @@ struct nl80211_scan *nl80211_scan_find(const char *name)
 | 
				
			|||||||
	return nl80211_scan;
 | 
						return nl80211_scan;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int nl80211_scan_add(char *name, target_scan_cb_t *scan_cb, void *scan_ctx)
 | 
					static struct nl80211_scan *
 | 
				
			||||||
 | 
					nl80211_scan_add(char *name, target_scan_cb_t *scan_cb, void *scan_ctx)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct nl80211_scan *nl80211_scan = avl_find_element(&nl80211_scan_tree, name, nl80211_scan, avl);
 | 
						struct nl80211_scan *nl80211_scan = avl_find_element(&nl80211_scan_tree, name, nl80211_scan, avl);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (nl80211_scan)
 | 
						if (!nl80211_scan) {
 | 
				
			||||||
		nl80211_scan_del(nl80211_scan);
 | 
							nl80211_scan = malloc(sizeof(*nl80211_scan));
 | 
				
			||||||
 | 
							if (!nl80211_scan)
 | 
				
			||||||
	nl80211_scan = malloc(sizeof(*nl80211_scan));
 | 
								return NULL;
 | 
				
			||||||
	if (!nl80211_scan)
 | 
							memset(nl80211_scan, 0, sizeof(*nl80211_scan));
 | 
				
			||||||
		return -1;
 | 
							strncpy(nl80211_scan->name, name, IF_NAMESIZE);
 | 
				
			||||||
	memset(nl80211_scan, 0, sizeof(*nl80211_scan));
 | 
							nl80211_scan->avl.key = nl80211_scan->name;
 | 
				
			||||||
	strncpy(nl80211_scan->name, name, IF_NAMESIZE);
 | 
							avl_insert(&nl80211_scan_tree, &nl80211_scan->avl);
 | 
				
			||||||
	nl80211_scan->avl.key = nl80211_scan->name;
 | 
							LOGD("%s: added scan context. avl:%p. scan_ctx:%p",
 | 
				
			||||||
	avl_insert(&nl80211_scan_tree, &nl80211_scan->avl);
 | 
								name, nl80211_scan, scan_ctx);
 | 
				
			||||||
	LOGD("%s: added scan context", name);
 | 
						} else {
 | 
				
			||||||
 | 
							LOGD("nl80211_scan_add: %s: Reusing the avl:%p. scan_ctx:%p\n",
 | 
				
			||||||
 | 
								name, nl80211_scan, nl80211_scan->scan_ctx);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	nl80211_scan->scan_cb = scan_cb;
 | 
						nl80211_scan->scan_cb = scan_cb;
 | 
				
			||||||
	nl80211_scan->scan_ctx = scan_ctx;
 | 
						nl80211_scan->scan_ctx = scan_ctx;
 | 
				
			||||||
	return 0;
 | 
						return nl80211_scan;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void nl80211_scan_del(struct nl80211_scan *nl80211_scan)
 | 
					static void nl80211_scan_del(struct nl80211_scan *nl80211_scan)
 | 
				
			||||||
@@ -415,10 +419,15 @@ static void nl80211_scan_del(struct nl80211_scan *nl80211_scan)
 | 
				
			|||||||
static void nl80211_scan_finish(char *name, bool state)
 | 
					static void nl80211_scan_finish(char *name, bool state)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct nl80211_scan *nl80211_scan = nl80211_scan_find(name);
 | 
						struct nl80211_scan *nl80211_scan = nl80211_scan_find(name);
 | 
				
			||||||
 | 
						target_scan_cb_t *scan_cb;
 | 
				
			||||||
 | 
						void *scan_ctx;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (nl80211_scan) {
 | 
						if (nl80211_scan) {
 | 
				
			||||||
		LOGD("%s: calling context cb", nl80211_scan->name);
 | 
							LOGD("%s: calling context cb", nl80211_scan->name);
 | 
				
			||||||
		(*nl80211_scan->scan_cb)(nl80211_scan->scan_ctx, state);
 | 
							scan_cb = nl80211_scan->scan_cb;
 | 
				
			||||||
 | 
							scan_ctx = nl80211_scan->scan_ctx;
 | 
				
			||||||
 | 
							nl80211_scan_del(nl80211_scan);
 | 
				
			||||||
 | 
							(*scan_cb)(scan_ctx, state);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -572,6 +581,7 @@ int nl80211_scan_trigger(struct nl_call_param *nl_call_param, uint32_t *chan_lis
 | 
				
			|||||||
	unsigned int i, flags = 0;
 | 
						unsigned int i, flags = 0;
 | 
				
			||||||
	int ret = 0;
 | 
						int ret = 0;
 | 
				
			||||||
	uint32_t oper_chan;
 | 
						uint32_t oper_chan;
 | 
				
			||||||
 | 
						struct nl80211_scan *nl80211_scan;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!msg)
 | 
						if (!msg)
 | 
				
			||||||
		return -1;
 | 
							return -1;
 | 
				
			||||||
@@ -606,15 +616,17 @@ int nl80211_scan_trigger(struct nl_call_param *nl_call_param, uint32_t *chan_lis
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	nla_nest_end(msg, freq);
 | 
						nla_nest_end(msg, freq);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = nl80211_scan_add(nl_call_param->ifname, scan_cb, scan_ctx); 
 | 
						nl80211_scan = nl80211_scan_add(nl_call_param->ifname, scan_cb, scan_ctx); 
 | 
				
			||||||
	if (ret ) {
 | 
						if (nl80211_scan == NULL) {
 | 
				
			||||||
		LOG(DEBUG,"%s: scan add failed %d\n", nl_call_param->ifname, ret);
 | 
							LOG(DEBUG,"%s: scan add failed %d\n", nl_call_param->ifname, ret);
 | 
				
			||||||
		return -1;
 | 
							return -1;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ret = unl_genl_request(&unl_req, msg, nl80211_scan_trigger_recv, NULL);
 | 
						ret = unl_genl_request(&unl_req, msg, nl80211_scan_trigger_recv, NULL);
 | 
				
			||||||
	if (ret)
 | 
						if (ret) {
 | 
				
			||||||
 | 
							nl80211_scan_del(nl80211_scan);
 | 
				
			||||||
		LOG(DEBUG, "%s: scan request failed %d\n", nl_call_param->ifname, ret);
 | 
							LOG(DEBUG, "%s: scan request failed %d\n", nl_call_param->ifname, ret);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return ret;
 | 
						return ret;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user