From: Johannes Berg <johannes@sipsolutions.net>
To: John Linville <linville@tuxdriver.com>
Cc: Michael Wu <flamingice@sourmilk.net>,
linux-wireless@vger.kernel.org, Jouni Malinen <j@w1.fi>
Subject: [PATCH 04/21] mac80211: validate VLAN interfaces better
Date: Thu, 06 Sep 2007 01:42:13 +0200 [thread overview]
Message-ID: <20070905234623.197117000@sipsolutions.net> (raw)
In-Reply-To: 20070905234209.108005000@sipsolutions.net
This patch changes mac80211 to verify that VLAN interfaces
are valid and not bother drivers about them any more.
VLAN interfaces are now only valid when an AP interface
is up with the same MAC address, and are automatically
turned off when the AP interface is set down.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Jouni Malinen <j@w1.fi>
---
Changes since v1:
* tested manually via nl80211
* fixed bug: typo in the list iteration leading to oopses
* fixed bug: open_count must be decremented after removing vlans
include/net/mac80211.h | 17 ++++++------
net/mac80211/debugfs_netdev.c | 5 ---
net/mac80211/ieee80211.c | 54 +++++++++++++++++++++++++++++++++++------
net/mac80211/ieee80211_cfg.c | 3 ++
net/mac80211/ieee80211_i.h | 6 +++-
net/mac80211/ieee80211_iface.c | 5 +++
6 files changed, 68 insertions(+), 22 deletions(-)
--- wireless-dev.orig/include/net/mac80211.h 2007-09-06 01:35:12.344453431 +0200
+++ wireless-dev/include/net/mac80211.h 2007-09-06 01:35:13.764453431 +0200
@@ -346,16 +346,17 @@ struct ieee80211_conf {
* @IEEE80211_IF_TYPE_IBSS: interface in IBSS (ad-hoc) mode.
* @IEEE80211_IF_TYPE_MNTR: interface in monitor (rfmon) mode.
* @IEEE80211_IF_TYPE_WDS: interface in WDS mode.
- * @IEEE80211_IF_TYPE_VLAN: not used.
+ * @IEEE80211_IF_TYPE_VLAN: VLAN interface bound to an AP, drivers
+ * will never see this type.
*/
enum ieee80211_if_types {
- IEEE80211_IF_TYPE_AP = 0x00000000,
- IEEE80211_IF_TYPE_MGMT = 0x00000001,
- IEEE80211_IF_TYPE_STA = 0x00000002,
- IEEE80211_IF_TYPE_IBSS = 0x00000003,
- IEEE80211_IF_TYPE_MNTR = 0x00000004,
- IEEE80211_IF_TYPE_WDS = 0x5A580211,
- IEEE80211_IF_TYPE_VLAN = 0x00080211,
+ IEEE80211_IF_TYPE_AP,
+ IEEE80211_IF_TYPE_MGMT,
+ IEEE80211_IF_TYPE_STA,
+ IEEE80211_IF_TYPE_IBSS,
+ IEEE80211_IF_TYPE_MNTR,
+ IEEE80211_IF_TYPE_WDS,
+ IEEE80211_IF_TYPE_VLAN,
};
/**
--- wireless-dev.orig/net/mac80211/ieee80211_cfg.c 2007-09-06 01:34:58.704453431 +0200
+++ wireless-dev/net/mac80211/ieee80211_cfg.c 2007-09-06 01:35:13.764453431 +0200
@@ -34,6 +34,9 @@ static int ieee80211_add_iface(struct wi
case NL80211_IFTYPE_AP:
itype = IEEE80211_IF_TYPE_AP;
break;
+ case NL80211_IFTYPE_AP_VLAN:
+ itype = IEEE80211_IF_TYPE_VLAN;
+ break;
case NL80211_IFTYPE_WDS:
itype = IEEE80211_IF_TYPE_WDS;
break;
--- wireless-dev.orig/net/mac80211/ieee80211.c 2007-09-06 01:35:12.364453431 +0200
+++ wireless-dev/net/mac80211/ieee80211.c 2007-09-06 01:35:13.774453431 +0200
@@ -429,22 +429,43 @@ static int ieee80211_open(struct net_dev
int res;
sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+
read_lock(&local->sub_if_lock);
list_for_each_entry(nsdata, &local->sub_if_list, list) {
struct net_device *ndev = nsdata->dev;
if (ndev != dev && ndev != local->mdev && netif_running(ndev) &&
- compare_ether_addr(dev->dev_addr, ndev->dev_addr) == 0 &&
- !identical_mac_addr_allowed(sdata->type, nsdata->type)) {
- read_unlock(&local->sub_if_lock);
- return -ENOTUNIQ;
+ compare_ether_addr(dev->dev_addr, ndev->dev_addr) == 0) {
+ /*
+ * check whether it may have the same address
+ */
+ if (!identical_mac_addr_allowed(sdata->type,
+ nsdata->type)) {
+ read_unlock(&local->sub_if_lock);
+ return -ENOTUNIQ;
+ }
+
+ /*
+ * can only add VLANs to enabled APs
+ */
+ if (sdata->type == IEEE80211_IF_TYPE_VLAN &&
+ nsdata->type == IEEE80211_IF_TYPE_AP &&
+ netif_running(nsdata->dev))
+ sdata->u.vlan.ap = nsdata;
}
}
read_unlock(&local->sub_if_lock);
- if (sdata->type == IEEE80211_IF_TYPE_WDS &&
- is_zero_ether_addr(sdata->u.wds.remote_addr))
- return -ENOLINK;
+ switch (sdata->type) {
+ case IEEE80211_IF_TYPE_WDS:
+ if (is_zero_ether_addr(sdata->u.wds.remote_addr))
+ return -ENOLINK;
+ break;
+ case IEEE80211_IF_TYPE_VLAN:
+ if (!sdata->u.vlan.ap)
+ return -ENOLINK;
+ break;
+ }
if (local->open_count == 0) {
res = 0;
@@ -455,6 +476,10 @@ static int ieee80211_open(struct net_dev
}
switch (sdata->type) {
+ case IEEE80211_IF_TYPE_VLAN:
+ list_add(&sdata->u.vlan.list, &sdata->u.vlan.ap->u.ap.vlans);
+ /* no need to tell driver */
+ break;
case IEEE80211_IF_TYPE_MNTR:
/* must be before the call to ieee80211_configure_filter */
local->monitors++;
@@ -518,9 +543,24 @@ static int ieee80211_stop(struct net_dev
netif_stop_queue(dev);
+ /* down all dependent devices, that is VLANs */
+ if (sdata->type == IEEE80211_IF_TYPE_AP) {
+ struct ieee80211_sub_if_data *vlan, *tmp;
+
+ list_for_each_entry_safe(vlan, tmp, &sdata->u.ap.vlans,
+ u.vlan.list)
+ dev_close(vlan->dev);
+ WARN_ON(!list_empty(&sdata->u.ap.vlans));
+ }
+
local->open_count--;
switch (sdata->type) {
+ case IEEE80211_IF_TYPE_VLAN:
+ list_del(&sdata->u.vlan.list);
+ sdata->u.vlan.ap = NULL;
+ /* no need to tell driver */
+ break;
case IEEE80211_IF_TYPE_MNTR:
local->monitors--;
if (local->monitors == 0) {
--- wireless-dev.orig/net/mac80211/ieee80211_i.h 2007-09-06 01:35:12.364453431 +0200
+++ wireless-dev/net/mac80211/ieee80211_i.h 2007-09-06 01:35:13.774453431 +0200
@@ -215,6 +215,8 @@ struct ieee80211_if_ap {
u8 *beacon_head, *beacon_tail;
int beacon_head_len, beacon_tail_len;
+ struct list_head vlans;
+
u8 ssid[IEEE80211_MAX_SSID_LEN];
size_t ssid_len;
u8 *generic_elem;
@@ -238,7 +240,8 @@ struct ieee80211_if_wds {
};
struct ieee80211_if_vlan {
- u8 id;
+ struct ieee80211_sub_if_data *ap;
+ struct list_head list;
};
/* flags used in struct ieee80211_if_sta.flags */
@@ -450,7 +453,6 @@ struct ieee80211_sub_if_data {
struct dentry *drop_unencrypted;
struct dentry *eapol;
struct dentry *ieee8021_x;
- struct dentry *vlan_id;
} vlan;
struct {
struct dentry *mode;
--- wireless-dev.orig/net/mac80211/ieee80211_iface.c 2007-09-06 01:34:58.794453431 +0200
+++ wireless-dev/net/mac80211/ieee80211_iface.c 2007-09-06 01:35:13.774453431 +0200
@@ -164,6 +164,7 @@ void ieee80211_if_set_type(struct net_de
sdata->bss = NULL;
break;
case IEEE80211_IF_TYPE_VLAN:
+ sdata->u.vlan.ap = NULL;
break;
case IEEE80211_IF_TYPE_AP:
sdata->u.ap.dtim_period = 2;
@@ -171,6 +172,7 @@ void ieee80211_if_set_type(struct net_de
sdata->u.ap.max_ratectrl_rateidx = -1;
skb_queue_head_init(&sdata->u.ap.ps_bc_buf);
sdata->bss = &sdata->u.ap;
+ INIT_LIST_HEAD(&sdata->u.ap.vlans);
break;
case IEEE80211_IF_TYPE_STA:
case IEEE80211_IF_TYPE_IBSS: {
@@ -300,6 +302,9 @@ void ieee80211_if_reinit(struct net_devi
case IEEE80211_IF_TYPE_MNTR:
dev->type = ARPHRD_ETHER;
break;
+ case IEEE80211_IF_TYPE_VLAN:
+ sdata->u.vlan.ap = NULL;
+ break;
}
/* remove all STAs that are bound to this virtual interface */
--- wireless-dev.orig/net/mac80211/debugfs_netdev.c 2007-09-06 01:35:12.374453431 +0200
+++ wireless-dev/net/mac80211/debugfs_netdev.c 2007-09-06 01:35:13.774453431 +0200
@@ -422,9 +422,6 @@ __IEEE80211_IF_FILE(beacon_tail_len);
/* WDS attributes */
IEEE80211_IF_FILE(peer, u.wds.remote_addr, MAC);
-/* VLAN attributes */
-IEEE80211_IF_FILE(vlan_id, u.vlan.id, DEC);
-
#define DEBUGFS_ADD(name, type)\
sdata->debugfs.type.name = debugfs_create_file(#name, 0444,\
sdata->debugfsdir, sdata, &name##_ops);
@@ -523,7 +520,6 @@ static void add_vlan_files(struct ieee80
DEBUGFS_ADD(drop_unencrypted, vlan);
DEBUGFS_ADD(eapol, vlan);
DEBUGFS_ADD(ieee8021_x, vlan);
- DEBUGFS_ADD(vlan_id, vlan);
}
static void add_monitor_files(struct ieee80211_sub_if_data *sdata)
@@ -651,7 +647,6 @@ static void del_vlan_files(struct ieee80
DEBUGFS_DEL(drop_unencrypted, vlan);
DEBUGFS_DEL(eapol, vlan);
DEBUGFS_DEL(ieee8021_x, vlan);
- DEBUGFS_DEL(vlan_id, vlan);
}
static void del_monitor_files(struct ieee80211_sub_if_data *sdata)
--
next prev parent reply other threads:[~2007-09-06 13:46 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-05 23:42 [PATCH 00/21] more mac80211 updates Johannes Berg
2007-09-05 23:42 ` [PATCH 01/21] mac80211: get STA after tx radiotap snipped Johannes Berg
2007-09-05 23:42 ` [PATCH 02/21] mac80211: allow drivers to indicate failed FCS/PLCP checksum Johannes Berg
2007-09-05 23:42 ` [PATCH 03/21] mac80211: revamp interface and filter configuration Johannes Berg
2007-09-06 14:28 ` Michael Buesch
2007-09-06 14:46 ` Johannes Berg
2007-09-06 17:05 ` Ivo van Doorn
2007-09-07 13:23 ` Johannes Berg
2007-09-07 17:56 ` Ivo van Doorn
2007-09-14 3:50 ` Michael Wu
2007-09-14 12:06 ` Johannes Berg
2007-09-05 23:42 ` Johannes Berg [this message]
2007-09-05 23:42 ` [PATCH 05/21] mac80211: remove key threshold stuff Johannes Berg
2007-09-05 23:42 ` [PATCH 06/21] mac80211: remove IEEE80211_CONF_SSID_HIDDEN and PRISM2_PARAM_BROADCAST_SSID Johannes Berg
2007-09-05 23:42 ` [PATCH 07/21] mac80211: renumber and document the hardware flags Johannes Berg
2007-09-05 23:42 ` [PATCH 08/21] mac80211: document a lot more Johannes Berg
2007-09-05 23:42 ` [PATCH 09/21] wireless networking: move frame inline functions to generic header Johannes Berg
2007-09-05 23:42 ` [PATCH 10/21] mac80211: yet more documentation Johannes Berg
2007-09-05 23:42 ` [PATCH 11/21] mac80211: fix warnings introduced by the doc patches Johannes Berg
2007-09-05 23:42 ` [PATCH 12/21] mac80211: remove tx info sw_retry_attempt member Johannes Berg
2007-09-05 23:42 ` [PATCH 13/21] mac80211: print out wiphy name instead of master device Johannes Berg
2007-09-05 23:42 ` [PATCH 14/21] mac80211 maintainership Johannes Berg
2007-09-05 23:42 ` [PATCH 15/21] mac80211: rename ieee80211_cfg.c to cfg.c Johannes Berg
2007-09-05 23:42 ` [PATCH 16/21] mac80211: consolidate decryption Johannes Berg
2007-09-05 23:42 ` [PATCH 17/21] mac80211: consolidate encryption Johannes Berg
2007-09-05 23:42 ` [PATCH 18/21] mac80211: remove ieee80211_wep_get_keyidx Johannes Berg
2007-09-05 23:42 ` [PATCH 19/21] mac80211: remove crypto algorithm typedef Johannes Berg
2007-09-05 23:42 ` [PATCH 20/21] mac80211: kill IE parse typedef Johannes Berg
2007-09-05 23:42 ` [PATCH 21/21] mac80211: kill vlan_id 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=20070905234623.197117000@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=flamingice@sourmilk.net \
--cc=j@w1.fi \
--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;
as well as URLs for NNTP newsgroup(s).