From: Johannes Berg <johannes@sipsolutions.net>
To: linux-wireless@vger.kernel.org
Subject: [RFT 3/4] mac80211: push interface checks down
Date: Sun, 06 Jul 2008 01:47:38 +0200 [thread overview]
Message-ID: <20080705235014.191243000@sipsolutions.net> (raw)
In-Reply-To: 20080705234735.210585000@sipsolutions.net
This patch pushes the "netif_running()" and "same type as before"
checks down into ieee80211_if_change_type() to centralise the
logic instead of duplicating it for cfg80211 and wext.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
net/mac80211/cfg.c | 8 ++++----
net/mac80211/ieee80211_i.h | 4 ++--
net/mac80211/iface.c | 20 ++++++++++++++++++--
net/mac80211/wext.c | 9 +--------
4 files changed, 25 insertions(+), 16 deletions(-)
--- everything.orig/net/mac80211/cfg.c 2008-07-05 23:33:16.000000000 +0200
+++ everything/net/mac80211/cfg.c 2008-07-05 23:33:18.000000000 +0200
@@ -84,22 +84,22 @@ static int ieee80211_change_iface(struct
struct net_device *dev;
enum ieee80211_if_types itype;
struct ieee80211_sub_if_data *sdata;
+ int ret;
/* we're under RTNL */
dev = __dev_get_by_index(&init_net, ifindex);
if (!dev)
return -ENODEV;
- if (netif_running(dev))
- return -EBUSY;
-
itype = nl80211_type_to_mac80211_type(type);
if (itype == IEEE80211_IF_TYPE_INVALID)
return -EINVAL;
sdata = IEEE80211_DEV_TO_SUB_IF(dev);
- ieee80211_if_change_type(sdata, itype);
+ ret = ieee80211_if_change_type(sdata, itype);
+ if (ret)
+ return ret;
if (ieee80211_vif_is_mesh(&sdata->vif) && params->mesh_id_len)
ieee80211_if_sta_set_mesh_id(&sdata->u.sta,
--- everything.orig/net/mac80211/ieee80211_i.h 2008-07-05 23:33:16.000000000 +0200
+++ everything/net/mac80211/ieee80211_i.h 2008-07-05 23:33:18.000000000 +0200
@@ -929,8 +929,8 @@ void ieee80211_if_setup(struct net_devic
int ieee80211_if_add(struct ieee80211_local *local, const char *name,
struct net_device **new_dev, enum ieee80211_if_types type,
struct vif_params *params);
-void ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,
- enum ieee80211_if_types type);
+int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,
+ enum ieee80211_if_types type);
void ieee80211_if_remove(struct net_device *dev);
void ieee80211_remove_interfaces(struct ieee80211_local *local);
--- everything.orig/net/mac80211/iface.c 2008-07-05 23:33:16.000000000 +0200
+++ everything/net/mac80211/iface.c 2008-07-05 23:33:18.000000000 +0200
@@ -138,9 +138,23 @@ static void ieee80211_setup_sdata(struct
ieee80211_debugfs_add_netdev(sdata);
}
-void ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,
- enum ieee80211_if_types type)
+int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,
+ enum ieee80211_if_types type)
{
+ ASSERT_RTNL();
+
+ if (type == sdata->vif.type)
+ return 0;
+
+ /*
+ * We could, here, on changes between IBSS/STA/MESH modes,
+ * invoke an MLME function instead that disassociates etc.
+ * and goes into the requested mode.
+ */
+
+ if (netif_running(sdata->dev))
+ return -EBUSY;
+
/* Purge and reset type-dependent state. */
ieee80211_teardown_sdata(sdata->dev);
ieee80211_setup_sdata(sdata, type);
@@ -149,6 +163,8 @@ void ieee80211_if_change_type(struct iee
sdata->basic_rates = 0;
sdata->drop_unencrypted = 0;
sdata->sequence = 0;
+
+ return 0;
}
int ieee80211_if_add(struct ieee80211_local *local, const char *name,
--- everything.orig/net/mac80211/wext.c 2008-07-05 23:33:16.000000000 +0200
+++ everything/net/mac80211/wext.c 2008-07-05 23:33:18.000000000 +0200
@@ -296,14 +296,7 @@ static int ieee80211_ioctl_siwmode(struc
return -EINVAL;
}
- if (type == sdata->vif.type)
- return 0;
- if (netif_running(dev))
- return -EBUSY;
-
- ieee80211_if_change_type(sdata, type);
-
- return 0;
+ return ieee80211_if_change_type(sdata, type);
}
--
next prev parent reply other threads:[~2008-07-05 23:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-05 23:47 [RFT 0/4] mac80211 improvements Johannes Berg
2008-07-05 23:47 ` [RFT 1/4] mac80211: make master netdev handling sane Johannes Berg
2008-07-06 13:44 ` Kalle Valo
2008-07-08 10:03 ` Johannes Berg
2008-07-08 10:42 ` Johannes Berg
2008-07-05 23:47 ` [RFT 2/4] mac80211: revamp virtual interface handling Johannes Berg
2008-07-05 23:47 ` Johannes Berg [this message]
2008-07-05 23:47 ` [RFT 4/4] mac80211: revamp beacon configuration Johannes Berg
2008-07-08 11:53 ` [RFT 0/4] mac80211 improvements Ivo van Doorn
2008-07-08 11:51 ` Johannes Berg
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=20080705235014.191243000@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).