Patchwork driver_nl80211: get rid of family/cache objects

login
register
mail settings
Submitter Johannes Berg
Date Nov. 10, 2011, 2:38 p.m.
Message ID <1320935897.3967.69.camel@jlt3.sipsolutions.net>
Download mbox | patch
Permalink /patch/124887/
State Accepted
Commit 335d42b1a63fcb697c7517eb29b7f2ec4438fa6d
Headers show

Comments

Johannes Berg - Nov. 10, 2011, 2:38 p.m.
From: Johannes Berg <johannes.berg@intel.com>

All we really need is the family ID, and we can
get that with genl_ctrl_resolve() and then don't
need to worry about family/cache objects.

Signed-hostap: Johannes Berg <johannes.berg@intel.com>
---
 src/drivers/driver_nl80211.c |   30 ++++--------------------------
 1 files changed, 4 insertions(+), 26 deletions(-)
Jouni Malinen - Nov. 16, 2011, 2:44 p.m.
On Thu, Nov 10, 2011 at 03:38:17PM +0100, Johannes Berg wrote:
> All we really need is the family ID, and we can
> get that with genl_ctrl_resolve() and then don't
> need to worry about family/cache objects.

Thanks! Applied.

> diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
>  struct nl80211_handles {
>  	struct nl_handle *handle;
> -	struct nl_cache *cache;
>  };

Do you think that we would need to add anything into struct
nl80211_handles in the future or should we just get rid of this wrapper?
Johannes Berg - Nov. 16, 2011, 2:56 p.m.
On Wed, 2011-11-16 at 16:44 +0200, Jouni Malinen wrote:

> > diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
> >  struct nl80211_handles {
> >  	struct nl_handle *handle;
> > -	struct nl_cache *cache;
> >  };
> 
> Do you think that we would need to add anything into struct
> nl80211_handles in the future or should we just get rid of this wrapper?

No, I don't think we need to add anything, and I think we can get rid of
it, I just didn't get around to it when I was writing that patch (and
wanted it to be a separate patch)

johannes

Patch

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 3c98ee0..77a9e50 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -109,23 +109,11 @@  static void nl80211_handle_destroy(struct nl_handle *handle)
 
 	nl_handle_destroy(handle);
 }
-
-static inline int __genl_ctrl_alloc_cache(struct nl_handle *h,
-					  struct nl_cache **cache)
-{
-	struct nl_cache *tmp = genl_ctrl_alloc_cache(h);
-	if (!tmp)
-		return -ENOMEM;
-	*cache = tmp;
-	return 0;
-}
-#define genl_ctrl_alloc_cache __genl_ctrl_alloc_cache
 #endif /* CONFIG_LIBNL20 */
 
 
 struct nl80211_handles {
 	struct nl_handle *handle;
-	struct nl_cache *cache;
 };
 
 
@@ -148,12 +136,6 @@  static int nl_create_handles(struct nl80211_handles *handles, struct nl_cb *cb,
 		goto err;
 	}
 
-	if (genl_ctrl_alloc_cache(handles->handle, &handles->cache) < 0) {
-		wpa_printf(MSG_ERROR, "nl80211: Failed to allocate generic "
-			   "netlink cache (%s)", dbg);
-		goto err;
-	}
-
 	return 0;
 err:
 	nl80211_handle_destroy(handles->handle);
@@ -165,7 +147,6 @@  static void nl_destroy_handles(struct nl80211_handles *handles)
 {
 	if (handles->handle == NULL)
 		return;
-	nl_cache_free(handles->cache);
 	nl80211_handle_destroy(handles->handle);
 	handles->handle = NULL;
 }
@@ -191,7 +172,7 @@  struct nl80211_global {
 	struct netlink_data *netlink;
 	struct nl_cb *nl_cb;
 	struct nl80211_handles nl;
-	struct genl_family *nl80211;
+	int nl80211_id;
 	int ioctl_sock; /* socket for ioctl() use */
 
 	struct nl80211_handles nl_event;
@@ -525,7 +506,7 @@  nla_put_failure:
 static void * nl80211_cmd(struct wpa_driver_nl80211_data *drv,
 			  struct nl_msg *msg, int flags, uint8_t cmd)
 {
-	return genlmsg_put(msg, 0, 0, genl_family_get_id(drv->global->nl80211),
+	return genlmsg_put(msg, 0, 0, drv->global->nl80211_id,
 			   0, flags, cmd, 0);
 }
 
@@ -2539,9 +2520,8 @@  static int wpa_driver_nl80211_init_nl_global(struct nl80211_global *global)
 	if (nl_create_handles(&global->nl, global->nl_cb, "nl"))
 		goto err;
 
-	global->nl80211 = genl_ctrl_search_by_name(global->nl.cache,
-						   "nl80211");
-	if (global->nl80211 == NULL) {
+	global->nl80211_id = genl_ctrl_resolve(global->nl.handle, "nl80211");
+	if (global->nl80211_id < 0) {
 		wpa_printf(MSG_ERROR, "nl80211: 'nl80211' generic netlink not "
 			   "found");
 		goto err;
@@ -7999,8 +7979,6 @@  static void nl80211_global_deinit(void *priv)
 	if (global->netlink)
 		netlink_deinit(global->netlink);
 
-	if (global->nl80211)
-		genl_family_put(global->nl80211);
 	nl_destroy_handles(&global->nl);
 
 	if (global->nl_event.handle) {