From: Johannes Berg <johannes@sipsolutions.net>
To: John Linville <linville@tuxdriver.com>
Cc: linux-wireless <linux-wireless@vger.kernel.org>
Subject: [PATCH] cfg80211: show interface type
Date: Tue, 16 Sep 2008 14:55:09 +0200 [thread overview]
Message-ID: <1221569709.8916.36.camel@johannes.berg> (raw)
This patch makes cfg80211 show the interface in the nl80211
information about a specific interface. API users are required
to keep the type updated (everything else is fairly complicated)
but you will get a warning if you fail to keep it updated.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
NB: This depends on "mac80211: make master interface not wireless"!
include/net/cfg80211.h | 6 ++++--
include/net/wireless.h | 2 ++
net/mac80211/iface.c | 1 +
net/wireless/core.c | 2 ++
net/wireless/nl80211.c | 6 +++++-
5 files changed, 14 insertions(+), 3 deletions(-)
--- everything.orig/include/net/wireless.h 2008-09-16 14:12:43.000000000 +0200
+++ everything/include/net/wireless.h 2008-09-16 14:14:30.000000000 +0200
@@ -223,9 +223,11 @@ struct wiphy {
* the netdev.)
*
* @wiphy: pointer to hardware description
+ * @iftype: interface type
*/
struct wireless_dev {
struct wiphy *wiphy;
+ enum nl80211_iftype iftype;
/* private to the generic wireless code */
struct list_head list;
--- everything.orig/net/wireless/core.c 2008-09-16 14:12:40.000000000 +0200
+++ everything/net/wireless/core.c 2008-09-16 14:14:30.000000000 +0200
@@ -384,6 +384,8 @@ static int cfg80211_netdev_notifier_call
rdev = wiphy_to_dev(dev->ieee80211_ptr->wiphy);
+ WARN_ON(dev->ieee80211_ptr->iftype == NL80211_IFTYPE_UNSPECIFIED);
+
switch (state) {
case NETDEV_REGISTER:
mutex_lock(&rdev->devlist_mtx);
--- everything.orig/include/net/cfg80211.h 2008-09-16 14:11:35.000000000 +0200
+++ everything/include/net/cfg80211.h 2008-09-16 14:14:30.000000000 +0200
@@ -363,11 +363,13 @@ struct wiphy;
* 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
+ * @add_virtual_intf: create a new virtual interface with the given name,
+ * must set the struct wireless_dev's iftype.
*
* @del_virtual_intf: remove the virtual interface determined by ifindex.
*
- * @change_virtual_intf: change type of virtual interface
+ * @change_virtual_intf: change type/configuration of virtual interface,
+ * keep the struct wireless_dev's iftype updated.
*
* @add_key: add a key with the given parameters. @mac_addr will be %NULL
* when adding a group key.
--- everything.orig/net/mac80211/iface.c 2008-09-16 14:11:36.000000000 +0200
+++ everything/net/mac80211/iface.c 2008-09-16 14:14:30.000000000 +0200
@@ -624,6 +624,7 @@ static void ieee80211_setup_sdata(struct
/* and set some type-dependent values */
sdata->vif.type = type;
sdata->dev->hard_start_xmit = ieee80211_subif_start_xmit;
+ sdata->wdev.iftype = type;
/* only monitor differs */
sdata->dev->type = ARPHRD_ETHER;
--- everything.orig/net/wireless/nl80211.c 2008-09-16 14:11:35.000000000 +0200
+++ everything/net/wireless/nl80211.c 2008-09-16 14:23:45.000000000 +0200
@@ -299,7 +299,7 @@ static int nl80211_send_iface(struct sk_
NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, dev->ifindex);
NLA_PUT_STRING(msg, NL80211_ATTR_IFNAME, dev->name);
- /* TODO: interface type */
+ NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, dev->ieee80211_ptr->iftype);
return genlmsg_end(msg, hdr);
nla_put_failure:
@@ -453,6 +453,10 @@ static int nl80211_set_interface(struct
&flags);
err = drv->ops->change_virtual_intf(&drv->wiphy, ifindex,
type, err ? NULL : &flags, ¶ms);
+
+ dev = __dev_get_by_index(&init_net, ifindex);
+ WARN_ON(!dev || (!err && dev->ieee80211_ptr->iftype != type));
+
rtnl_unlock();
unlock:
reply other threads:[~2008-09-16 12:55 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=1221569709.8916.36.camel@johannes.berg \
--to=johannes@sipsolutions.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