From: Johannes Berg <johannes@sipsolutions.net>
To: John Linville <linville@tuxdriver.com>
Cc: linux-wireless <linux-wireless@vger.kernel.org>,
Michael Wu <flamingice@sourmilk.net>
Subject: [PATCH] cfg80211/nl80211: use rtnl
Date: Sat, 21 Apr 2007 11:20:35 +0200 [thread overview]
Message-ID: <1177147235.5941.0.camel@johannes.berg> (raw)
Because the wext/no-rtnl patch was controversial at this time, this patch
adds rtnl locking to cfg80211 so all calls to driver/stack operations are
made with rtnl held.
Once wext compat support in cfg80211 is mature enough and cfg80211 can fully
replace wext, this will be revisited.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
include/net/cfg80211.h | 4 ++++
net/wireless/nl80211.c | 19 +++++++++++++++++++
net/wireless/sysfs.c | 4 ++++
3 files changed, 27 insertions(+)
--- wireless-dev.orig/include/net/cfg80211.h 2007-04-21 10:51:54.540655118 +0200
+++ wireless-dev/include/net/cfg80211.h 2007-04-21 10:53:18.160655118 +0200
@@ -86,6 +86,10 @@ struct wiphy;
* All callbacks except where otherwise noted should return 0
* on success or a negative error code.
*
+ * All operations are currently invoked under rtnl for consistency with the
+ * wireless extensions but this is subject to reevaluation as soon as this
+ * code is used more widely and we have a first user without wext.
+ *
* @add_virtual_intf: create a new virtual interface with the given name
*
* @del_virtual_intf: remove the virtual interface determined by ifindex.
--- wireless-dev.orig/net/wireless/nl80211.c 2007-04-21 10:48:26.340655118 +0200
+++ wireless-dev/net/wireless/nl80211.c 2007-04-21 11:01:02.490655118 +0200
@@ -12,6 +12,7 @@
#include <linux/if_ether.h>
#include <linux/ieee80211.h>
#include <linux/nl80211.h>
+#include <linux/rtnetlink.h>
#include <net/genetlink.h>
#include <net/cfg80211.h>
#include "core.h"
@@ -312,8 +313,10 @@ static int nl80211_add_virt_intf(struct
goto unlock;
}
+ rtnl_lock();
err = drv->ops->add_virtual_intf(&drv->wiphy,
nla_data(info->attrs[NL80211_ATTR_IFNAME]), type);
+ rtnl_unlock();
unlock:
cfg80211_put_dev(drv);
@@ -337,7 +340,9 @@ static int nl80211_del_virt_intf(struct
goto out;
}
+ rtnl_lock();
err = drv->ops->del_virtual_intf(&drv->wiphy, ifindex);
+ rtnl_unlock();
out:
cfg80211_put_dev(drv);
@@ -369,7 +374,9 @@ static int nl80211_change_virt_intf(stru
goto unlock;
}
+ rtnl_lock();
err = drv->ops->change_virtual_intf(&drv->wiphy, ifindex, type);
+ rtnl_unlock();
unlock:
cfg80211_put_dev(drv);
@@ -394,7 +401,9 @@ static int nl80211_get_association(struc
goto out_put_drv;
}
+ rtnl_lock();
err = drv->ops->get_association(&drv->wiphy, dev, bssid);
+ rtnl_unlock();
if (err < 0)
goto out_put_drv;
@@ -464,7 +473,9 @@ static int nl80211_associate(struct sk_b
assoc_params.valid |= ASSOC_PARAMS_TIMEOUT;
}
+ rtnl_lock();
err = drv->ops->associate(&drv->wiphy, dev, &assoc_params);
+ rtnl_unlock();
out:
cfg80211_put_dev(drv);
@@ -499,7 +510,9 @@ static int nl80211_disassoc_deauth(struc
goto out;
}
+ rtnl_lock();
err = act(&drv->wiphy, dev);
+ rtnl_unlock();
out:
cfg80211_put_dev(drv);
dev_put(dev);
@@ -566,7 +579,9 @@ static int nl80211_get_auth_list(struct
cb.skb = msg;
cb.idx = 1;
+ rtnl_lock();
err = drv->ops->get_auth_list(&drv->wiphy, dev, &cb, add_bssid);
+ rtnl_unlock();
if (err)
goto msg_free;
@@ -680,7 +695,9 @@ static int nl80211_initiate_scan(struct
params.channels = channels;
params.n_channels = count;
+ rtnl_lock();
err = drv->ops->initiate_scan(&drv->wiphy, dev, ¶ms);
+ rtnl_unlock();
kfree(channels);
out:
@@ -769,7 +786,9 @@ static int nl80211_key_cmd(struct sk_buf
params.macaddress = NULL;
}
+ rtnl_lock();
err = act(&drv->wiphy, dev, ¶ms);
+ rtnl_unlock();
out:
cfg80211_put_dev(drv);
--- wireless-dev.orig/net/wireless/sysfs.c 2007-04-21 10:53:26.160655118 +0200
+++ wireless-dev/net/wireless/sysfs.c 2007-04-21 10:53:54.400655118 +0200
@@ -51,8 +51,10 @@ static ssize_t _store_add_iface(struct d
if (!rdev->ops->add_virtual_intf)
return -ENOSYS;
+ rtnl_lock();
res = rdev->ops->add_virtual_intf(&rdev->wiphy, (char*)buf,
NL80211_IFTYPE_UNSPECIFIED);
+ rtnl_unlock();
return res ? res : len;
}
@@ -77,7 +79,9 @@ static ssize_t _store_remove_iface(struc
ifidx = netdev->ifindex;
dev_put(netdev);
+ rtnl_lock();
res = rdev->ops->del_virtual_intf(&rdev->wiphy, ifidx);
+ rtnl_unlock();
return res ? res : len;
}
reply other threads:[~2007-04-21 9:18 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1177147235.5941.0.camel@johannes.berg \
--to=johannes@sipsolutions.net \
--cc=flamingice@sourmilk.net \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox