[PATCH v2 05/11] nl80211: tie connect_or_ctrl handle to bss init/destroy

Markus Theil <[email protected]>
Newsgroups gmane.linux.drivers.hostap
Message-ID <[email protected]>
This commit creates a connect_or_ctrl nl_sock* for every
bss uncoditionally. It is used in follow up patches for
nl80211 control port rx.

Signed-off-by: Markus Theil <[email protected]>
---
 src/drivers/driver_nl80211.c | 49 ++++++++++++++++++------------------
 1 file changed, 25 insertions(+), 24 deletions(-)

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index b1f70d9fe..7e481d757 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -1918,6 +1918,25 @@ static void wpa_driver_nl80211_handle_eapol_tx_status(int sock,
 }
 
 
+static int nl80211_init_connect_or_ctrl_handle(struct i802_bss *bss)
+{
+	if (bss->nl_connect_or_ctrl) {
+		wpa_printf(MSG_DEBUG,
+			   "nl80211: Connect handle already created (nl_connect_or_ctrl=%p)",
+			   bss->nl_connect_or_ctrl);
+		return -1;
+	}
+
+	bss->nl_connect_or_ctrl = nl_create_handle(bss->nl_cb, "connect_or_ctrl");
+	if (!bss->nl_connect_or_ctrl)
+		return -1;
+	nl80211_register_eloop_read(&bss->nl_connect_or_ctrl,
+				    wpa_driver_nl80211_event_receive,
+				    bss->nl_cb, 1);
+	return 0;
+}
+
+
 static int nl80211_init_bss(struct i802_bss *bss)
 {
 	bss->nl_cb = nl_cb_alloc(NL_CB_DEFAULT);
@@ -1929,6 +1948,8 @@ static int nl80211_init_bss(struct i802_bss *bss)
 	nl_cb_set(bss->nl_cb, NL_CB_VALID, NL_CB_CUSTOM,
 		  process_bss_event, bss);
 
+	nl80211_init_connect_or_ctrl_handle(bss);
+
 	return 0;
 }
 
@@ -1937,6 +1958,10 @@ static void nl80211_destroy_bss(struct i802_bss *bss)
 {
 	nl_cb_put(bss->nl_cb);
 	bss->nl_cb = NULL;
+
+	if (bss->nl_connect_or_ctrl) {
+		nl80211_destroy_eloop_handle(&bss->nl_connect_or_ctrl, 1);
+	}
 }
 
 
@@ -2160,25 +2185,6 @@ static int nl80211_register_action_frame(struct i802_bss *bss,
 }
 
 
-static int nl80211_init_connect_handle(struct i802_bss *bss)
-{
-	if (bss->nl_connect_or_ctrl) {
-		wpa_printf(MSG_DEBUG,
-			   "nl80211: Connect handle already created (nl_connect_or_ctrl=%p)",
-			   bss->nl_connect_or_ctrl);
-		return -1;
-	}
-
-	bss->nl_connect_or_ctrl = nl_create_handle(bss->nl_cb, "connect");
-	if (!bss->nl_connect_or_ctrl)
-		return -1;
-	nl80211_register_eloop_read(&bss->nl_connect_or_ctrl,
-				    wpa_driver_nl80211_event_receive,
-				    bss->nl_cb, 1);
-	return 0;
-}
-
-
 static int nl80211_mgmt_subscribe_non_ap(struct i802_bss *bss)
 {
 	struct wpa_driver_nl80211_data *drv = bss->drv;
@@ -2716,8 +2722,6 @@ wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv,
 	if (drv->vendor_cmd_test_avail)
 		qca_vendor_test(drv);
 
-	nl80211_init_connect_handle(bss);
-
 	return 0;
 }
 
@@ -2830,9 +2834,6 @@ static void wpa_driver_nl80211_deinit(struct i802_bss *bss)
 		nl80211_del_p2pdev(bss);
 	}
 
-	if (bss->nl_connect_or_ctrl)
-		nl80211_destroy_eloop_handle(&bss->nl_connect_or_ctrl, 1);
-
 	nl80211_destroy_bss(drv->first_bss);
 
 	os_free(drv->filter_ssids);
-- 
2.26.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.