[PATCH v2 3/6] nl80211: Pre-position some handle_preq for global objects.

greearb at candelatech.com greearb
Thu Oct 20 13:21:21 PDT 2011


From: Ben Greear <greearb at candelatech.com>

This is just to decrease the size & complexity of the big
patch that makes netlink objects global.

Signed-off-by: Ben Greear <greearb at candelatech.com>
---
:100644 100644 ddd4ebc... d8cbf45... M	src/drivers/driver_nl80211.c
 src/drivers/driver_nl80211.c |   85 +++++++++++++++++++++--------------------
 1 files changed, 44 insertions(+), 41 deletions(-)

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index ddd4ebc..d8cbf45 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -105,6 +105,7 @@ static void nl80211_handle_destroy(struct nl_handle *handle)
 #endif
 
 #define DRVNL nl80211
+#define DRVPREQ nl_handle_preq
 
 /* TODO:  Move this somewhere central and put struct_ids
  * in all structs that are passed around as void* so that
@@ -2444,7 +2445,7 @@ static void wpa_driver_nl80211_deinit(void *priv)
 		l2_packet_deinit(drv->l2);
 #endif /* CONFIG_AP */
 
-	if (drv->nl_handle_preq)
+	if (drv->DRVPREQ)
 		wpa_driver_nl80211_probe_req_report(bss, 0);
 	if (bss->added_if_into_bridge) {
 		if (linux_br_del_if(drv->ioctl_sock, bss->brname, bss->ifname)
@@ -6947,70 +6948,72 @@ static int wpa_driver_nl80211_probe_req_report(void *priv, int report)
 	struct wpa_driver_nl80211_data *drv = bss->drv;
 
 	if (!report) {
-		if (drv->nl_handle_preq) {
+		if (drv->DRVPREQ) {
 			eloop_unregister_read_sock(
-				nl_socket_get_fd(drv->nl_handle_preq));
+				nl_socket_get_fd(drv->DRVPREQ));
 			nl_cache_free(drv->nl_cache_preq);
-			nl80211_handle_destroy(drv->nl_handle_preq);
-			drv->nl_handle_preq = NULL;
+			nl80211_handle_destroy(drv->DRVPREQ);
+			drv->DRVPREQ = NULL;
 		}
 		return 0;
 	}
 
-	if (drv->nl_handle_preq) {
+	if (drv->DRVPREQ) {
 		wpa_printf(MSG_DEBUG, "nl80211: Probe Request reporting "
 			   "already on!");
 		return 0;
 	}
 
-	drv->nl_handle_preq = nl80211_handle_alloc(drv->nl_cb);
-	if (drv->nl_handle_preq == NULL) {
-		wpa_printf(MSG_ERROR, "nl80211: Failed to allocate "
-			   "netlink callbacks (preq)");
-		goto out_err1;
-	}
+	{ /* get ready for global pre-req */
+		drv->DRVPREQ = nl80211_handle_alloc(drv->nl_cb);
+		if (drv->DRVPREQ == NULL) {
+			wpa_printf(MSG_ERROR, "nl80211: Failed to allocate "
+				   "netlink callbacks (preq)");
+			goto out_err1;
+		}
 
-	if (genl_connect(drv->nl_handle_preq)) {
-		wpa_printf(MSG_ERROR, "nl80211: Failed to connect to "
-			   "generic netlink (preq)");
-		goto out_err2;
-		return -1;
-	}
+		if (genl_connect(drv->DRVPREQ)) {
+			wpa_printf(MSG_ERROR, "nl80211: Failed to connect to "
+				   "generic netlink (preq)");
+			goto out_err2;
+			return -1;
+		}
 
 #ifdef CONFIG_LIBNL20
-	if (genl_ctrl_alloc_cache(drv->nl_handle_preq,
-				  &drv->nl_cache_preq) < 0) {
-		wpa_printf(MSG_ERROR, "nl80211: Failed to allocate generic "
-			   "netlink cache (preq)");
-		goto out_err2;
-	}
+		if (genl_ctrl_alloc_cache(drv->DRVPREQ,
+					  &drv->nl_cache_preq) < 0) {
+			wpa_printf(MSG_ERROR, "nl80211: Failed to allocate generic "
+				   "netlink cache (preq)");
+			goto out_err2;
+		}
 #else /* CONFIG_LIBNL20 */
-	drv->nl_cache_preq = genl_ctrl_alloc_cache(drv->nl_handle_preq);
-	if (drv->nl_cache_preq == NULL) {
-		wpa_printf(MSG_ERROR, "nl80211: Failed to allocate generic "
-			   "netlink cache (preq)");
-		goto out_err2;
-	}
+		drv->nl_cache_preq = genl_ctrl_alloc_cache(drv->DRVPREQ);
+		if (drv->nl_cache_preq == NULL) {
+			wpa_printf(MSG_ERROR, "nl80211: Failed to allocate generic "
+				   "netlink cache (preq)");
+			goto out_err2;
+		}
 #endif /* CONFIG_LIBNL20 */
 
-	if (nl80211_register_frame(drv, drv->nl_handle_preq,
-				   (WLAN_FC_TYPE_MGMT << 2) |
-				   (WLAN_FC_STYPE_PROBE_REQ << 4),
-				   NULL, 0) < 0) {
-		goto out_err3;
-	}
+		if (nl80211_register_frame(drv, drv->DRVPREQ,
+					   (WLAN_FC_TYPE_MGMT << 2) |
+					   (WLAN_FC_STYPE_PROBE_REQ << 4),
+					   NULL, 0) < 0) {
+			goto out_err3;
+		}
 
-	eloop_register_read_sock(nl_socket_get_fd(drv->nl_handle_preq),
-				 wpa_driver_nl80211_event_receive, drv,
-				 drv->nl_handle_preq);
+		eloop_register_read_sock(nl_socket_get_fd(drv->DRVPREQ),
+					 wpa_driver_nl80211_event_receive, drv,
+					 drv->DRVPREQ);
+	}
 
 	return 0;
 
  out_err3:
 	nl_cache_free(drv->nl_cache_preq);
  out_err2:
-	nl80211_handle_destroy(drv->nl_handle_preq);
-	drv->nl_handle_preq = NULL;
+	nl80211_handle_destroy(drv->DRVPREQ);
+	drv->DRVPREQ = NULL;
  out_err1:
 	return -1;
 }
-- 
1.7.3.4




More information about the Hostap mailing list