Skip to contentSkip to conversation

d80211 patches

PATCH In review Jiri Benc 5 participants 31 messages Apr 21, 2006 – Apr 28, 2006

Subsystems (3)
lore
Share & tools
lore

Jiri Benc

author
#0 lore raw

cover d80211 patches

Hi John,

please pull to your wireless-dev tree from

git://git.kernel.org/pub/scm/linux/kernel/git/jbenc/dscape.git up

to obtain following patches. They were all posted to netdev previously and are all discussed with Jouni (except 7th patch, but that is quite simple and shouldn't cause any harm).

Also, the new rule of required kerneldoc documentation is hopefully fulfilled - the only exception is ieee80211_hw structure, which is well-commented but with comments inside. I think it will be best to convert comments in ieee80211_hw by a separate patch.

Please note that these changes break d80211 drivers.

Jiri Benc:
d80211: symlinks to wiphy in sysfs
d80211: allow WDS remote to by set by WE
d80211: add IBSS and monitor interface types
d80211: non-shared interface types
d80211: remove local->bssid variable
d80211: rename IEEE80211_SUB_IF_TYPE_ constants
d80211: ask driver for allowed iface combinations
d80211: remove obsolete stuff
d80211: fix interface configuration
d80211: rename adm_status to radio_enabled
d80211: interface types changeable by SIOCSIWMODE
d80211: master interface auto up/down
d80211: set_multicast_list
d80211: fix handling of received frames
d80211: fix monitor interfaces
d80211: fix AP interfaces

Jouni Malinen:
d80211: Replace MODULE_PARM with module_param

 include/net/d80211.h         |  179 ++++-
 net/d80211/Makefile          |    1 
 net/d80211/hostapd_ioctl.h   |    3 
 net/d80211/ieee80211.c       | 1473 +++++++++++++++----------------------------
 net/d80211/ieee80211_dev.c   |   16 
 net/d80211/ieee80211_i.h     |   80 +-
 net/d80211/ieee80211_iface.c |  299 ++++++++
 net/d80211/ieee80211_ioctl.c |  468 ++++++-------
 net/d80211/ieee80211_proc.c  |   34 
 net/d80211/ieee80211_sta.c   |  109 +--
 net/d80211/ieee80211_sysfs.c |   95 +-
 net/d80211/wme.c             |    3 
 12 files changed, 1376 insertions(+), 1384 deletions(-)

Jiri Benc
SUSE Labs

author
#1 lore raw

PATCH 1/17 d80211: Replace MODULE_PARM with module_param

From: Jouni Malinen <[email protected]>

MODULE_PARM macro was removed and this broke net/d80211 build. Fix this by using module_param instead of MODULE_PARM.

---

 net/d80211/ieee80211_ioctl.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

d0d54060410447c5eb354886ac0ae9cff73a4b2c

net/d80211/ieee80211_ioctl.c +2 -2
index 42a7abe..987f761 100644
@@ -30,7 +30,7 @@ #include "aes_ccm.h"
 
 
 static int ieee80211_regdom = 0x10; /* FCC */
-MODULE_PARM(ieee80211_regdom, "i");
+module_param(ieee80211_regdom, int, 0444);
 MODULE_PARM_DESC(ieee80211_regdom, "IEEE 802.11 regulatory domain; 64=MKK");
 
 /*
@@ -40,7 +40,7 @@ MODULE_PARM_DESC(ieee80211_regdom, "IEEE
  * module.
  */
 static int ieee80211_japan_5ghz /* = 0 */;
-MODULE_PARM(ieee80211_japan_5ghz, "i");
+module_param(ieee80211_japan_5ghz, int, 0444);
 MODULE_PARM_DESC(ieee80211_japan_5ghz, "Vendor-updated firmware for 5 GHz");
 
 
Signature · 1 line
1.3.0
author
#2 lore raw

PATCH 2/17 d80211: symlinks to wiphy in sysfs

In reply to Jiri Benc

This patch adds symlinks under /sys/net/*/wiphy pointing to /sys/class/ieee80211/phyX.

This allows new interfaces to be added by writing a new name to e.g. /sys/net/wlan0/wiphy/add_iface.

---

 net/d80211/ieee80211_dev.c   |   16 +++++++++++++
 net/d80211/ieee80211_i.h     |    1 +
 net/d80211/ieee80211_sysfs.c |   51 +++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 67 insertions(+), 1 deletions(-)

8ac63bdfba39115673abc492d7eb867c364b0fc4

net/d80211/ieee80211_dev.c +16 -0
index 4302506..6278cfa 100644
@@ -83,3 +83,19 @@ struct ieee80211_local *ieee80211_dev_fi
 	spin_unlock(&dev_list_lock);
 	return dev_item ? dev_item->local : NULL;
 }
+
+int ieee80211_dev_find_index(struct ieee80211_local *local)
+{
+	struct ieee80211_dev_list *dev_item;
+	int index = -1;
+
+	spin_lock(&dev_list_lock);
+	list_for_each_entry(dev_item, &dev_list, list) {
+		if (dev_item->local == local) {
+			index = dev_item->dev_index;
+			break;
+		}
+	}
+	spin_unlock(&dev_list_lock);
+	return index;
+}
net/d80211/ieee80211_i.h +1 -0
index 0c1eeac..c217104 100644
@@ -587,6 +587,7 @@ int ieee80211_sta_disassociate(struct ne
 int ieee80211_dev_alloc_index(struct ieee80211_local *local);
 void ieee80211_dev_free_index(struct ieee80211_local *local);
 struct ieee80211_local *ieee80211_dev_find(int index);
+int ieee80211_dev_find_index(struct ieee80211_local *local);
 
 /* ieee80211_sysfs.c */
 int ieee80211_register_sysfs(struct ieee80211_local *local);
net/d80211/ieee80211_sysfs.c +50 -1

68 lines not on this page · raw message

Signature · 1 line
1.3.0
author
#3 lore raw

PATCH 3/17 d80211: allow WDS remote to by set by WE

In reply to Jiri Benc

Setting of address of WDS remote peer wasn't possible by a WE call. Remote WDS peer can be understood as a remote AP and SIOCSIWAP/SIOCGIWAP are unused in WDS mode, so let's use them.

---

 net/d80211/ieee80211.c       |   25 +++++--------------------
 net/d80211/ieee80211_i.h     |    3 +--
 net/d80211/ieee80211_ioctl.c |   27 +++++++++++++++++++++++----
 3 files changed, 29 insertions(+), 26 deletions(-)

7ced2ee797d78b7b568be06a02ff3c1c06b25b9d

net/d80211/ieee80211.c +5 -20
index d0bc0bc..f80dffa 100644
@@ -3944,25 +3944,11 @@ #endif /* CONFIG_D80211_VERBOSE_DEBUG */
 }
 
 
-int ieee80211_if_update_wds(struct net_device *dev, char *name,
-			    struct ieee80211_if_wds *wds, int locked)
+int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr)
 {
-	struct net_device *wds_dev = NULL;
 	struct ieee80211_local *local = dev->priv;
-	struct ieee80211_sub_if_data *sdata = NULL;
+	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 	struct sta_info *sta;
-	struct list_head *ptr;
-
-	list_for_each(ptr, &local->sub_if_list) {
-		sdata = list_entry(ptr, struct ieee80211_sub_if_data, list);
-		if (strcmp(name, sdata->dev->name) == 0) {
-			wds_dev = sdata->dev;
-			break;
-		}
-	}
-
-	if (wds_dev == NULL || sdata->type != IEEE80211_SUB_IF_TYPE_WDS)
-		return -ENODEV;
 
 	/* Remove STA entry for the old peer */
 	sta = sta_info_get(local, sdata->u.wds.remote_addr);
@@ -3971,13 +3957,12 @@ int ieee80211_if_update_wds(struct net_d
 		sta_info_free(local, sta, 0);
 	} else {
 		printk(KERN_DEBUG "%s: could not find STA entry for WDS link "
-		       "%s peer " MACSTR "\n",
-		       dev->name, wds_dev->name,
-		       MAC2STR(sdata->u.wds.remote_addr));
+		       "peer " MACSTR "\n",
+		       dev->name, MAC2STR(sdata->u.wds.remote_addr));
 	}
 
 	/* Update WDS link data */
-        memcpy(&sdata->u.wds, wds, sizeof(struct ieee80211_if_wds));
+	memcpy(&sdata->u.wds.remote_addr, remote_addr, ETH_ALEN);
 
 	return 0;
 }
net/d80211/ieee80211_i.h +1 -2
index c217104..ba72466 100644
@@ -517,8 +517,7 @@ int ieee80211_if_remove_wds(struct net_d
 int ieee80211_if_remove_vlan(struct net_device *dev, const char *name, int locked);
 int ieee80211_if_remove_ap(struct net_device *dev, const char *name, int locked);
 int ieee80211_if_flush(struct net_device *dev, int locked);
-int ieee80211_if_update_wds(struct net_device *dev, char *name,
-			    struct ieee80211_if_wds *wds, int locked);
+int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr);
 
 /* ieee80211_ioctl.c */
 int ieee80211_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
net/d80211/ieee80211_ioctl.c +23 -4
index 987f761..71b72fe 100644
@@ -997,17 +997,27 @@ static int ieee80211_ioctl_update_if(str
         int left = param_len - ((u8 *) pos - (u8 *) param);
 
 	if (param->u.if_info.type == HOSTAP_IF_WDS) {
-		struct ieee80211_if_wds iwds;
 		struct hostapd_if_wds *wds =
 			(struct hostapd_if_wds *) param->u.if_info.data;
+		struct ieee80211_local *local = dev->priv;
+		struct net_device *wds_dev = NULL;
+		struct ieee80211_sub_if_data *sdata;
 
 		if (left < sizeof(struct ieee80211_if_wds))
 			return -EPROTO;
 
-		memcpy(iwds.remote_addr, wds->remote_addr, ETH_ALEN);
+		list_for_each_entry(sdata, &local->sub_if_list, list) {
+			if (strcmp(param->u.if_info.name,
+				   sdata->dev->name) == 0) {
+				wds_dev = sdata->dev;
+				break;
+			}
+		}
 
-		return ieee80211_if_update_wds(dev, param->u.if_info.name,
-					       &iwds, 1);
+		if (wds_dev == NULL || sdata->type != IEEE80211_SUB_IF_TYPE_WDS)
+			return -ENODEV;
+
+		return ieee80211_if_update_wds(wds_dev, wds->remote_addr);
 	} else {
 		return -EOPNOTSUPP;
 	}
@@ -1842,6 +1852,11 @@ static int ieee80211_ioctl_siwap(struct 
 			       "the low-level driver\n", dev->name);
 		}
 		return ieee80211_sta_set_bssid(dev, (u8 *) &ap_addr->sa_data);
+	} else if (sdata->type == IEEE80211_SUB_IF_TYPE_WDS) {
+		if (memcmp(sdata->u.wds.remote_addr, (u8 *) &ap_addr->sa_data,
+			   ETH_ALEN) == 0)
+			return 0;
+		return ieee80211_if_update_wds(dev, (u8 *) &ap_addr->sa_data);
 	}
 
 	return -EOPNOTSUPP;
@@ -1859,6 +1874,10 @@ static int ieee80211_ioctl_giwap(struct 
 		ap_addr->sa_family = ARPHRD_ETHER;
 		memcpy(&ap_addr->sa_data, sdata->u.sta.bssid, ETH_ALEN);
 		return 0;
+	} else if (sdata->type == IEEE80211_SUB_IF_TYPE_WDS) {
+		ap_addr->sa_family = ARPHRD_ETHER;
+		memcpy(&ap_addr->sa_data, sdata->u.wds.remote_addr, ETH_ALEN);
+		return 0;
 	}
 
 	return -EOPNOTSUPP;
Signature · 1 line
1.3.0
author
#4 lore raw

PATCH 4/17 d80211: add IBSS and monitor interface types

In reply to Jiri Benc

Add constants for IBSS and monitor interface types. These constants are used in subsequent patches.

---

 net/d80211/ieee80211_i.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

b5f3ee77e4da0c6cbe98000f1380d3df92a949d4

net/d80211/ieee80211_i.h +2 -0
index ba72466..848afb7 100644
@@ -259,6 +259,8 @@ #define IEEE80211_AUTH_ALG_LEAP BIT(2)
 #define IEEE80211_SUB_IF_TYPE_AP   0x00000000
 #define IEEE80211_SUB_IF_TYPE_MGMT 0x00000001
 #define IEEE80211_SUB_IF_TYPE_STA  0x00000002
+#define IEEE80211_SUB_IF_TYPE_IBSS 0x00000003
+#define IEEE80211_SUB_IF_TYPE_MNTR 0x00000004
 #define IEEE80211_SUB_IF_TYPE_WDS  0x5A580211
 #define IEEE80211_SUB_IF_TYPE_VLAN 0x00080211
 
Signature · 1 line
1.3.0
author
#5 lore raw

PATCH 5/17 d80211: non-shared interface types

In reply to Jiri Benc

This patch removes "iwmode" variable (local->conf.mode) shared by all interfaces. Instead, every interface has its own type (STA/IBSS/AP/WDS).

Please note, that
- Actual SIOCSIWMODE ioctl is disabled by this patch and is implemented by one of subsequent patches.
- There is no way to ask the driver if given combination of interfaces is possible. Again, it is implemented by one of subsequent patches.

---

 include/net/d80211.h         |   18 ------
 net/d80211/ieee80211.c       |  120 +++++++++++++++++++-----------------------
 net/d80211/ieee80211_ioctl.c |  103 +++++++++++++++++++++++-------------
 net/d80211/ieee80211_proc.c  |   12 +++-
 net/d80211/ieee80211_sta.c   |   43 ++++++++-------
 5 files changed, 150 insertions(+), 146 deletions(-)

16aa733f49d78c481269c79ad8de190b40665da2

include/net/d80211.h +0 -18
index e4c5ed2..75e8e24 100644
@@ -242,8 +242,6 @@ struct ieee80211_conf {
 	int freq;			/* MHz */
 	int channel_val;		/* hw specific value for the channel */
 
-	int mode;			/* IW_MODE_ */
-
 	int phymode;			/* MODE_IEEE80211A, .. */
         unsigned int regulatory_domain;
         int adm_status;
@@ -359,22 +357,6 @@ struct ieee80211_scan_conf {
 
 };
 
-#ifndef IW_MODE_ADHOC
-#define IW_MODE_ADHOC 1
-#endif
-
-#ifndef IW_MODE_INFRA
-#define IW_MODE_INFRA 2
-#endif
-
-#ifndef IW_MODE_MASTER
-#define IW_MODE_MASTER 3
-#endif
-
-#ifndef IW_MODE_MONITOR
-#define IW_MODE_MONITOR 6
-#endif
-
 #define IEEE80211_SEQ_COUNTER_RX	0
 #define IEEE80211_SEQ_COUNTER_TX	1
 
net/d80211/ieee80211.c +53 -67

271 lines not on this page · raw message

net/d80211/ieee80211_ioctl.c +65 -38

245 lines not on this page · raw message

net/d80211/ieee80211_proc.c +9 -3
index 5d77c2a..3709494 100644
@@ -110,10 +110,13 @@ static char * ieee80211_proc_sub_if_ap(c
 }
 
 
-static char * ieee80211_proc_sub_if_sta(char *p,
+static char * ieee80211_proc_sub_if_sta(char *p, int ibss,
 					struct ieee80211_if_sta *ifsta)
 {
-	p += sprintf(p, "type=sta\n");
+	if (ibss)
+		p += sprintf(p, "type=ibss\n");
+	else
+		p += sprintf(p, "type=sta\n");
 	p += sprintf(p,
 		     "state=%d\n"
 		     "bssid=" MACSTR "\n"
@@ -176,7 +179,10 @@ static char * ieee80211_proc_sub_if(char
 		p += sprintf(p, "vlan.id=%d\n", sdata->u.vlan.id);
 		break;
 	case IEEE80211_SUB_IF_TYPE_STA:
-		p = ieee80211_proc_sub_if_sta(p, &sdata->u.sta);
+		p = ieee80211_proc_sub_if_sta(p, 0, &sdata->u.sta);
+		break;
+	case IEEE80211_SUB_IF_TYPE_IBSS:
+		p = ieee80211_proc_sub_if_sta(p, 1, &sdata->u.sta);
 		break;
 	}
 	p += sprintf(p, "channel_use=%d\n", sdata->channel_use);
net/d80211/ieee80211_sta.c +23 -20

155 lines not on this page · raw message

Signature · 1 line
1.3.0
author
#6 lore raw

PATCH 6/17 d80211: remove local->bssid variable

In reply to Jiri Benc

BSSID shouldn't be common for all interfaces.

---

 net/d80211/ieee80211.c     |    4 ++--
 net/d80211/ieee80211_i.h   |    1 -
 net/d80211/ieee80211_sta.c |    8 ++------
 3 files changed, 4 insertions(+), 9 deletions(-)

78d82ec5d0282693656a09add989460775d56bbd

net/d80211/ieee80211.c +2 -2
index 10c4792..362c231 100644
@@ -2063,7 +2063,7 @@ ieee80211_rx_h_data(struct ieee80211_txr
 		memcpy(src, hdr->addr2, ETH_ALEN);
 
 		if (sdata->type != IEEE80211_SUB_IF_TYPE_IBSS ||
-		    memcmp(hdr->addr3, local->bssid, ETH_ALEN) != 0) {
+		    memcmp(hdr->addr3, sdata->u.sta.bssid, ETH_ALEN) != 0) {
 			if (net_ratelimit()) {
 				printk(KERN_DEBUG "%s: dropped IBSS frame (DA="
 				       MACSTR " SA=" MACSTR " BSSID=" MACSTR
@@ -2803,7 +2803,7 @@ ieee80211_rx_h_sta_process(struct ieee80
 	 * other STAs are using different BSSID. */
 	if (rx->sdata->type == IEEE80211_SUB_IF_TYPE_IBSS) {
 		u8 *bssid = ieee80211_get_bssid(hdr, rx->skb->len);
-		if (memcmp(bssid, rx->local->bssid, ETH_ALEN) == 0)
+		if (memcmp(bssid, rx->sdata->u.sta.bssid, ETH_ALEN) == 0)
 			sta->last_rx = jiffies;
 	} else
 	if (!MULTICAST_ADDR(hdr->addr1) ||
net/d80211/ieee80211_i.h +0 -1
index 848afb7..8fe1dd1 100644
@@ -433,7 +433,6 @@ #endif /* CONFIG_HOSTAPD_WPA_TESTING */
         u32 stat_time;
         struct timer_list stat_timer;
 
-	u8 bssid[ETH_ALEN]; /* BSSID for STA modes (Adhoc/Managed) */
         struct timer_list rate_limit_timer;
         u32 rate_limit;
         u32 rate_limit_burst;
net/d80211/ieee80211_sta.c +2 -6
index 9972b98..5df6734 100644
@@ -1365,7 +1365,7 @@ #endif
 		((u64) pos[1] << 8) | ((u64) pos[0]);
 
 	if (sdata->type == IEEE80211_SUB_IF_TYPE_IBSS && beacon &&
-	    memcmp(mgmt->bssid, local->bssid, ETH_ALEN) == 0) {
+	    memcmp(mgmt->bssid, sdata->u.sta.bssid, ETH_ALEN) == 0) {
 #ifdef IEEE80211_IBSS_DEBUG
 		static unsigned long last_tsf_debug = 0;
 		u64 tsf;
@@ -1389,7 +1389,7 @@ #endif /* IEEE80211_IBSS_DEBUG */
 		invalid = 1;
 
 	if (sdata->type == IEEE80211_SUB_IF_TYPE_IBSS && elems.supp_rates &&
-	    memcmp(mgmt->bssid, local->bssid, ETH_ALEN) == 0 &&
+	    memcmp(mgmt->bssid, sdata->u.sta.bssid, ETH_ALEN) == 0 &&
 	    (sta = sta_info_get(local, mgmt->sa))) {
 		struct ieee80211_rate *rates;
 		size_t num_rates;
@@ -1990,7 +1990,6 @@ static int ieee80211_sta_join_ibss(struc
 		local->hw->reset_tsf(local->mdev);
 	}
 	memcpy(ifsta->bssid, bss->bssid, ETH_ALEN);
-	memcpy(local->bssid, bss->bssid, ETH_ALEN);
 	memcpy(local->conf.client_bssid, bss->bssid, ETH_ALEN);
 
 	local->conf.beacon_int = bss->beacon_int >= 10 ? bss->beacon_int : 10;
@@ -2344,7 +2343,6 @@ int ieee80211_sta_get_ssid(struct net_de
 
 int ieee80211_sta_set_bssid(struct net_device *dev, u8 *bssid)
 {
-	struct ieee80211_local *local = dev->priv;
 	struct ieee80211_sub_if_data *sdata;
 	struct ieee80211_if_sta *ifsta;
 
@@ -2352,8 +2350,6 @@ int ieee80211_sta_set_bssid(struct net_d
 	ifsta = &sdata->u.sta;
 
 	memcpy(ifsta->bssid, bssid, ETH_ALEN);
-	if (sdata->type == IEEE80211_SUB_IF_TYPE_IBSS)
-		memcpy(local->bssid, bssid, ETH_ALEN);
 
 	if (memcmp(bssid, "\x00\x00\x00\x00\x00\x00", ETH_ALEN) == 0)
 		ifsta->bssid_set = 0;
Signature · 1 line
1.3.0
author
#7 lore raw

PATCH 7/17 d80211: rename IEEE80211_SUB_IF_TYPE_ constants

In reply to Jiri Benc

As we're going to expose IEEE80211_SUB_IF_TYPE_* constants to drivers, the prefix IEEE80211_SUB_IF_TYPE_ is no longer appropriate. The constants are going to mean the type of 802.11 interface, not the type of sub-interface structure (which is not visible to drivers at all).

This patch renames them to IEEE80211_IF_TYPE_*.

---

 net/d80211/ieee80211.c       |   98 +++++++++++++++++-------------------
 net/d80211/ieee80211_i.h     |   14 +++--
 net/d80211/ieee80211_ioctl.c |  114 +++++++++++++++++++++---------------------
 net/d80211/ieee80211_proc.c  |   10 ++--
 net/d80211/ieee80211_sta.c   |   40 +++++++--------
 net/d80211/wme.c             |    2 -
 6 files changed, 137 insertions(+), 141 deletions(-)

6369196531f5cb19227491f2497b043272e2ab88

net/d80211/ieee80211.c +47 -51
index 362c231..fae9d64 100644
@@ -326,7 +326,7 @@ ieee80211_tx_h_rate_ctrl(struct ieee8021
 
 	memset(&extra, 0, sizeof(extra));
 	extra.mgmt_data = tx->sdata &&
-		tx->sdata->type == IEEE80211_SUB_IF_TYPE_MGMT;
+		tx->sdata->type == IEEE80211_IF_TYPE_MGMT;
 	extra.ethertype = tx->ethertype;
 	extra.startidx  = 0;
 	extra.endidx    = tx->local->num_curr_rates;
@@ -868,7 +868,7 @@ #endif /* CONFIG_D80211_VERBOSE_DEBUG */
 
 	if (likely(tx->u.tx.unicast)) {
 		if (unlikely(!(sta_flags & WLAN_STA_ASSOC) &&
-			     tx->sdata->type != IEEE80211_SUB_IF_TYPE_IBSS &&
+			     tx->sdata->type != IEEE80211_IF_TYPE_IBSS &&
 			     WLAN_FC_GET_TYPE(tx->fc) == WLAN_FC_TYPE_DATA)) {
 #ifdef CONFIG_D80211_VERBOSE_DEBUG
 			printk(KERN_DEBUG "%s: dropped data frame to not "
@@ -882,7 +882,7 @@ #endif /* CONFIG_D80211_VERBOSE_DEBUG */
 		if (unlikely(WLAN_FC_GET_TYPE(tx->fc) == WLAN_FC_TYPE_DATA &&
 			     tx->local->num_sta == 0 &&
 			     !tx->local->allow_broadcast_always &&
-			     tx->sdata->type != IEEE80211_SUB_IF_TYPE_IBSS)) {
+			     tx->sdata->type != IEEE80211_IF_TYPE_IBSS)) {
 			/*
 			 * No associated STAs - no need to send multicast
 			 * frames.
@@ -925,7 +925,7 @@ static void purge_old_ps_buffers(struct 
 		struct ieee80211_sub_if_data *sdata =
 			list_entry(ptr, struct ieee80211_sub_if_data, list);
 		if (sdata->dev == local->mdev ||
-		    sdata->type != IEEE80211_SUB_IF_TYPE_AP)
+		    sdata->type != IEEE80211_IF_TYPE_AP)
 			continue;
 		ap = &sdata->u.ap;
 		skb = skb_dequeue(&ap->ps_bc_buf);
@@ -963,7 +963,7 @@ ieee80211_tx_h_multicast_ps_buf(struct i
 	/* If any of the associated stations is in power save mode,
 	 * the frame is buffered to be sent after DTIM beacon frame */
 	if (tx->local->hw->host_broadcast_ps_buffering &&
-	    tx->sdata->type != IEEE80211_SUB_IF_TYPE_WDS &&
+	    tx->sdata->type != IEEE80211_IF_TYPE_WDS &&
 	    tx->sdata->bss && atomic_read(&tx->sdata->bss->num_sta_ps) &&
 	    !(tx->fc & WLAN_FC_ORDER)) {
 		if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER)
@@ -1231,7 +1231,7 @@ static int ieee80211_master_start_xmit(s
 	control.queue = pkt_data->queue;
 
 	ret = ieee80211_tx(dev, skb, &control,
-			   control.sdata->type == IEEE80211_SUB_IF_TYPE_MGMT);
+			   control.sdata->type == IEEE80211_IF_TYPE_MGMT);
 
         return ret;
 }
@@ -1283,15 +1283,15 @@ static int ieee80211_subif_start_xmit(st
 	/* TODO: handling for 802.1x authorized/unauthorized port */
 	fc = (WLAN_FC_TYPE_DATA << 2) | (WLAN_FC_STYPE_DATA << 4);
 
-	if (likely(sdata->type == IEEE80211_SUB_IF_TYPE_AP ||
-		   sdata->type == IEEE80211_SUB_IF_TYPE_VLAN)) {
+	if (likely(sdata->type == IEEE80211_IF_TYPE_AP ||
+		   sdata->type == IEEE80211_IF_TYPE_VLAN)) {
 		fc |= WLAN_FC_FROMDS;
 		/* DA BSSID SA */
 		memcpy(hdr.addr1, skb->data, ETH_ALEN);
 		memcpy(hdr.addr2, dev->dev_addr, ETH_ALEN);
 		memcpy(hdr.addr3, skb->data + ETH_ALEN, ETH_ALEN);
                 hdrlen = 24;
-        } else if (sdata->type == IEEE80211_SUB_IF_TYPE_WDS) {
+        } else if (sdata->type == IEEE80211_IF_TYPE_WDS) {
                 fc |= WLAN_FC_FROMDS | WLAN_FC_TODS;
 		/* RA TA DA SA */
                 memcpy(hdr.addr1, sdata->u.wds.remote_addr, ETH_ALEN);
@@ -1299,14 +1299,14 @@ static int ieee80211_subif_start_xmit(st
                 memcpy(hdr.addr3, skb->data, ETH_ALEN);
                 memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN);
                 hdrlen = 30;
-        } else if (sdata->type == IEEE80211_SUB_IF_TYPE_STA) {
+        } else if (sdata->type == IEEE80211_IF_TYPE_STA) {
 		fc |= WLAN_FC_TODS;
 		/* BSSID SA DA */
 		memcpy(hdr.addr1, sdata->u.sta.bssid, ETH_ALEN);
 		memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN);
 		memcpy(hdr.addr3, skb->data, ETH_ALEN);
 		hdrlen = 24;
-	} else if (sdata->type == IEEE80211_SUB_IF_TYPE_IBSS) {
+	} else if (sdata->type == IEEE80211_IF_TYPE_IBSS) {
 		/* DA SA BSSID */
 		memcpy(hdr.addr1, skb->data, ETH_ALEN);
 		memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN);
@@ -1879,7 +1879,7 @@ ieee80211_get_wds_dev(struct ieee80211_l
 	list_for_each(ptr, &local->sub_if_list)	{
 		struct ieee80211_sub_if_data *sdata =
 			list_entry(ptr, struct ieee80211_sub_if_data, list);
-		if (sdata->type == IEEE80211_SUB_IF_TYPE_WDS &&
+		if (sdata->type == IEEE80211_IF_TYPE_WDS &&
 		    memcmp(addr, sdata->u.wds.remote_addr, ETH_ALEN) == 0)
 			return sdata->dev;
 	}
@@ -1943,8 +1943,8 @@ static struct net_device * ieee80211_sta
 	list_for_each(ptr, &local->sub_if_list) {
 		struct ieee80211_sub_if_data *sdata =
 			list_entry(ptr, struct ieee80211_sub_if_data, list);
-		if (sdata->type != IEEE80211_SUB_IF_TYPE_STA &&
-		    sdata->type != IEEE80211_SUB_IF_TYPE_IBSS)
+		if (sdata->type != IEEE80211_IF_TYPE_STA &&
+		    sdata->type != IEEE80211_IF_TYPE_IBSS)
 			continue;
 		if (!multicast &&
 		    memcmp(a1, sdata->dev->dev_addr, ETH_ALEN) != 0)
@@ -1952,7 +1952,7 @@ static struct net_device * ieee80211_sta
 
 		if (memcmp(addr, sdata->u.sta.bssid, ETH_ALEN) == 0 ||
 		    (memcmp(addr, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) == 0 &&
-		     sdata->type == IEEE80211_SUB_IF_TYPE_IBSS)) {
+		     sdata->type == IEEE80211_IF_TYPE_IBSS)) {
 			*sta_multicast = multicast;
 			return sdata->dev;
 		}
@@ -2021,7 +2021,7 @@ ieee80211_rx_h_data(struct ieee80211_txr
 		memcpy(dst, hdr->addr3, ETH_ALEN);
 		memcpy(src, hdr->addr2, ETH_ALEN);
 
-		if (unlikely(sdata->type != IEEE80211_SUB_IF_TYPE_AP ||
+		if (unlikely(sdata->type != IEEE80211_IF_TYPE_AP ||
 			     !ieee80211_own_bssid(local, hdr->addr1))) {
 			printk(KERN_DEBUG "%s: dropped ToDS frame (BSSID="
 			       MACSTR " SA=" MACSTR " DA=" MACSTR ")\n",
@@ -2051,7 +2051,7 @@ ieee80211_rx_h_data(struct ieee80211_txr
 		memcpy(dst, hdr->addr1, ETH_ALEN);
 		memcpy(src, hdr->addr3, ETH_ALEN);
 
-		if (sdata->type != IEEE80211_SUB_IF_TYPE_STA ||
+		if (sdata->type != IEEE80211_IF_TYPE_STA ||
 		    memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN) == 0 ||
 		    memcmp(hdr->addr2, sdata->u.sta.bssid, ETH_ALEN) != 0) {
 			return TXRX_DROP;
@@ -2062,7 +2062,7 @@ ieee80211_rx_h_data(struct ieee80211_txr
 		memcpy(dst, hdr->addr1, ETH_ALEN);
 		memcpy(src, hdr->addr2, ETH_ALEN);
 
-		if (sdata->type != IEEE80211_SUB_IF_TYPE_IBSS ||
+		if (sdata->type != IEEE80211_IF_TYPE_IBSS ||
 		    memcmp(hdr->addr3, sdata->u.sta.bssid, ETH_ALEN) != 0) {
 			if (net_ratelimit()) {
 				printk(KERN_DEBUG "%s: dropped IBSS frame (DA="
@@ -2126,8 +2126,8 @@ ieee80211_rx_h_data(struct ieee80211_txr
 		sdata->stats.rx_bytes += skb->len;
         }
 
-	if (local->bridge_packets && (sdata->type == IEEE80211_SUB_IF_TYPE_AP
-	    || sdata->type == IEEE80211_SUB_IF_TYPE_VLAN)) {
+	if (local->bridge_packets && (sdata->type == IEEE80211_IF_TYPE_AP
+	    || sdata->type == IEEE80211_IF_TYPE_VLAN)) {
 		if (MULTICAST_ADDR(skb->data)) {
 			/* send multicast frames both to higher layers in
 			 * local net stack and back to the wireless media */
@@ -2658,7 +2658,7 @@ #endif /* IEEE80211_LEDS */
 static ieee80211_txrx_result
 ieee80211_rx_h_monitor(struct ieee80211_txrx_data *rx)
 {
-	if (rx->sdata->type == IEEE80211_SUB_IF_TYPE_MNTR) {
+	if (rx->sdata->type == IEEE80211_IF_TYPE_MNTR) {
 		ieee80211_rx_mgmt(rx->dev, rx->skb, rx->u.rx.status,
                                   ieee80211_msg_monitor);
 		return TXRX_QUEUED;
@@ -2697,7 +2697,7 @@ ieee80211_rx_h_check(struct ieee80211_tx
 
 	/* Filter out foreign unicast packets when in promiscuous mode.
 	 * FIX: Filter out multicast to foreign BSSID. */
-	if (rx->sdata->type == IEEE80211_SUB_IF_TYPE_STA &&
+	if (rx->sdata->type == IEEE80211_IF_TYPE_STA &&
 	    !MULTICAST_ADDR(hdr->addr1) &&
 	    !ieee80211_own_addr(rx->dev, hdr->addr1))
 		return TXRX_DROP;
@@ -2713,7 +2713,7 @@ ieee80211_rx_h_check(struct ieee80211_tx
 	if (unlikely((WLAN_FC_GET_TYPE(rx->fc) == WLAN_FC_TYPE_DATA ||
 		      (WLAN_FC_GET_TYPE(rx->fc) == WLAN_FC_TYPE_CTRL &&
 		       WLAN_FC_GET_STYPE(rx->fc) == WLAN_FC_STYPE_PSPOLL)) &&
-		     rx->sdata->type != IEEE80211_SUB_IF_TYPE_IBSS &&
+		     rx->sdata->type != IEEE80211_IF_TYPE_IBSS &&
 		     (!rx->sta || !(rx->sta->flags & WLAN_STA_ASSOC)))) {
 		if (!(rx->fc & WLAN_FC_FROMDS) && !(rx->fc & WLAN_FC_TODS)) {
 			/* Drop IBSS frames silently. */
@@ -2725,7 +2725,7 @@ ieee80211_rx_h_check(struct ieee80211_tx
 		return TXRX_QUEUED;
 	}
 
-	if (rx->sdata->type == IEEE80211_SUB_IF_TYPE_STA)
+	if (rx->sdata->type == IEEE80211_IF_TYPE_STA)
 		always_sta_key = 0;
 	else
 		always_sta_key = 1;
@@ -2801,13 +2801,13 @@ ieee80211_rx_h_sta_process(struct ieee80
 	/* Update last_rx only for IBSS packets which are for the current
 	 * BSSID to avoid keeping the current IBSS network alive in cases where
 	 * other STAs are using different BSSID. */
-	if (rx->sdata->type == IEEE80211_SUB_IF_TYPE_IBSS) {
+	if (rx->sdata->type == IEEE80211_IF_TYPE_IBSS) {
 		u8 *bssid = ieee80211_get_bssid(hdr, rx->skb->len);
 		if (memcmp(bssid, rx->sdata->u.sta.bssid, ETH_ALEN) == 0)
 			sta->last_rx = jiffies;
 	} else
 	if (!MULTICAST_ADDR(hdr->addr1) ||
-	    rx->sdata->type == IEEE80211_SUB_IF_TYPE_STA) {
+	    rx->sdata->type == IEEE80211_IF_TYPE_STA) {
 		/* Update last_rx only for unicast frames in order to prevent
 		 * the Probe Request frames (the only broadcast frames from a
 		 * STA in infrastructure mode) from keeping a connection alive.
@@ -2906,7 +2906,7 @@ static ieee80211_txrx_result
 ieee80211_rx_h_802_1x_pae(struct ieee80211_txrx_data *rx)
 {
 	if (rx->sdata->eapol && ieee80211_is_eapol(rx->skb) &&
-	    rx->sdata->type != IEEE80211_SUB_IF_TYPE_STA) {
+	    rx->sdata->type != IEEE80211_IF_TYPE_STA) {
 		/* Pass both encrypted and unencrypted EAPOL frames to user
 		 * space for processing. */
 		ieee80211_rx_mgmt(rx->dev, rx->skb, rx->u.rx.status,
@@ -2960,8 +2960,8 @@ ieee80211_rx_h_mgmt(struct ieee80211_txr
 {
         struct ieee80211_sub_if_data *sdata;
 	sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev);
-	if (sdata->type == IEEE80211_SUB_IF_TYPE_STA ||
-	    sdata->type == IEEE80211_SUB_IF_TYPE_IBSS) {
+	if (sdata->type == IEEE80211_IF_TYPE_STA ||
+	    sdata->type == IEEE80211_IF_TYPE_IBSS) {
 		ieee80211_sta_rx_mgmt(rx->dev, rx->skb, rx->u.rx.status);
 	} else {
 		/* Management frames are sent to hostapd for processing */
@@ -3123,7 +3123,7 @@ static void ieee80211_rx_michael_mic_rep
 	}
 
 	if (rx->local->hw->wep_include_iv &&
-	    rx->sdata->type == IEEE80211_SUB_IF_TYPE_AP) {
+	    rx->sdata->type == IEEE80211_IF_TYPE_AP) {
 		int keyidx = ieee80211_wep_get_keyidx(rx->skb);
 		/* AP with Pairwise keys support should never receive Michael
 		 * MIC errors for non-zero keyidx because these are reserved
@@ -3198,7 +3198,7 @@ static void ieee80211_sta_rx_broadcast(s
 	list_for_each(ptr, &local->sub_if_list) {
 		struct ieee80211_sub_if_data *sdata =
 			list_entry(ptr, struct ieee80211_sub_if_data, list);
-		if (sdata->type != IEEE80211_SUB_IF_TYPE_STA ||
+		if (sdata->type != IEEE80211_IF_TYPE_STA ||
 		    (memcmp(bssid, sdata->u.sta.bssid, ETH_ALEN) != 0 &&
 		     !(bssid[0] & 0x01)))
 			continue;
@@ -3266,7 +3266,7 @@ void __ieee80211_rx(struct net_device *d
 					      &sta_broadcast);
 		rx.sdata = IEEE80211_DEV_TO_SUB_IF(rx.dev);
 		if (sta == NULL &&
-		    rx.sdata->type == IEEE80211_SUB_IF_TYPE_IBSS) {
+		    rx.sdata->type == IEEE80211_IF_TYPE_IBSS) {
 			u8 *bssid = ieee80211_get_bssid(hdr, skb->len);
 			if (bssid)
 				sta = rx.sta =
@@ -3868,13 +3868,13 @@ static struct net_device *ieee80211_if_a
 	wds_dev->tx_queue_len = 0;
 
 	sdata = IEEE80211_DEV_TO_SUB_IF(wds_dev);
-	sdata->type = IEEE80211_SUB_IF_TYPE_AP;
+	sdata->type = IEEE80211_IF_TYPE_AP;
         sdata->master = local->mdev;
         sdata->dev = wds_dev;
 	sdata->local = local;
 	memset(&sdata->stats, 0, sizeof(struct net_device_stats));
 	sdata_parent = IEEE80211_DEV_TO_SUB_IF(dev);
-	if (sdata_parent->type == IEEE80211_SUB_IF_TYPE_AP)
+	if (sdata_parent->type == IEEE80211_IF_TYPE_AP)
 		sdata->bss = &sdata_parent->u.ap;
 	else {
 		printk(KERN_DEBUG "%s: could not set BSS pointer for new "
@@ -3916,7 +3916,7 @@ int ieee80211_if_add_wds(struct net_devi
                 return -ENOANO;
 
 	sdata = IEEE80211_DEV_TO_SUB_IF(wds_dev);
-        sdata->type = IEEE80211_SUB_IF_TYPE_WDS;
+        sdata->type = IEEE80211_IF_TYPE_WDS;
         memcpy(&sdata->u.wds, wds, sizeof(struct ieee80211_if_wds));
 
 #ifdef CONFIG_D80211_VERBOSE_DEBUG
@@ -3983,7 +3983,7 @@ int ieee80211_if_add_vlan(struct net_dev
                 return -ENOANO;
 
 	sdata = IEEE80211_DEV_TO_SUB_IF(vlan_dev);
-        sdata->type = IEEE80211_SUB_IF_TYPE_VLAN;
+        sdata->type = IEEE80211_IF_TYPE_VLAN;
 	ieee80211_proc_init_virtual(vlan_dev);
         return 0;
 }
@@ -3991,7 +3991,7 @@ int ieee80211_if_add_vlan(struct net_dev
 
 static void ieee80211_if_ap_init(struct ieee80211_sub_if_data *sdata)
 {
-	sdata->type = IEEE80211_SUB_IF_TYPE_AP;
+	sdata->type = IEEE80211_IF_TYPE_AP;
 	sdata->u.ap.dtim_period = 2;
 	sdata->u.ap.force_unicast_rateidx = -1;
 	sdata->u.ap.max_ratectrl_rateidx = -1;
@@ -4072,7 +4072,7 @@ int ieee80211_if_add_sta(struct net_devi
 
 	sdata = IEEE80211_DEV_TO_SUB_IF(sta_dev);
 	ifsta = &sdata->u.sta;
-	sdata->type = IEEE80211_SUB_IF_TYPE_STA;
+	sdata->type = IEEE80211_IF_TYPE_STA;
 	ieee80211_proc_init_virtual(sta_dev);
 
 	spin_lock_bh(&local->sub_if_lock);
@@ -4131,7 +4131,7 @@ #endif
 	}
 
 	switch (sdata->type) {
-	case IEEE80211_SUB_IF_TYPE_AP:
+	case IEEE80211_IF_TYPE_AP:
 		/* Remove all virtual interfaces that use this BSS
 		 * as their sdata->bss */
 		list_for_each_safe(ptr, n, &local->sub_if_list) {
@@ -4177,7 +4177,7 @@ #endif
 		}
 
 		break;
-	case IEEE80211_SUB_IF_TYPE_WDS:
+	case IEEE80211_IF_TYPE_WDS:
 		sta = sta_info_get(local, sdata->u.wds.remote_addr);
 		if (sta) {
 			sta_info_release(local, sta);
@@ -4189,7 +4189,7 @@ #ifdef CONFIG_D80211_VERBOSE_DEBUG
 #endif /* CONFIG_D80211_VERBOSE_DEBUG */
 		}
 		break;
-	case IEEE80211_SUB_IF_TYPE_STA:
+	case IEEE80211_IF_TYPE_STA:
 		del_timer_sync(&sdata->u.sta.timer);
 		if (local->scan_timer.data == (unsigned long) sdata->dev)
 			del_timer_sync(&local->scan_timer);
@@ -4258,32 +4258,28 @@ static int ieee80211_if_remove(struct ne
 int ieee80211_if_remove_wds(struct net_device *dev, const char *name,
 			    int locked)
 {
-        return ieee80211_if_remove(dev, name, IEEE80211_SUB_IF_TYPE_WDS,
-				   locked);
+        return ieee80211_if_remove(dev, name, IEEE80211_IF_TYPE_WDS, locked);
 }
 
 
 int ieee80211_if_remove_vlan(struct net_device *dev, const char *name,
 			     int locked)
 {
-        return ieee80211_if_remove(dev, name, IEEE80211_SUB_IF_TYPE_VLAN,
-				   locked);
+        return ieee80211_if_remove(dev, name, IEEE80211_IF_TYPE_VLAN, locked);
 }
 
 
 int ieee80211_if_remove_ap(struct net_device *dev, const char *name,
 			   int locked)
 {
-	return ieee80211_if_remove(dev, name, IEEE80211_SUB_IF_TYPE_AP,
-				   locked);
+	return ieee80211_if_remove(dev, name, IEEE80211_IF_TYPE_AP, locked);
 }
 
 
 int ieee80211_if_remove_sta(struct net_device *dev, const char *name,
 			    int locked)
 {
-	return ieee80211_if_remove(dev, name, IEEE80211_SUB_IF_TYPE_STA,
-				   locked);
+	return ieee80211_if_remove(dev, name, IEEE80211_IF_TYPE_STA, locked);
 }
 
 
@@ -4469,7 +4465,7 @@ struct net_device *ieee80211_alloc_hw(si
 	sprintf(apdev->name, "%sap", dev->name);
 
         sdata = IEEE80211_DEV_TO_SUB_IF(apdev);
-        sdata->type = IEEE80211_SUB_IF_TYPE_MGMT;
+        sdata->type = IEEE80211_IF_TYPE_MGMT;
         sdata->dev = apdev;
         sdata->master = mdev;
         sdata->local = local;
@@ -4490,7 +4486,7 @@ struct net_device *ieee80211_alloc_hw(si
 	sprintf(mdev->name, "%s.11", dev->name);
 
 	sdata = IEEE80211_DEV_TO_SUB_IF(mdev);
-	sdata->type = IEEE80211_SUB_IF_TYPE_AP;
+	sdata->type = IEEE80211_IF_TYPE_AP;
         sdata->dev = mdev;
         sdata->master = mdev;
         sdata->local = local;
net/d80211/ieee80211_i.h +7 -7
index 8fe1dd1..9d18c71 100644
@@ -256,13 +256,13 @@ #define IEEE80211_AUTH_ALG_LEAP BIT(2)
 };
 
 
-#define IEEE80211_SUB_IF_TYPE_AP   0x00000000
-#define IEEE80211_SUB_IF_TYPE_MGMT 0x00000001
-#define IEEE80211_SUB_IF_TYPE_STA  0x00000002
-#define IEEE80211_SUB_IF_TYPE_IBSS 0x00000003
-#define IEEE80211_SUB_IF_TYPE_MNTR 0x00000004
-#define IEEE80211_SUB_IF_TYPE_WDS  0x5A580211
-#define IEEE80211_SUB_IF_TYPE_VLAN 0x00080211
+#define IEEE80211_IF_TYPE_AP   0x00000000
+#define IEEE80211_IF_TYPE_MGMT 0x00000001
+#define IEEE80211_IF_TYPE_STA  0x00000002
+#define IEEE80211_IF_TYPE_IBSS 0x00000003
+#define IEEE80211_IF_TYPE_MNTR 0x00000004
+#define IEEE80211_IF_TYPE_WDS  0x5A580211
+#define IEEE80211_IF_TYPE_VLAN 0x00080211
 
 struct ieee80211_sub_if_data {
         struct list_head list;
net/d80211/ieee80211_ioctl.c +57 -57

326 lines not on this page · raw message

net/d80211/ieee80211_proc.c +5 -5
index 3709494..098599a 100644
@@ -166,22 +166,22 @@ static char * ieee80211_proc_sub_if(char
 		p += sprintf(p, "bss=%p\n", sdata->bss);
 
 	switch (sdata->type) {
-	case IEEE80211_SUB_IF_TYPE_AP:
+	case IEEE80211_IF_TYPE_AP:
 		p = ieee80211_proc_sub_if_ap(p, &sdata->u.ap);
 		break;
-	case IEEE80211_SUB_IF_TYPE_WDS:
+	case IEEE80211_IF_TYPE_WDS:
 		p += sprintf(p, "type=wds\n");
 		p += sprintf(p, "wds.peer=" MACSTR "\n",
 			     MAC2STR(sdata->u.wds.remote_addr));
 		break;
-	case IEEE80211_SUB_IF_TYPE_VLAN:
+	case IEEE80211_IF_TYPE_VLAN:
 		p += sprintf(p, "type=vlan\n");
 		p += sprintf(p, "vlan.id=%d\n", sdata->u.vlan.id);
 		break;
-	case IEEE80211_SUB_IF_TYPE_STA:
+	case IEEE80211_IF_TYPE_STA:
 		p = ieee80211_proc_sub_if_sta(p, 0, &sdata->u.sta);
 		break;
-	case IEEE80211_SUB_IF_TYPE_IBSS:
+	case IEEE80211_IF_TYPE_IBSS:
 		p = ieee80211_proc_sub_if_sta(p, 1, &sdata->u.sta);
 		break;
 	}
net/d80211/ieee80211_sta.c +20 -20
index 5df6734..49c1b62 100644
@@ -372,7 +372,7 @@ static void ieee80211_set_associated(str
 	if (assoc) {
 		struct ieee80211_sub_if_data *sdata;
 		sdata = IEEE80211_DEV_TO_SUB_IF(dev);
-		if (sdata->type != IEEE80211_SUB_IF_TYPE_STA)
+		if (sdata->type != IEEE80211_IF_TYPE_STA)
 			return;
 		ifsta->prev_bssid_set = 1;
 		memcpy(ifsta->prev_bssid, sdata->u.sta.bssid, ETH_ALEN);
@@ -863,7 +863,7 @@ static void ieee80211_rx_mgmt_auth(struc
 	u16 auth_alg, auth_transaction, status_code;
 
 	if (ifsta->state != IEEE80211_AUTHENTICATE &&
-	    sdata->type != IEEE80211_SUB_IF_TYPE_IBSS) {
+	    sdata->type != IEEE80211_IF_TYPE_IBSS) {
 		printk(KERN_DEBUG "%s: authentication frame received from "
 		       MACSTR ", but not in authenticate state - ignored\n",
 		       dev->name, MAC2STR(mgmt->sa));
@@ -877,7 +877,7 @@ static void ieee80211_rx_mgmt_auth(struc
 		return;
 	}
 
-	if (sdata->type != IEEE80211_SUB_IF_TYPE_IBSS &&
+	if (sdata->type != IEEE80211_IF_TYPE_IBSS &&
 	    memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN) != 0) {
 		printk(KERN_DEBUG "%s: authentication frame received from "
 		       "unknown AP (SA=" MACSTR " BSSID=" MACSTR ") - "
@@ -886,7 +886,7 @@ static void ieee80211_rx_mgmt_auth(struc
 		return;
 	}
 
-	if (sdata->type != IEEE80211_SUB_IF_TYPE_IBSS &&
+	if (sdata->type != IEEE80211_IF_TYPE_IBSS &&
 	    memcmp(ifsta->bssid, mgmt->bssid, ETH_ALEN) != 0) {
 		printk(KERN_DEBUG "%s: authentication frame received from "
 		       "unknown BSSID (SA=" MACSTR " BSSID=" MACSTR ") - "
@@ -904,7 +904,7 @@ static void ieee80211_rx_mgmt_auth(struc
 	       dev->name, MAC2STR(mgmt->sa), auth_alg,
 	       auth_transaction, status_code);
 
-	if (sdata->type == IEEE80211_SUB_IF_TYPE_IBSS) {
+	if (sdata->type == IEEE80211_IF_TYPE_IBSS) {
 		/* IEEE 802.11 standard does not require authentication in IBSS
 		 * networks and most implementations do not seem to use it.
 		 * However, try to reply to authentication attempts if someone
@@ -1364,7 +1364,7 @@ #endif
 		((u64) pos[3] << 24) | ((u64) pos[2] << 16) |
 		((u64) pos[1] << 8) | ((u64) pos[0]);
 
-	if (sdata->type == IEEE80211_SUB_IF_TYPE_IBSS && beacon &&
+	if (sdata->type == IEEE80211_IF_TYPE_IBSS && beacon &&
 	    memcmp(mgmt->bssid, sdata->u.sta.bssid, ETH_ALEN) == 0) {
 #ifdef IEEE80211_IBSS_DEBUG
 		static unsigned long last_tsf_debug = 0;
@@ -1388,7 +1388,7 @@ #endif /* IEEE80211_IBSS_DEBUG */
 				   &elems) == ParseFailed)
 		invalid = 1;
 
-	if (sdata->type == IEEE80211_SUB_IF_TYPE_IBSS && elems.supp_rates &&
+	if (sdata->type == IEEE80211_IF_TYPE_IBSS && elems.supp_rates &&
 	    memcmp(mgmt->bssid, sdata->u.sta.bssid, ETH_ALEN) == 0 &&
 	    (sta = sta_info_get(local, mgmt->sa))) {
 		struct ieee80211_rate *rates;
@@ -1596,7 +1596,7 @@ static void ieee80211_rx_mgmt_beacon(str
 	ieee80211_rx_bss_info(dev, mgmt, len, rx_status, 1);
 
 	sdata = IEEE80211_DEV_TO_SUB_IF(dev);
-	if (sdata->type != IEEE80211_SUB_IF_TYPE_STA)
+	if (sdata->type != IEEE80211_IF_TYPE_STA)
 		return;
 	ifsta = &sdata->u.sta;
 
@@ -1651,7 +1651,7 @@ static void ieee80211_rx_mgmt_probe_req(
 	struct ieee80211_mgmt *resp;
 	u8 *pos, *end;
 
-	if (sdata->type != IEEE80211_SUB_IF_TYPE_IBSS ||
+	if (sdata->type != IEEE80211_IF_TYPE_IBSS ||
 	    ifsta->state != IEEE80211_IBSS_JOINED ||
 	    len < 24 + 2 || ifsta->probe_resp == NULL)
 		return;
@@ -1720,7 +1720,7 @@ void ieee80211_sta_rx_mgmt(struct net_de
 		goto fail;
 
 	sdata = IEEE80211_DEV_TO_SUB_IF(dev);
-	if (sdata->type != IEEE80211_SUB_IF_TYPE_STA) {
+	if (sdata->type != IEEE80211_IF_TYPE_STA) {
 		printk(KERN_DEBUG "%s: ieee80211_sta_rx_mgmt: non-STA "
 		       "interface (type=%d)\n", dev->name, sdata->type);
 		goto fail;
@@ -1865,8 +1865,8 @@ void ieee80211_sta_timer(unsigned long p
 
 	dev = (struct net_device *) ptr;
 	sdata = IEEE80211_DEV_TO_SUB_IF(dev);
-	if (sdata->type != IEEE80211_SUB_IF_TYPE_STA &&
-	    sdata->type != IEEE80211_SUB_IF_TYPE_IBSS) {
+	if (sdata->type != IEEE80211_IF_TYPE_STA &&
+	    sdata->type != IEEE80211_IF_TYPE_IBSS) {
 		printk(KERN_DEBUG "%s: ieee80211_sta_timer: non-STA interface "
 		       "(type=%d)\n", dev->name, sdata->type);
 		return;
@@ -1913,7 +1913,7 @@ static void ieee80211_sta_new_auth(struc
 	struct ieee80211_local *local = dev->priv;
 	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
-	if (sdata->type != IEEE80211_SUB_IF_TYPE_STA)
+	if (sdata->type != IEEE80211_IF_TYPE_STA)
 		return;
 
 	if (local->hw->reset_tsf) {
@@ -2318,7 +2318,7 @@ int ieee80211_sta_set_ssid(struct net_de
 	ifsta->ssid_len = len;
 
 	ifsta->ssid_set = 1;
-	if (sdata->type == IEEE80211_SUB_IF_TYPE_IBSS && !ifsta->bssid_set) {
+	if (sdata->type == IEEE80211_IF_TYPE_IBSS && !ifsta->bssid_set) {
 		ifsta->ibss_join_req = jiffies;
 		ifsta->state = IEEE80211_IBSS_SEARCH;
 		return ieee80211_sta_find_ibss(dev, ifsta);
@@ -2439,7 +2439,7 @@ static void ieee80211_sta_scan_timer(uns
 			local->last_scan_completed = jiffies;
 			memset(&wrqu, 0, sizeof(wrqu));
 			wireless_send_event(dev, SIOCGIWSCAN, &wrqu, NULL);
-			if (sdata->type == IEEE80211_SUB_IF_TYPE_IBSS) {
+			if (sdata->type == IEEE80211_IF_TYPE_IBSS) {
 				struct ieee80211_sub_if_data *sdata =
 					IEEE80211_DEV_TO_SUB_IF(dev);
 				struct ieee80211_if_sta *ifsta = &sdata->u.sta;
@@ -2453,7 +2453,7 @@ static void ieee80211_sta_scan_timer(uns
 		skip = !(local->hw_modes & (1 << mode->mode));
 		chan = &mode->channels[local->scan_channel_idx];
 		if (!(chan->flag & IEEE80211_CHAN_W_SCAN) ||
-		    (sdata->type == IEEE80211_SUB_IF_TYPE_IBSS &&
+		    (sdata->type == IEEE80211_IF_TYPE_IBSS &&
 		     !(chan->flag & IEEE80211_CHAN_W_IBSS)) ||
 		    (local->hw_modes & (1 << MODE_IEEE80211G) &&
 		     mode->mode == MODE_IEEE80211B && local->scan_skip_11b))
@@ -2799,7 +2799,7 @@ struct sta_info * ieee80211_ibss_add_sta
 	spin_lock_bh(&local->sub_if_lock);
 	list_for_each(ptr, &local->sub_if_list) {
 		sdata = list_entry(ptr, struct ieee80211_sub_if_data, list);
-		if (sdata->type == IEEE80211_SUB_IF_TYPE_IBSS &&
+		if (sdata->type == IEEE80211_IF_TYPE_IBSS &&
 		    memcmp(bssid, sdata->u.sta.bssid, ETH_ALEN) == 0) {
 			sta_dev = sdata->dev;
 			break;
@@ -2835,8 +2835,8 @@ int ieee80211_sta_deauthenticate(struct 
 	printk(KERN_DEBUG "%s: deauthenticate(reason=%d)\n",
 	       dev->name, reason);
 
-	if (sdata->type != IEEE80211_SUB_IF_TYPE_STA &&
-	    sdata->type != IEEE80211_SUB_IF_TYPE_IBSS)
+	if (sdata->type != IEEE80211_IF_TYPE_STA &&
+	    sdata->type != IEEE80211_IF_TYPE_IBSS)
 		return -EINVAL;
 
 	ieee80211_send_deauth(dev, ifsta, reason);
@@ -2853,7 +2853,7 @@ int ieee80211_sta_disassociate(struct ne
 	printk(KERN_DEBUG "%s: disassociate(reason=%d)\n",
 	       dev->name, reason);
 
-	if (sdata->type != IEEE80211_SUB_IF_TYPE_STA)
+	if (sdata->type != IEEE80211_IF_TYPE_STA)
 		return -EINVAL;
 
 	if (!ifsta->associated)
net/d80211/wme.c +1 -1
index 21689ed..51a197a 100644
@@ -190,7 +190,7 @@ static inline int classify80211(struct s
 		return IEEE80211_TX_QUEUE_DATA0;
 	}
 
-	if (unlikely(pkt_data->sdata->type == IEEE80211_SUB_IF_TYPE_MGMT)) {
+	if (unlikely(pkt_data->sdata->type == IEEE80211_IF_TYPE_MGMT)) {
 		/* Data frames from hostapd (mainly, EAPOL) use AC_VO
 		* and they will include QoS control fields if
 		* the target STA is using WME. */
Signature · 1 line
1.3.0
author
#8 lore raw

PATCH 8/17 d80211: ask driver for allowed iface combinations

In reply to Jiri Benc

Not all combinations of interfaces (in fact, very few combination of interfaces) are possible to be UP together. When an interface is going UP, let's ask the driver if this is possible.

Please note that ieee80211_if_init_conf structure is not complete yet - new fields will need to be added to allow drivers to decide.

---

 include/net/d80211.h     |   52 ++++++++++++++++++++++++++++++++++++++++++++++
 net/d80211/ieee80211.c   |   30 ++++++++++++++++++++++-----
 net/d80211/ieee80211_i.h |    8 -------
 3 files changed, 77 insertions(+), 13 deletions(-)

77fe239e18433d16747c0851a5ecba6abe76820b

include/net/d80211.h +52 -0
index 75e8e24..44417fc 100644
@@ -305,6 +305,42 @@ struct ieee80211_conf {
 	u8 pulse_inband_threshold;
 };
 
+/**
+ * enum ieee80211_if_types - types of 802.11 network interface
+ * @IEEE80211_IF_TYPE_AP: interface in AP mode.
+ * @IEEE80211_IF_TYPE_MGMT: special interface for communication with hostap
+ *	daemon. Drivers should never see this type.
+ * @IEEE80211_IF_TYPE_STA: interface in STA (client) mode.
+ * @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.
+ */
+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,
+};
+
+/**
+ * struct ieee80211_if_init_conf - initial configuration of an interface
+ * @type: one of &enum ieee80211_if_types constants. Determines the type of
+ *	added/removed interface.
+ * @mac_addr: pointer to MAC address of the interface. This pointer is valid
+ *	until the interface is removed (i.e. it cannot be used after
+ *	remove_interface() callback was called for this interface).
+ *
+ * This structure is used in add_interface() and remove_interface()
+ * callbacks of &struct ieee80211_hw.
+ */
+struct ieee80211_if_init_conf {
+	int type;
+	void *mac_addr;
+};
 
 typedef enum { ALG_NONE, ALG_WEP, ALG_TKIP, ALG_CCMP, ALG_NULL }
 ieee80211_key_alg;
@@ -452,6 +488,22 @@ struct ieee80211_hw {
 	 * interrupts and beacon sending. */
 	int (*stop)(struct net_device *dev);
 
+	/* Handler for asking a driver if a new interface can be added (or,
+	 * more exactly, set UP). If the handler returns zero, the interface
+	 * is added. Driver should perform any initialization it needs prior
+	 * to returning zero. By returning non-zero, adding of the interface
+	 * is not permitted. The open() handler is called after
+	 * add_interface() if this is the first device added. At least one
+	 * of open() and add_interface() handler has to be non-NULL. If
+	 * add_interface() is NULL, one STA interface is permitted only. */
+	int (*add_interface)(struct net_device *dev,
+			     struct ieee80211_if_init_conf *conf);
+
+	/* Notify a driver that interface is going down. The stop() handler
+	 * is called prior to this if this is a last interface. */
+	void (*remove_interface)(struct net_device *dev,
+				 struct ieee80211_if_init_conf *conf);
+
 	/* Handler for configuration requests. IEEE 802.11 code calls this
 	 * function to change hardware configuration, e.g., channel. */
 	int (*config)(struct net_device *dev, struct ieee80211_conf *conf);
net/d80211/ieee80211.c +25 -5
index fae9d64..271c4d9 100644
@@ -1828,11 +1828,22 @@ static int ieee80211_open(struct net_dev
 	int res;
 
 	sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+	if (local->hw->add_interface) {
+		struct ieee80211_if_init_conf conf;
 
-        if (local->open_count == 0) {
-		res = local->hw->open(sdata->master);
+		conf.type = sdata->type;
+		conf.mac_addr = dev->dev_addr;
+		res = local->hw->add_interface(sdata->master, &conf);
 		if (res)
 			return res;
+	}
+
+        if (local->open_count == 0) {
+		if (local->hw->open) {
+			res = local->hw->open(sdata->master);
+			if (res)
+				return res;
+		}
 		ieee80211_init_scan(sdata->master);
 	}
         local->open_count++;
@@ -1855,10 +1866,19 @@ static int ieee80211_stop(struct net_dev
 	local->open_count--;
         if (local->open_count == 0) {
 		ieee80211_stop_scan(sdata->master);
-		res = local->hw->stop(sdata->master);
-		if (res)
-			return res;
+		if (local->hw->stop) {
+			res = local->hw->stop(sdata->master);
+			if (res)
+				return res;
+		}
         }
+	if (local->hw->remove_interface) {
+		struct ieee80211_if_init_conf conf;
+
+		conf.type = sdata->type;
+		conf.mac_addr = dev->dev_addr;
+		local->hw->remove_interface(sdata->master, &conf);
+	}
 
 	return 0;
 }
net/d80211/ieee80211_i.h +0 -8
index 9d18c71..d42b6fe 100644
@@ -256,14 +256,6 @@ #define IEEE80211_AUTH_ALG_LEAP BIT(2)
 };
 
 
-#define IEEE80211_IF_TYPE_AP   0x00000000
-#define IEEE80211_IF_TYPE_MGMT 0x00000001
-#define IEEE80211_IF_TYPE_STA  0x00000002
-#define IEEE80211_IF_TYPE_IBSS 0x00000003
-#define IEEE80211_IF_TYPE_MNTR 0x00000004
-#define IEEE80211_IF_TYPE_WDS  0x5A580211
-#define IEEE80211_IF_TYPE_VLAN 0x00080211
-
 struct ieee80211_sub_if_data {
         struct list_head list;
         unsigned int type;
Signature · 1 line
1.3.0
author
#9 lore raw

PATCH 9/17 d80211: remove obsolete stuff

In reply to Jiri Benc

Because any number of interfaces may be added, bss_devs and sta_devs arrays cannot be fixed-size arrays. We can make them linked lists, but they are needed for optimalization only (and even that is questionable with subsequent patches). Let's remove them; we will probably want something similar later to speed up packet receiving, but let's not bother ourselves now.

Also, ieee80211_addr_inc is removed. Choosing of MAC address of a new STA should be matter of userspace. It's responsibility of the stack not to allow two STAs with the same MAC address to be up - this feature is introduced in one of subsequent patches.

---

 include/net/d80211.h         |    3 -
 net/d80211/hostapd_ioctl.h   |    1 
 net/d80211/ieee80211.c       |  164 ++++--------------------------------------
 net/d80211/ieee80211_i.h     |    9 --
 net/d80211/ieee80211_ioctl.c |   70 ------------------
 net/d80211/ieee80211_proc.c  |   12 ---
 net/d80211/ieee80211_sysfs.c |   29 -------
 7 files changed, 16 insertions(+), 272 deletions(-)

3180a84e9351200900e932690feb613d1f799068

include/net/d80211.h +0 -3
index 44417fc..5dff49a 100644
@@ -277,9 +277,6 @@ struct ieee80211_conf {
         int antenna_def;
         int antenna_mode;
 
-	u8 bssid_mask[ETH_ALEN];	/* ff:ff:ff:ff:ff:ff = 1 BSSID */
-	int bss_count;
-
 	int atheros_super_ag_compression;
 	int atheros_super_ag_fast_frame;
 	int atheros_super_ag_burst;
net/d80211/hostapd_ioctl.h +0 -1
index 42c2bc5..028caf1 100644
@@ -129,7 +129,6 @@ enum {
 	PRISM2_HOSTAPD_SET_CHANNEL_FLAG = 1012,
 	PRISM2_HOSTAPD_SET_REGULATORY_DOMAIN = 1013,
 	PRISM2_HOSTAPD_SET_TX_QUEUE_PARAMS = 1014,
-	PRISM2_HOSTAPD_SET_BSS = 1015,
 	PRISM2_HOSTAPD_GET_TX_STATS = 1016,
 	PRISM2_HOSTAPD_UPDATE_IF = 1017,
 	PRISM2_HOSTAPD_SCAN_REQ = 1019,
net/d80211/ieee80211.c +16 -148

275 lines not on this page · raw message

net/d80211/ieee80211_i.h +0 -9
index d42b6fe..3766232 100644
@@ -372,13 +372,6 @@ #define IEEE80211_IRQSAFE_QUEUE_LIMIT 12
 
         spinlock_t sub_if_lock; /* mutex for STA data structures */
         struct list_head sub_if_list;
-	struct net_device **bss_devs; /* pointer to IF_TYPE_AP devices for
-				       * quick access to BSS data */
-	int bss_dev_count; /* number of used entries in bss_devs; note: the
-			    * total size of bss_devs array is stored in
-			    * conf.bss_count */
-	struct net_device **sta_devs; /* pointer to IF_TYPE_STA devices */
-	int sta_dev_count; /* number of used entries in sta_devs */
 	int sta_scanning;
 	int scan_hw_mode_idx;
 	int scan_channel_idx;
@@ -553,8 +546,6 @@ int ieee80211_if_remove_sta(struct net_d
 /* ieee80211_ioctl.c */
 int ieee80211_set_compression(struct ieee80211_local *local,
 			      struct net_device *dev, struct sta_info *sta);
-int ieee80211_set_bss_count(struct net_device *dev, int new_count,
-			    u8 *bssid_mask);
 /* ieee80211_sta.c */
 void ieee80211_sta_timer(unsigned long ptr);
 void ieee80211_sta_rx_mgmt(struct net_device *dev, struct sk_buff *skb,
net/d80211/ieee80211_ioctl.c +0 -70

82 lines not on this page · raw message

net/d80211/ieee80211_proc.c +0 -12
index 098599a..a886280 100644
@@ -374,7 +374,6 @@ static int ieee80211_proc_debug_read(cha
 {
 	char *p = page;
 	struct ieee80211_local *local = (struct ieee80211_local *) data;
-	int i;
 
 	if (off != 0) {
 		*eof = 1;
@@ -439,17 +438,6 @@ #endif /* CONFIG_D80211_DEBUG_COUNTERS *
 
 	p += sprintf(p, "num_scans=%u\n", local->scan.num_scans);
 
-	p += sprintf(p,
-		     "conf.bss_count=%d\n"
-		     "bss_dev_count=%u\n",
-		     local->conf.bss_count, local->bss_dev_count);
-	for (i = 0; i < local->conf.bss_count; i++) {
-		p += sprintf(p, "bss_dev[%d]=%p (%s)\n",
-			     i, local->bss_devs[i],
-			     (i < local->bss_dev_count && local->bss_devs[i]) ?
-			     local->bss_devs[i]->name : "N/A");
-	}
-
 	return (p - page);
 }
 
net/d80211/ieee80211_sysfs.c +0 -29
index 32fb380..082404f 100644
@@ -51,33 +51,6 @@ static ssize_t store_remove_iface(struct
 	return res < 0 ? res : len;
 }
 
-static ssize_t show_max_iface_count(struct class_device *dev,
-				    char *buf)
-{
-	struct ieee80211_local *local = to_ieee80211_local(dev);
-
-	return sprintf(buf, "%d\n", local->conf.bss_count);
-}
-
-static ssize_t store_max_iface_count(struct class_device *dev,
-				     const char *buf, size_t len)
-{
-	struct ieee80211_local *local = to_ieee80211_local(dev);
-	unsigned long new_count;
-	char *endp;
-	int res;
-
-	if (!capable(CAP_NET_ADMIN))
-		return -EPERM;
-	new_count = simple_strtoul(buf, &endp, 0);
-	if (endp == buf)
-		return -EINVAL;
-	rtnl_lock();
-	res = ieee80211_set_bss_count(local->mdev, new_count, NULL);
-	rtnl_unlock();
-	return res < 0 ? res : len;
-}
-
 #ifdef CONFIG_HOTPLUG
 static int ieee80211_uevent(struct class_device *cd, char **envp,
 			    int num_envp, char *buf, int size)
@@ -98,8 +71,6 @@ #endif
 static struct class_device_attribute ieee80211_class_dev_attrs[] = {
 	__ATTR(add_iface, S_IWUSR, NULL, store_add_iface),
 	__ATTR(remove_iface, S_IWUSR, NULL, store_remove_iface),
-	__ATTR(max_iface_count, S_IRUGO | S_IWUSR,
-	       show_max_iface_count, store_max_iface_count),
 	{}
 };
 
Signature · 1 line
1.3.0
author
#10 lore raw

PATCH 10/17 d80211: fix interface configuration

In reply to Jiri Benc

This patch fixes some problems in interface configuration.

- Pass interface ID to add_interface and remove_interface callbacks. This ID is used by a driver when calling ieee80211_beacon_get and ieee80211_get_buffered_bc functions.
- New configuration callback, config_interface, is introduced.
- Allow BSSID to be set per-interface.

---

 include/net/d80211.h         |   63 ++++++++++++++++++++++++++++++++++--------
 net/d80211/ieee80211.c       |   35 +++++++++++++++++++----
 net/d80211/ieee80211_i.h     |    1 +
 net/d80211/ieee80211_ioctl.c |   11 -------
 net/d80211/ieee80211_sta.c   |   15 +++++++++-
 5 files changed, 93 insertions(+), 32 deletions(-)

9b4d05977dda50bec721e696ec3cf98afd7d1ca9

include/net/d80211.h +51 -12
index 5dff49a..84abd7c 100644
@@ -286,8 +286,6 @@ struct ieee80211_conf {
 
 	int atheros_xr;
 
-	u8 client_bssid[ETH_ALEN];
-
 	/* Following five fields are used for IEEE 802.11H */
 	unsigned int radar_detect;
 	unsigned int spect_mgmt;
@@ -325,6 +323,9 @@ enum ieee80211_if_types {
 
 /**
  * struct ieee80211_if_init_conf - initial configuration of an interface
+ * @if_id: internal interface ID. This number has no particular meaning to
+ *	drivers and the only allowed usage is to pass it to
+ *	ieee80211_beacon_get() and ieee80211_get_buffered_bc() functions.
  * @type: one of &enum ieee80211_if_types constants. Determines the type of
  *	added/removed interface.
  * @mac_addr: pointer to MAC address of the interface. This pointer is valid
@@ -335,10 +336,27 @@ enum ieee80211_if_types {
  * callbacks of &struct ieee80211_hw.
  */
 struct ieee80211_if_init_conf {
+	int if_id;
 	int type;
 	void *mac_addr;
 };
 
+/**
+ * struct ieee80211_if_conf - configuration of an interface
+ * @type: type of the interface. This is always the same as was specified in
+ *	&struct ieee80211_if_init_conf. The type of interface never change
+ *	during the live of the interface; this field is present only for
+ *	convenience.
+ * @bssid: BSSID of the network we are associated to/creating.
+ *
+ * This structure is passed to config_interface() callback of
+ * &struct ieee80211_hw.
+ */
+struct ieee80211_if_conf {
+	int type;
+	u8 *bssid;
+};
+
 typedef enum { ALG_NONE, ALG_WEP, ALG_TKIP, ALG_CCMP, ALG_NULL }
 ieee80211_key_alg;
 
@@ -505,6 +523,11 @@ struct ieee80211_hw {
 	 * function to change hardware configuration, e.g., channel. */
 	int (*config)(struct net_device *dev, struct ieee80211_conf *conf);
 
+	/* Handler for configuration requests related to interfaces (e.g.
+	 * BSSID). */
+	int (*config_interface)(struct net_device *dev, int if_id,
+				struct ieee80211_if_conf *conf);
+
 	/* Set TIM bit handler. If the hardware/firmware takes care of beacon
 	 * generation, IEEE 802.11 code uses this function to tell the
 	 * low-level to set (or clear if set==0) TIM bit for the given aid. If
@@ -682,16 +705,31 @@ void ieee80211_tx_status(struct net_devi
 void ieee80211_tx_status_irqsafe(struct net_device *dev, struct sk_buff *skb,
 				 struct ieee80211_tx_status *status);
 
-/* Beacon generation function. If the beacon frames are generated by the host
- * system (i.e., not in hardware/firmware), the low-level driver uses this
- * function to receive the next beacon frame from the 802.11 code. The
- * low-level is responsible for calling this function before beacon data is
- * needed (e.g., based on hardware interrupt). Returned skb is used only once
- * and low-level driver is responsible of freeing it. */
-struct sk_buff * ieee80211_beacon_get(struct net_device *dev, int bss_idx,
+/**
+ * ieee80211_beacon_get - beacon generation function
+ * @dev: pointer to &struct net_device as obtained from
+ *	ieee80211_alloc_hw().
+ * @if_id: interface ID from &struct ieee80211_if_init_conf.
+ * @control: will be filled with information needed to send this beacon.
+ *
+ * If the beacon frames are generated by the host system (i.e., not in
+ * hardware/firmware), the low-level driver uses this function to receive
+ * the next beacon frame from the 802.11 code. The low-level is responsible
+ * for calling this function before beacon data is needed (e.g., based on
+ * hardware interrupt). Returned skb is used only once and low-level driver
+ * is responsible of freeing it.
+ */
+struct sk_buff * ieee80211_beacon_get(struct net_device *dev, int if_id,
 				      struct ieee80211_tx_control *control);
 
-/* Function for accessing buffered broadcast and multicast frames. If
+/**
+ * ieee80211_beacon_get - accessing buffered broadcast and multicast frames
+ * @dev: pointer to &struct net_device as obtained from
+ *	ieee80211_alloc_hw().
+ * @if_id: interface ID from &struct ieee80211_if_init_conf.
+ * @control: will be filled with information needed to send returned frame.
+ *
+ * Function for accessing buffered broadcast and multicast frames. If
  * hardware/firmware does not implement buffering of broadcast/multicast
  * frames when power saving is used, 802.11 code buffers them in the host
  * memory. The low-level driver uses this function to fetch next buffered
@@ -704,9 +742,10 @@ struct sk_buff * ieee80211_beacon_get(st
  * call ieee80211_beacon_get() first. ieee80211_get_buffered_bc() returns
  * NULL if the previous generated beacon was not DTIM, so the low-level driver
  * does not need to check for DTIM beacons separately and should be able to
- * use common code for all beacons. */
+ * use common code for all beacons.
+ */
 struct sk_buff *
-ieee80211_get_buffered_bc(struct net_device *dev, int bss_idx,
+ieee80211_get_buffered_bc(struct net_device *dev, int if_id,
 			  struct ieee80211_tx_control *control);
 
 /* Low level drivers that have their own MLME and MAC indicate
net/d80211/ieee80211.c +28 -7
index e3e155e..e6d4342 100644
@@ -1556,7 +1556,7 @@ static void ieee80211_beacon_add_tim(str
 }
 
 
-struct sk_buff * ieee80211_beacon_get(struct net_device *dev, int bss_idx,
+struct sk_buff * ieee80211_beacon_get(struct net_device *dev, int if_id,
 				      struct ieee80211_tx_control *control)
 {
 	struct ieee80211_local *local = dev->priv;
@@ -1569,18 +1569,19 @@ struct sk_buff * ieee80211_beacon_get(st
 	u8 *b_head, *b_tail;
 	int bh_len, bt_len;
 
-	bdev = dev_get_by_index(bss_idx);
+	bdev = dev_get_by_index(if_id);
 	if (bdev) {
 		sdata = IEEE80211_DEV_TO_SUB_IF(bdev);
 		ap = &sdata->u.ap;
 		dev_put(bdev);
 	}
 
-	if (ap == NULL || ap->beacon_head == NULL) {
+	if (ap == NULL || sdata->type != IEEE80211_IF_TYPE_AP ||
+	    ap->beacon_head == NULL) {
 #ifdef CONFIG_D80211_VERBOSE_DEBUG
 		if (net_ratelimit())
 			printk(KERN_DEBUG "no beacon data avail for idx=%d "
-			       "(%s)\n", bss_idx, bdev ? bdev->name : "N/A");
+			       "(%s)\n", if_id, bdev ? bdev->name : "N/A");
 #endif /* CONFIG_D80211_VERBOSE_DEBUG */
 		return NULL;
 	}
@@ -1632,7 +1633,7 @@ #endif /* CONFIG_D80211_VERBOSE_DEBUG */
 
 
 struct sk_buff *
-ieee80211_get_buffered_bc(struct net_device *dev, int bss_idx,
+ieee80211_get_buffered_bc(struct net_device *dev, int if_id,
 			  struct ieee80211_tx_control *control)
 {
 	struct ieee80211_local *local = dev->priv;
@@ -1645,13 +1646,14 @@ ieee80211_get_buffered_bc(struct net_dev
 	struct ieee80211_sub_if_data *sdata;
 	struct ieee80211_if_ap *bss = NULL;
 
-	bdev = dev_get_by_index(bss_idx);
+	bdev = dev_get_by_index(if_id);
 	if (bdev) {
 		sdata = IEEE80211_DEV_TO_SUB_IF(bdev);
 		bss = &sdata->u.ap;
 		dev_put(bdev);
 	}
-	if (bss == NULL || bss->beacon_head == NULL)
+	if (bss == NULL || sdata->type != IEEE80211_IF_TYPE_AP ||
+	    bss->beacon_head == NULL)
 		return NULL;
 
 	if (bss->dtim_count != 0)
@@ -1694,6 +1696,23 @@ ieee80211_get_buffered_bc(struct net_dev
 	return skb;
 }
 
+int ieee80211_if_config(struct net_device *dev)
+{
+	struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+	struct ieee80211_local *local = dev->priv;
+	struct ieee80211_if_conf conf;
+
+	if (!local->hw->config_interface)
+		return 0;
+
+	memset(&conf, 0, sizeof(conf));
+	conf.type = sdata->type;
+	if (sdata->type == IEEE80211_IF_TYPE_STA ||
+	    sdata->type == IEEE80211_IF_TYPE_IBSS) {
+		conf.bssid = sdata->u.sta.bssid;
+	}
+	return local->hw->config_interface(local->mdev, dev->ifindex, &conf);
+}
 
 int ieee80211_hw_config(struct net_device *dev)
 {
@@ -1824,6 +1843,7 @@ static int ieee80211_open(struct net_dev
 	if (local->hw->add_interface) {
 		struct ieee80211_if_init_conf conf;
 
+		conf.if_id = dev->ifindex;
 		conf.type = sdata->type;
 		conf.mac_addr = dev->dev_addr;
 		res = local->hw->add_interface(sdata->master, &conf);
@@ -1868,6 +1888,7 @@ static int ieee80211_stop(struct net_dev
 	if (local->hw->remove_interface) {
 		struct ieee80211_if_init_conf conf;
 
+		conf.if_id = dev->ifindex;
 		conf.type = sdata->type;
 		conf.mac_addr = dev->dev_addr;
 		local->hw->remove_interface(sdata->master, &conf);
net/d80211/ieee80211_i.h +1 -0
index 3766232..8fd0ac4 100644
@@ -484,6 +484,7 @@ #endif /* CONFIG_D80211_DEBUG_COUNTERS *
 
 /* ieee80211.c */
 int ieee80211_hw_config(struct net_device *dev);
+int ieee80211_if_config(struct net_device *dev);
 struct ieee80211_key_conf *
 ieee80211_key_data2conf(struct ieee80211_local *local,
 			struct ieee80211_key *data);
net/d80211/ieee80211_ioctl.c +0 -11
index 461e2d9..00efe47 100644
@@ -1782,22 +1782,11 @@ static int ieee80211_ioctl_siwap(struct 
 				 struct iw_request_info *info,
 				 struct sockaddr *ap_addr, char *extra)
 {
-	struct ieee80211_local *local = dev->priv;
 	struct ieee80211_sub_if_data *sdata;
 
 	sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 	if (sdata->type == IEEE80211_IF_TYPE_STA ||
 	    sdata->type == IEEE80211_IF_TYPE_IBSS) {
-		int changed_bssid = 0;
-		if (memcmp(local->conf.client_bssid, (u8 *) &ap_addr->sa_data,
-			   ETH_ALEN) != 0)
-			changed_bssid = 1;
-		memcpy(local->conf.client_bssid, (u8 *) &ap_addr->sa_data,
-		       ETH_ALEN);
-		if (changed_bssid && ieee80211_hw_config(dev)) {
-			printk(KERN_DEBUG "%s: Failed to config new BSSID to "
-			       "the low-level driver\n", dev->name);
-		}
 		return ieee80211_sta_set_bssid(dev, (u8 *) &ap_addr->sa_data);
 	} else if (sdata->type == IEEE80211_IF_TYPE_WDS) {
 		if (memcmp(sdata->u.wds.remote_addr, (u8 *) &ap_addr->sa_data,
net/d80211/ieee80211_sta.c +13 -2
index 49c1b62..d9c3d67 100644
@@ -1990,7 +1990,9 @@ static int ieee80211_sta_join_ibss(struc
 		local->hw->reset_tsf(local->mdev);
 	}
 	memcpy(ifsta->bssid, bss->bssid, ETH_ALEN);
-	memcpy(local->conf.client_bssid, bss->bssid, ETH_ALEN);
+	res = ieee80211_if_config(dev);
+	if (res)
+		return res;
 
 	local->conf.beacon_int = bss->beacon_int >= 10 ? bss->beacon_int : 10;
 
@@ -2345,11 +2347,20 @@ int ieee80211_sta_set_bssid(struct net_d
 {
 	struct ieee80211_sub_if_data *sdata;
 	struct ieee80211_if_sta *ifsta;
+	int res;
 
 	sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 	ifsta = &sdata->u.sta;
 
-	memcpy(ifsta->bssid, bssid, ETH_ALEN);
+	if (memcmp(ifsta->bssid, bssid, ETH_ALEN) != 0) {
+		memcpy(ifsta->bssid, bssid, ETH_ALEN);
+		res = ieee80211_if_config(dev);
+		if (res) {
+			printk(KERN_DEBUG "%s: Failed to config new BSSID to "
+			       "the low-level driver\n", dev->name);
+			return res;
+		}
+	}
 
 	if (memcmp(bssid, "\x00\x00\x00\x00\x00\x00", ETH_ALEN) == 0)
 		ifsta->bssid_set = 0;
Signature · 1 line
1.3.0
author
#11 lore raw

PATCH 11/17 d80211: rename adm_status to radio_enabled

In reply to Jiri Benc

PRISM2_PARAM_ADM_STATUS is not much descriptive name. This patch renames it to PRISM2_PARAM_RADIO_ENABLED, sets radio_enabled to 1 by default (this is no problem as radio must not be enabled until at least one network interface is running) and removes automatic setting of adm_status when interface is in a STA mode.

Later, PRISM2_PARAM_RADIO_ENABLED value can be removed and radio_enabled set by SIOCSIWTXPOW handler (ie. by iwconfig txpower off).

---

 include/net/d80211.h         |    6 +++++-
 net/d80211/hostapd_ioctl.h   |    2 +-
 net/d80211/ieee80211.c       |    1 +
 net/d80211/ieee80211_ioctl.c |   11 +++++------
 4 files changed, 12 insertions(+), 8 deletions(-)

16a5dd7f47ba97ad3e19fe19a96a8d483dc29bbf

include/net/d80211.h +5 -1
index 84abd7c..2ec31db 100644
@@ -237,6 +237,10 @@ struct ieee80211_tx_status {
 };
 
 
+/**
+ * struct ieee80211_conf - configuration of a hardware
+ * @radio_enabled: when zero, driver is required to switch off the radio.
+ */
 struct ieee80211_conf {
 	int channel;			/* IEEE 802.11 channel number */
 	int freq;			/* MHz */
@@ -244,7 +248,7 @@ struct ieee80211_conf {
 
 	int phymode;			/* MODE_IEEE80211A, .. */
         unsigned int regulatory_domain;
-        int adm_status;
+	int radio_enabled;
 
         int beacon_int;
 
net/d80211/hostapd_ioctl.h +1 -1
index 028caf1..a462688 100644
@@ -64,7 +64,7 @@ enum {
 	PRISM2_PARAM_TEST_MODE = 1007,
 	PRISM2_PARAM_NEXT_MODE = 1008,
 	PRISM2_PARAM_CLEAR_KEYS = 1009,
-	PRISM2_PARAM_ADM_STATUS = 1010,
+	PRISM2_PARAM_RADIO_ENABLED = 1010,
 	PRISM2_PARAM_ANTENNA_SEL = 1011,
 	PRISM2_PARAM_CALIB_INT = 1012,
         PRISM2_PARAM_ANTENNA_MODE = 1013,
net/d80211/ieee80211.c +1 -0
index e6d4342..16a07d0 100644
@@ -4330,6 +4330,7 @@ struct net_device *ieee80211_alloc_hw(si
 	local->short_retry_limit = 7;
 	local->long_retry_limit = 4;
 	local->conf.calib_int = 60;
+	local->conf.radio_enabled = 1;
 	local->rate_ctrl_num_up = RATE_CONTROL_NUM_UP;
 	local->rate_ctrl_num_down = RATE_CONTROL_NUM_DOWN;
 
net/d80211/ieee80211_ioctl.c +5 -6
index 00efe47..6279a7a 100644
@@ -1166,11 +1166,11 @@ static int ieee80211_ioctl_set_regulator
 }
 
 
-static int ieee80211_ioctl_set_adm_status(struct net_device *dev,
-					  int val)
+static int ieee80211_ioctl_set_radio_enabled(struct net_device *dev,
+					     int val)
 {
         struct ieee80211_conf *conf = ieee80211_get_hw_conf(dev);
-        conf->adm_status = val;
+	conf->radio_enabled = val;
         return ieee80211_hw_config(dev);
 }
 
@@ -1580,7 +1580,6 @@ static int ieee80211_init_client(struct 
 	if (ieee80211_regdom == 0x40)
 		channel_range = ieee80211_mkk_channels;
 	ieee80211_unmask_channels(dev);
-	ieee80211_ioctl_set_adm_status(dev, 1);
 	return 0;
 }
 
@@ -2312,8 +2311,8 @@ static int ieee80211_ioctl_prism2_param(
 		ret = ieee80211_ioctl_clear_keys(dev);
 		break;
 
-	case PRISM2_PARAM_ADM_STATUS:
-                ret = ieee80211_ioctl_set_adm_status(dev, value);
+	case PRISM2_PARAM_RADIO_ENABLED:
+		ret = ieee80211_ioctl_set_radio_enabled(dev, value);
 		break;
 
 	case PRISM2_PARAM_ANTENNA_SEL:
Signature · 1 line
1.3.0
author
#12 lore raw

PATCH 12/17 d80211: interface types changeable by SIOCSIWMODE

In reply to Jiri Benc

Allow type of interface to be set by SIOCSIWMODE. All of functions responsible for adding/removing/initialization of interfaces were moved to a new file ieee80211_iface.c. Function for removing interface was split into two parts: one for deinitialization of the interface and one for deallocation of the interface. That way, it is possible to change the type of interface just by deinitializing and initializing it.

Also, remove set_mac_address callback to a driver, as it is not needed anymore (drivers are notified about MAC addresses through add_interface callback).

Please note, that although after this patch interfaces are fully independent and driver can correctly control which combination is allowed, not all multicast frames are received correctly by all respective interfaces. This is addressed by subsequent patches.

---

 include/net/d80211.h         |    3 
 net/d80211/Makefile          |    1 
 net/d80211/ieee80211.c       |  458 +++++-------------------------------------
 net/d80211/ieee80211_i.h     |   30 +--
 net/d80211/ieee80211_iface.c |  289 +++++++++++++++++++++++++++
 net/d80211/ieee80211_ioctl.c |  125 +++++++----
 net/d80211/ieee80211_sysfs.c |   12 +
 7 files changed, 435 insertions(+), 483 deletions(-)
 create mode 100644 net/d80211/ieee80211_iface.c

ef162ee22ef1564f76a9d67b8df647993806e72d

include/net/d80211.h +0 -3
index 2ec31db..6894745 100644
@@ -585,9 +585,6 @@ struct ieee80211_hw {
 	/* Configuration of test parameters */
 	int (*test_param)(struct net_device *dev, int param, int value);
 
-	/* Change MAC address. addr is pointer to struct sockaddr. */
-	int (*set_mac_address)(struct net_device *dev, void *addr);
-
         /* For devices that generate their own beacons and probe response
          * or association responses this updates the state of privacy_invoked
          * returns 0 for success or an error number */
net/d80211/Makefile +1 -0
index 59d1d65..66bfcff 100644
@@ -10,6 +10,7 @@ obj-$(CONFIG_D80211) += 80211.o rate_con
 	ieee80211_scan.o \
 	ieee80211_sta.o \
 	ieee80211_dev.o \
+	ieee80211_iface.o \
 	ieee80211_sysfs.o \
 	michael.o \
 	tkip.o \
net/d80211/ieee80211.c +51 -407

517 lines not on this page · raw message

net/d80211/ieee80211_i.h +15 -15
index 8fd0ac4..5116a88 100644
@@ -493,18 +493,8 @@ void ieee80211_rx_mgmt(struct net_device
 		       struct ieee80211_rx_status *status, u32 msg_type);
 void ieee80211_prepare_rates(struct net_device *dev);
 void ieee80211_tx_set_iswep(struct ieee80211_txrx_data *tx);
-int ieee80211_if_add_wds(struct net_device *dev, const char *name,
-			 struct ieee80211_if_wds *wds, int locked);
-int ieee80211_if_add_vlan(struct net_device *dev, const char *name,
-			  struct ieee80211_if_vlan *vlan, int locked);
-int ieee80211_if_add_ap(struct net_device *dev, const char *name, u8 *bssid,
-			int locked);
-
-int ieee80211_if_remove_wds(struct net_device *dev, const char *name, int locked);
-int ieee80211_if_remove_vlan(struct net_device *dev, const char *name, int locked);
-int ieee80211_if_remove_ap(struct net_device *dev, const char *name, int locked);
-int ieee80211_if_flush(struct net_device *dev, int locked);
 int ieee80211_if_update_wds(struct net_device *dev, u8 *remote_addr);
+void ieee80211_if_setup(struct net_device *dev);
 
 /* ieee80211_ioctl.c */
 int ieee80211_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
@@ -540,13 +530,10 @@ #define CHAN_UTIL_HDR_LONG (202 * CHAN_U
 #define CHAN_UTIL_HDR_SHORT (40 * CHAN_UTIL_PER_USEC)
 
 
-
-/* ieee80211.c */
-int ieee80211_if_add_sta(struct net_device *dev, const char *name, int locked);
-int ieee80211_if_remove_sta(struct net_device *dev, const char *name, int locked);
 /* ieee80211_ioctl.c */
 int ieee80211_set_compression(struct ieee80211_local *local,
 			      struct net_device *dev, struct sta_info *sta);
+int ieee80211_init_client(struct net_device *dev);
 /* ieee80211_sta.c */
 void ieee80211_sta_timer(unsigned long ptr);
 void ieee80211_sta_rx_mgmt(struct net_device *dev, struct sk_buff *skb,
@@ -573,6 +560,19 @@ void ieee80211_dev_free_index(struct iee
 struct ieee80211_local *ieee80211_dev_find(int index);
 int ieee80211_dev_find_index(struct ieee80211_local *local);
 
+/* ieee80211_iface.c */
+int ieee80211_if_add(struct net_device *dev, const char *name,
+		     struct net_device **new_dev);
+void ieee80211_if_set_type(struct net_device *dev, int type);
+void ieee80211_if_reinit(struct net_device *dev);
+void __ieee80211_if_del(struct ieee80211_local *local,
+			struct ieee80211_sub_if_data *sdata);
+void ieee80211_if_del(struct net_device *dev);
+int ieee80211_if_remove(struct net_device *dev, const char *name, int id);
+void ieee80211_if_free(struct net_device *dev);
+void ieee80211_if_flush(struct net_device *dev);
+void ieee80211_if_sdata_init(struct ieee80211_sub_if_data *sdata);
+
 /* ieee80211_sysfs.c */
 int ieee80211_register_sysfs(struct ieee80211_local *local);
 void ieee80211_unregister_sysfs(struct ieee80211_local *local);
net/d80211/ieee80211_iface.c new file +289 -0

289 lines not on this page · raw message

net/d80211/ieee80211_ioctl.c +72 -53

183 lines not on this page · raw message

net/d80211/ieee80211_sysfs.c +7 -5
index 082404f..546e2b7 100644
@@ -22,17 +22,17 @@ static ssize_t store_add_iface(struct cl
 			       const char *buf, size_t len)
 {
 	struct ieee80211_local *local = to_ieee80211_local(dev);
+	struct net_device *new_dev;
 	int res;
 
 	if (!capable(CAP_NET_ADMIN))
 		return -EPERM;
 	if (len > IFNAMSIZ)
 		return -EINVAL;
-	/* Cannot call ieee80211_if_add_sta() with 'locked' parameter equal
-	 * to zero as it would lead to call to register_netdev() and
-	 * interpreting '%d' character in an interface name. */
 	rtnl_lock();
-	res = ieee80211_if_add_sta(local->mdev, buf, 1);
+	res = ieee80211_if_add(local->mdev, buf, &new_dev);
+	if (res == 0)
+		ieee80211_if_set_type(new_dev, IEEE80211_IF_TYPE_STA);
 	rtnl_unlock();
 	return res < 0 ? res : len;
 }
@@ -47,7 +47,9 @@ static ssize_t store_remove_iface(struct
 		return -EPERM;
 	if (len > IFNAMSIZ)
 		return -EINVAL;
-	res = ieee80211_if_remove_sta(local->mdev, buf, 0);
+	rtnl_lock();
+	res = ieee80211_if_remove(local->mdev, buf, -1);
+	rtnl_unlock();
 	return res < 0 ? res : len;
 }
 
Signature · 1 line
1.3.0
author
#13 lore raw

PATCH 13/17 d80211: master interface auto up/down

In reply to Jiri Benc

There is no reason to put master interface to UP/DOWN state manually.

Calling of hw->open and hw->stop callbacks logically belongs to ieee80211_master_open and ieee80211_master_stop functions, but then we need to refuse putting master interface to UP state when there is no other interface running, and similarly, to refuse putting master interface DOWN when there are other interfaces running. Because the second is not possible, hw->open and hw->stop need to be called from ieee80211_open/ieee80211_stop.

---

 net/d80211/ieee80211.c |   57 +++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 44 insertions(+), 13 deletions(-)

e5df634b3ae1c945076820434d8dcf897c0eb574

net/d80211/ieee80211.c +44 -13
index c20cb00..ea71b6c 100644
@@ -1829,10 +1829,38 @@ static inline int identical_mac_addr_all
 		  type2 == IEEE80211_IF_TYPE_AP)));
 }
 
+static int ieee80211_master_open(struct net_device *dev)
+{
+	struct ieee80211_local *local = dev->priv;
+	struct ieee80211_sub_if_data *sdata;
+	int res = -EOPNOTSUPP;
+
+	list_for_each_entry(sdata, &local->sub_if_list, list) {
+		if (sdata->dev != dev && netif_running(sdata->dev)) {
+			res = 0;
+			break;
+		}
+	}
+	return res;
+}
+
+static int ieee80211_master_stop(struct net_device *dev)
+{
+	struct ieee80211_local *local = dev->priv;
+	struct ieee80211_sub_if_data *sdata;
+
+	list_for_each_entry(sdata, &local->sub_if_list, list) {
+		if (sdata->dev != dev && netif_running(sdata->dev))
+			return -EOPNOTSUPP;
+	}
+	return 0;
+}
+
 static int ieee80211_open(struct net_device *dev)
 {
 	struct ieee80211_sub_if_data *sdata, *nsdata;
 	struct ieee80211_local *local = dev->priv;
+	struct ieee80211_if_init_conf conf;
 	int res;
 
 	sdata = IEEE80211_DEV_TO_SUB_IF(dev);
@@ -1852,8 +1880,6 @@ static int ieee80211_open(struct net_dev
 		return -ENOLINK;
 
 	if (local->hw->add_interface) {
-		struct ieee80211_if_init_conf conf;
-
 		conf.if_id = dev->ifindex;
 		conf.type = sdata->type;
 		conf.mac_addr = dev->dev_addr;
@@ -1868,10 +1894,18 @@ static int ieee80211_open(struct net_dev
 	}
 
         if (local->open_count == 0) {
-		if (local->hw->open) {
+		res = 0;
+		if (local->hw->open)
 			res = local->hw->open(sdata->master);
-			if (res)
-				return res;
+		if (res == 0) {
+			res = dev_open(sdata->master);
+			if (res && local->hw->stop)
+				local->hw->stop(sdata->master);
+		}
+		if (res) {
+			if (local->hw->remove_interface)
+				local->hw->remove_interface(dev, &conf);
+			return res;
 		}
 		ieee80211_init_scan(sdata->master);
 	}
@@ -1886,7 +1920,6 @@ static int ieee80211_stop(struct net_dev
 {
 	struct ieee80211_sub_if_data *sdata;
 	struct ieee80211_local *local = dev->priv;
-	int res;
 
 	sdata = IEEE80211_DEV_TO_SUB_IF(dev);
 
@@ -1895,11 +1928,9 @@ static int ieee80211_stop(struct net_dev
 	local->open_count--;
         if (local->open_count == 0) {
 		ieee80211_stop_scan(sdata->master);
-		if (local->hw->stop) {
-			res = local->hw->stop(sdata->master);
-			if (res)
-				return res;
-		}
+		dev_close(sdata->master);
+		if (local->hw->stop)
+			local->hw->stop(sdata->master);
         }
 	if (local->hw->remove_interface) {
 		struct ieee80211_if_init_conf conf;
@@ -4035,8 +4066,8 @@ struct net_device *ieee80211_alloc_hw(si
 	mdev->change_mtu = ieee80211_change_mtu;
         mdev->tx_timeout = ieee80211_tx_timeout;
         mdev->get_stats = ieee80211_get_stats;
-        mdev->open = ieee80211_open;
-	mdev->stop = ieee80211_stop;
+	mdev->open = ieee80211_master_open;
+	mdev->stop = ieee80211_master_stop;
 	mdev->type = ARPHRD_IEEE80211;
         mdev->hard_header_parse = header_parse_80211;
 	sprintf(mdev->name, "%s.11", dev->name);
Signature · 1 line
1.3.0
author
#14 lore raw

PATCH 14/17 d80211: set_multicast_list

In reply to Jiri Benc

Add set_multicast_list callback. The version of set_multicast_list in struct net_device cannot be used by a driver, because the driver is interested in cumulative flags and cumulative multicast list from all interfaces.

---

 include/net/d80211.h         |   24 ++++++++++++++
 net/d80211/ieee80211.c       |   71 ++++++++++++++++++++++++++++++++++++++++++
 net/d80211/ieee80211_i.h     |    8 +++++
 net/d80211/ieee80211_iface.c |    1 +
 4 files changed, 104 insertions(+), 0 deletions(-)

9ada6736d81619ac81ea1ce283f47c365fe3b24f

include/net/d80211.h +24 -0
index 6894745..7bc66b5 100644
@@ -532,6 +532,13 @@ struct ieee80211_hw {
 	int (*config_interface)(struct net_device *dev, int if_id,
 				struct ieee80211_if_conf *conf);
 
+	/* ieee80211 drivers should use this and not the function in
+	 * net_device. dev->flags, dev->mc_count and dev->mc_list must not
+	 * be used; use passed parameters and ieee80211_get_mc_list_item()
+	 * instead. */
+	void (*set_multicast_list)(struct net_device *dev,
+				   unsigned short flags, int mc_count);
+
 	/* Set TIM bit handler. If the hardware/firmware takes care of beacon
 	 * generation, IEEE 802.11 code uses this function to tell the
 	 * low-level to set (or clear if set==0) TIM bit for the given aid. If
@@ -775,6 +782,23 @@ typedef enum {
 } Netif_Oper;
 int ieee80211_netif_oper(struct net_device *dev, Netif_Oper op);
 
+/**
+ * ieee80211_get_mc_list_item - iteration over items in multicast list
+ * @dev: pointer to &struct net_device as obtained from
+ *	ieee80211_alloc_hw().
+ * @prev: value returned by previous call to ieee80211_get_mc_list_item() or
+ *	NULL to start a new iteration.
+ * @ptr: pointer to buffer of void * type for internal usage of
+ *	ieee80211_get_mc_list_item().
+ *
+ * Iterates over items in multicast list of given device. To get the first
+ * item, pass NULL in @prev and in *@ptr. In subsequent calls, pass the
+ * value returned by previous call in @prev. Don't alter *@ptr during
+ * iteration. When there are no more items, NULL is returned.
+ */
+struct dev_mc_list *ieee80211_get_mc_list_item(struct net_device *dev,
+					       struct dev_mc_list *prev,
+					       void **ptr);
 
 /*
  * Function to get hardware configuration information
net/d80211/ieee80211.c +71 -0

89 lines not on this page · raw message

net/d80211/ieee80211_i.h +8 -0
index 5116a88..37d533d 100644
@@ -264,6 +264,10 @@ struct ieee80211_sub_if_data {
         struct net_device *master;
         struct ieee80211_local *local;
 
+	int mc_count;
+	unsigned allmulti:1;
+	unsigned promisc:1;
+
         struct net_device_stats stats;
 	int drop_unencrypted;
 	int eapol; /* 0 = process EAPOL frames as normal data frames,
@@ -327,6 +331,10 @@ #define IEEE80211_IRQSAFE_QUEUE_LIMIT 12
 	struct sta_info *sta_hash[STA_HASH_SIZE];
 	struct timer_list sta_cleanup;
 
+	int mc_count;	/* total count of multicast entries in all interfaces */
+	int iff_allmultis, iff_promiscs;
+			/* number of interfaces with corresponding IFF_ flags */
+
 	/* Current rate table. This is a pointer to hw->modes structure. */
 	struct ieee80211_rate *curr_rates;
 	int num_curr_rates;
net/d80211/ieee80211_iface.c +1 -0
index 917428e..2151bd9 100644
@@ -62,6 +62,7 @@ int ieee80211_if_add(struct net_device *
 	ndev->irq = dev->irq;
 	ndev->mem_start = dev->mem_start;
 	ndev->mem_end = dev->mem_end;
+	ndev->flags = dev->flags & IFF_MULTICAST;
 	ieee80211_if_setup(ndev);
 
 	sdata = IEEE80211_DEV_TO_SUB_IF(ndev);
Signature · 1 line
1.3.0
author
#15 lore raw

PATCH 15/17 d80211: fix handling of received frames

In reply to Jiri Benc

Make sure that every frame reaches every interface it belongs to. Previously, some packet (most notably multicast ones) were not delivered to all interface they should be delivered to. This also allows monitor interfaces to work easily, even together with regular interfaces.

On a typical setup (i.e. one or two interfaces only) this patch shouldn't have significant impact on performance. However, on a setup with great number of interfaces, things will probably slow down. This is not a problem with design of this patch - things can be relatively easily sped up later. See related comment in 'd80211: remove obsolete stuff' patch.

---

 net/d80211/ieee80211.c |  338 +++++++++++++++++-------------------------------
 1 files changed, 121 insertions(+), 217 deletions(-)

5aa4f5e0b7654f03d39977ac1212356d6b6f3fa7

net/d80211/ieee80211.c +121 -217
index fbca700..e2a42af 100644
@@ -2020,73 +2020,10 @@ static int header_parse_80211(struct sk_
 	return ETH_ALEN;
 }
 
-
-static struct net_device *
-ieee80211_get_wds_dev(struct ieee80211_local *local, u8 *addr)
+static inline int ieee80211_bssid_match(u8 *raddr, u8 *addr)
 {
-	struct list_head *ptr;
-
-	list_for_each(ptr, &local->sub_if_list)	{
-		struct ieee80211_sub_if_data *sdata =
-			list_entry(ptr, struct ieee80211_sub_if_data, list);
-		if (sdata->type == IEEE80211_IF_TYPE_WDS &&
-		    memcmp(addr, sdata->u.wds.remote_addr, ETH_ALEN) == 0)
-			return sdata->dev;
-	}
-
-	return NULL;
-}
-
-
-static struct net_device * ieee80211_own_bssid(struct ieee80211_local *local,
-					       u8 *addr)
-{
-	struct net_device *dev = NULL;
-	struct ieee80211_sub_if_data *sdata;
-
-	spin_lock_bh(&local->sub_if_lock);
-	list_for_each_entry(sdata, &local->sub_if_list, list) {
-		if (sdata->type == IEEE80211_IF_TYPE_AP &&
-		    memcmp(addr, sdata->dev->dev_addr, ETH_ALEN) == 0) {
-			dev = sdata->dev;
-			break;
-		}
-	}
-	spin_unlock_bh(&local->sub_if_lock);
-
-	return dev;
-}
-
-
-static struct net_device * ieee80211_sta_bssid(struct ieee80211_local *local,
-					       u8 *addr, u8 *a1,
-					       int *sta_multicast)
-{
-	struct list_head *ptr;
-	int multicast;
-
-	multicast = a1[0] & 0x01;
-
-	/* Could not find station interface, resort to O(n) lookup. */
-	list_for_each(ptr, &local->sub_if_list) {
-		struct ieee80211_sub_if_data *sdata =
-			list_entry(ptr, struct ieee80211_sub_if_data, list);
-		if (sdata->type != IEEE80211_IF_TYPE_STA &&
-		    sdata->type != IEEE80211_IF_TYPE_IBSS)
-			continue;
-		if (!multicast &&
-		    memcmp(a1, sdata->dev->dev_addr, ETH_ALEN) != 0)
-			continue;
-
-		if (memcmp(addr, sdata->u.sta.bssid, ETH_ALEN) == 0 ||
-		    (memcmp(addr, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) == 0 &&
-		     sdata->type == IEEE80211_IF_TYPE_IBSS)) {
-			*sta_multicast = multicast;
-			return sdata->dev;
-		}
-	}
-
-	return NULL;
+	return memcmp(raddr, addr, ETH_ALEN) == 0 ||
+	       is_broadcast_ether_addr(raddr);
 }
 
 
@@ -2128,8 +2065,7 @@ ieee80211_rx_h_data(struct ieee80211_txr
 		memcpy(dst, hdr->addr3, ETH_ALEN);
 		memcpy(src, hdr->addr2, ETH_ALEN);
 
-		if (unlikely(sdata->type != IEEE80211_IF_TYPE_AP ||
-			     !ieee80211_own_bssid(local, hdr->addr1))) {
+		if (unlikely(sdata->type != IEEE80211_IF_TYPE_AP)) {
 			printk(KERN_DEBUG "%s: dropped ToDS frame (BSSID="
 			       MACSTR " SA=" MACSTR " DA=" MACSTR ")\n",
 			       dev->name, MAC2STR(hdr->addr1),
@@ -2142,8 +2078,7 @@ ieee80211_rx_h_data(struct ieee80211_txr
 		memcpy(dst, hdr->addr3, ETH_ALEN);
 		memcpy(src, hdr->addr4, ETH_ALEN);
 
-		dev = ieee80211_get_wds_dev(local, hdr->addr2);
-		if (!dev || memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN) != 0) {
+		if (unlikely(sdata->type != IEEE80211_IF_TYPE_WDS)) {
 			printk(KERN_DEBUG "%s: dropped FromDS&ToDS frame (RA="
 			       MACSTR " TA=" MACSTR " DA=" MACSTR " SA="
 			       MACSTR ")\n",
@@ -2158,9 +2093,7 @@ ieee80211_rx_h_data(struct ieee80211_txr
 		memcpy(dst, hdr->addr1, ETH_ALEN);
 		memcpy(src, hdr->addr3, ETH_ALEN);
 
-		if (sdata->type != IEEE80211_IF_TYPE_STA ||
-		    memcmp(hdr->addr3, dev->dev_addr, ETH_ALEN) == 0 ||
-		    memcmp(hdr->addr2, sdata->u.sta.bssid, ETH_ALEN) != 0) {
+		if (sdata->type != IEEE80211_IF_TYPE_STA) {
 			return TXRX_DROP;
 		}
 		break;
@@ -2169,8 +2102,7 @@ ieee80211_rx_h_data(struct ieee80211_txr
 		memcpy(dst, hdr->addr1, ETH_ALEN);
 		memcpy(src, hdr->addr2, ETH_ALEN);
 
-		if (sdata->type != IEEE80211_IF_TYPE_IBSS ||
-		    memcmp(hdr->addr3, sdata->u.sta.bssid, ETH_ALEN) != 0) {
+		if (sdata->type != IEEE80211_IF_TYPE_IBSS) {
 			if (net_ratelimit()) {
 				printk(KERN_DEBUG "%s: dropped IBSS frame (DA="
 				       MACSTR " SA=" MACSTR " BSSID=" MACSTR
@@ -2802,12 +2734,15 @@ ieee80211_rx_h_check(struct ieee80211_tx
 		return TXRX_DROP;
 	}
 
-	/* Filter out foreign unicast packets when in promiscuous mode.
-	 * FIX: Filter out multicast to foreign BSSID. */
-	if (rx->sdata->type == IEEE80211_IF_TYPE_STA &&
-	    !MULTICAST_ADDR(hdr->addr1) &&
-	    memcmp(rx->dev->dev_addr, hdr->addr1, ETH_ALEN) != 0)
-		return TXRX_DROP;
+	if (memcmp(rx->dev->dev_addr, hdr->addr1, ETH_ALEN) == 0)
+		rx->skb->pkt_type = PACKET_HOST;
+	else if (is_multicast_ether_addr(hdr->addr1)) {
+		if (is_broadcast_ether_addr(hdr->addr1))
+			rx->skb->pkt_type = PACKET_BROADCAST;
+		else
+			rx->skb->pkt_type = PACKET_MULTICAST;
+	} else
+		rx->skb->pkt_type = PACKET_OTHERHOST;
 
 	/* Drop disallowed frame classes based on STA auth/assoc state;
 	 * IEEE 802.11, Chap 5.5.
@@ -2840,17 +2775,6 @@ ieee80211_rx_h_check(struct ieee80211_tx
 	if (rx->sta && rx->sta->key && always_sta_key) {
 		rx->key = rx->sta->key;
         } else {
-		if (!rx->sdata) {
-			printk(KERN_DEBUG "%s: sdata was null in packet!!\n",
-			       rx->dev->name);
-			printk(KERN_DEBUG "%s: Addr1: " MACSTR "\n",
-			       rx->dev->name, MAC2STR(hdr->addr1));
-			printk(KERN_DEBUG "%s: Addr2: " MACSTR "\n",
-			       rx->dev->name, MAC2STR(hdr->addr2));
-			printk(KERN_DEBUG "%s: Addr3: " MACSTR "\n",
-			       rx->dev->name, MAC2STR(hdr->addr3));
-			return TXRX_DROP;
-		}
 		if (rx->sta && rx->sta->key)
 			rx->key = rx->sta->key;
 		else
@@ -3158,41 +3082,6 @@ static u8 * ieee80211_get_bssid(struct i
 	return NULL;
 }
 
-
-static struct net_device * ieee80211_get_rx_dev(struct ieee80211_local *local,
-						struct ieee80211_hdr *hdr,
-						size_t len, int *sta_broadcast)
-{
-	u8 *bssid;
-	struct net_device *dev;
-	u16 fc;
-
-	bssid = ieee80211_get_bssid(hdr, len);
-	if (bssid) {
-		dev = ieee80211_own_bssid(local, bssid);
-		if (!dev)
-			dev = ieee80211_sta_bssid(local, bssid, hdr->addr1,
-						  sta_broadcast);
-		if (dev)
-			return dev;
-	}
-
-	if (len >= 30) {
-		fc = le16_to_cpu(hdr->frame_control);
-		if (WLAN_FC_GET_TYPE(fc) == WLAN_FC_TYPE_DATA &&
-		    (fc & (WLAN_FC_TODS | WLAN_FC_FROMDS)) ==
-		    (WLAN_FC_TODS | WLAN_FC_FROMDS)) {
-			dev = ieee80211_get_wds_dev(local, hdr->addr2);
-			if (dev)
-				return dev;
-		}
-	}
-
-	/* Default to default device if nothing else matches */
-	return local->wdev;
-}
-
-
 static void ieee80211_rx_michael_mic_report(struct net_device *dev,
 					    struct ieee80211_hdr *hdr,
 					    struct sta_info *sta,
@@ -3283,63 +3172,31 @@ static void ieee80211_rx_michael_mic_rep
 	rx->skb = NULL;
 }
 
-
-static void ieee80211_sta_rx_broadcast(struct ieee80211_txrx_data *rx)
+static inline void ieee80211_invoke_rx_handlers(struct ieee80211_local *local,
+						struct ieee80211_txrx_data *rx,
+						struct sta_info *sta)
 {
-	struct ieee80211_local *local = rx->dev->priv;
-	u8 *_bssid, bssid[ETH_ALEN];
-	struct sk_buff *orig_skb = rx->skb, *skb;
-	struct ieee80211_hdr *hdr;
 	ieee80211_rx_handler *handler;
-	ieee80211_txrx_result res;
-	struct list_head *ptr;
-
-	hdr = (struct ieee80211_hdr *) orig_skb->data;
-	_bssid = ieee80211_get_bssid(hdr, orig_skb->len);
-	if (_bssid == NULL) {
-		dev_kfree_skb(orig_skb);
-		return;
-	}
-	memcpy(bssid, _bssid, ETH_ALEN);
-
-	list_for_each(ptr, &local->sub_if_list) {
-		struct ieee80211_sub_if_data *sdata =
-			list_entry(ptr, struct ieee80211_sub_if_data, list);
-		if (sdata->type != IEEE80211_IF_TYPE_STA ||
-		    (memcmp(bssid, sdata->u.sta.bssid, ETH_ALEN) != 0 &&
-		     !(bssid[0] & 0x01)))
-			continue;
+        ieee80211_txrx_result res = TXRX_DROP;
 
-		skb = skb_copy(orig_skb, GFP_ATOMIC);
-		if (skb == NULL) {
-			if (net_ratelimit()) {
-				printk(KERN_DEBUG "%s: failed to copy "
-				       "multicast frame for %s",
-				       rx->dev->name, sdata->dev->name);
+	for (handler = local->rx_handlers; *handler != NULL; handler++) {
+		res = (*handler)(rx);
+		if (res != TXRX_CONTINUE) {
+			if (res == TXRX_DROP) {
+				I802_DEBUG_INC(local->rx_handlers_drop);
+				if (sta)
+					sta->rx_dropped++;
 			}
-			continue;
-		}
-
-		hdr = (struct ieee80211_hdr *) skb->data;
-		rx->skb = skb;
-		rx->dev = sdata->dev;
-		rx->sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev);
-
-		res = TXRX_DROP;
-		for (handler = local->rx_handlers; *handler != NULL; handler++)
-		{
-			res = (*handler)(rx);
-			if (res == TXRX_DROP || res == TXRX_QUEUED)
-				break;
+			if (res == TXRX_QUEUED)
+				I802_DEBUG_INC(local->rx_handlers_queued);
+			break;
 		}
-
-		if (res == TXRX_DROP || *handler == NULL)
-			dev_kfree_skb(skb);
 	}
 
-	dev_kfree_skb(orig_skb);
-}
 
+	if (res == TXRX_DROP || *handler == NULL)
+		dev_kfree_skb(rx->skb);
+}
 
 /*
  * This is the receive path handler. It is called by a low level driver when an
@@ -3349,71 +3206,118 @@ void __ieee80211_rx(struct net_device *d
 		    struct ieee80211_rx_status *status)
 {
 	struct ieee80211_local *local = dev->priv;
+	struct ieee80211_sub_if_data *sdata;
 	struct sta_info *sta;
 	struct ieee80211_hdr *hdr;
-	ieee80211_rx_handler *handler;
 	struct ieee80211_txrx_data rx;
-        ieee80211_txrx_result res = TXRX_DROP;
 	u16 type;
-	int sta_broadcast = 0;
+	int multicast;
 
 	hdr = (struct ieee80211_hdr *) skb->data;
 	memset(&rx, 0, sizeof(rx));
 	rx.skb = skb;
 	rx.local = local;
-	if (skb->len >= 16)
-		sta = rx.sta = sta_info_get(local, hdr->addr2);
-	else
-		sta = rx.sta = NULL;
-	if (sta && !sta->assoc_ap && !(sta->flags & WLAN_STA_WDS)) {
-		rx.dev = sta->dev;
-		rx.sdata = IEEE80211_DEV_TO_SUB_IF(rx.dev);
-	} else {
-		rx.dev = ieee80211_get_rx_dev(local, hdr, skb->len,
-					      &sta_broadcast);
-		rx.sdata = IEEE80211_DEV_TO_SUB_IF(rx.dev);
-		if (sta == NULL &&
-		    rx.sdata->type == IEEE80211_IF_TYPE_IBSS) {
-			u8 *bssid = ieee80211_get_bssid(hdr, skb->len);
-			if (bssid)
-				sta = rx.sta =
-					ieee80211_ibss_add_sta(dev, skb, bssid,
-							       hdr->addr2);
-		}
-	}
 
 	rx.u.rx.status = status;
 	rx.fc = skb->len >= 2 ? le16_to_cpu(hdr->frame_control) : 0;
 	type = WLAN_FC_GET_TYPE(rx.fc);
 	if (type == WLAN_FC_TYPE_DATA || type == WLAN_FC_TYPE_MGMT)
 		local->dot11ReceivedFragmentCount++;
-	if (sta_broadcast) {
-		ieee80211_sta_rx_broadcast(&rx);
-		goto end;
-	}
+	multicast = is_multicast_ether_addr(hdr->addr1);
+
+	if (skb->len >= 16)
+		sta = rx.sta = sta_info_get(local, hdr->addr2);
+	else
+		sta = rx.sta = NULL;
 
         if ((status->flag & RX_FLAG_MMIC_ERROR)) {
 		ieee80211_rx_michael_mic_report(dev, hdr, sta, &rx);
 		goto end;
         }
 
-	for (handler = local->rx_handlers; *handler != NULL; handler++) {
-		res = (*handler)(&rx);
-		if (res != TXRX_CONTINUE) {
-			if (res == TXRX_DROP) {
-				I802_DEBUG_INC(local->rx_handlers_drop);
-				if (sta)
-					sta->rx_dropped++;
+	if (sta && !sta->assoc_ap && !(sta->flags & WLAN_STA_WDS) &&
+	    !local->iff_promiscs && !multicast) {
+		rx.dev = sta->dev;
+		rx.sdata = IEEE80211_DEV_TO_SUB_IF(rx.dev);
+		ieee80211_invoke_rx_handlers(local, &rx, sta);
+	} else {
+		struct ieee80211_sub_if_data *prev = NULL;
+		struct sk_buff *skb_new;
+		u8 *bssid = ieee80211_get_bssid(hdr, skb->len);
+
+		list_for_each_entry(sdata, &local->sub_if_list, list) {
+			switch (sdata->type) {
+			case IEEE80211_IF_TYPE_STA:
+				if (!bssid || memcmp(sdata->u.sta.bssid,
+						     bssid, ETH_ALEN) != 0)
+					continue;
+				if (!multicast && !sdata->promisc &&
+				    memcmp(sdata->dev->dev_addr, hdr->addr1,
+					   ETH_ALEN) != 0)
+					continue;
+				break;
+			case IEEE80211_IF_TYPE_IBSS:
+				if (!bssid ||
+				    !ieee80211_bssid_match(bssid,
+							   sdata->u.sta.bssid))
+					continue;
+				if (!multicast && !sdata->promisc &&
+				    memcmp(sdata->dev->dev_addr, hdr->addr1,
+					   ETH_ALEN) != 0)
+					continue;
+				if (sta == NULL) {
+					sta = rx.sta =
+						ieee80211_ibss_add_sta(dev, skb, bssid,
+								       hdr->addr2);
+						/* FIXME: call with sdata->dev */
+				}
+				break;
+			case IEEE80211_IF_TYPE_AP:
+				if (!bssid) {
+					if (memcmp(sdata->dev->dev_addr,
+						   hdr->addr1, ETH_ALEN) != 0)
+						continue;
+				} else if (!local->sta_scanning &&
+					   !local->scan.in_scan &&
+					   !ieee80211_bssid_match(bssid,
+							sdata->dev->dev_addr))
+					continue;
+				break;
+			case IEEE80211_IF_TYPE_WDS:
+				if (bssid ||
+				    WLAN_FC_GET_TYPE(rx.fc) != WLAN_FC_TYPE_DATA)
+					continue;
+				if (memcmp(sdata->u.wds.remote_addr,
+					   hdr->addr2, ETH_ALEN) != 0)
+					continue;
+				break;
 			}
-			if (res == TXRX_QUEUED)
-				I802_DEBUG_INC(local->rx_handlers_queued);
-			break;
+
+			if (prev) {
+				skb_new = skb_copy(skb, GFP_ATOMIC);
+				if (skb_new == NULL) {
+					if (net_ratelimit()) {
+						printk(KERN_DEBUG "%s: failed to copy "
+						       "multicast frame for %s",
+						       dev->name, prev->dev->name);
+					}
+					continue;
+				}
+				rx.skb = skb_new;
+				rx.dev = prev->dev;
+				rx.sdata = prev;
+				ieee80211_invoke_rx_handlers(local, &rx, sta);
+			}
+			prev = sdata;
 		}
+		if (prev) {
+			rx.skb = skb;
+			rx.dev = prev->dev;
+			rx.sdata = prev;
+			ieee80211_invoke_rx_handlers(local, &rx, sta);
+		} else
+			dev_kfree_skb(skb);
 	}
-	skb = rx.skb; /* handlers are allowed to change skb */
-
-	if (res == TXRX_DROP || *handler == NULL)
-		dev_kfree_skb(skb);
 
   end:
 	if (sta)
Signature · 1 line
1.3.0
author
#16 lore raw

PATCH 16/17 d80211: fix monitor interfaces

In reply to Jiri Benc

This patch allows monitor interfaces to be set by SIOCSIWMODE and to receive frames.

Also, "soft" and "hard" monitor modes are introduced.

---

 include/net/d80211.h         |   10 ++++++
 net/d80211/ieee80211.c       |   67 ++++++++++++++++++++++++++++++++++++++++--
 net/d80211/ieee80211_i.h     |    1 +
 net/d80211/ieee80211_iface.c |    7 ++++
 4 files changed, 81 insertions(+), 4 deletions(-)

738241025b5e0091237d8c9d809d9affbdfaee29

include/net/d80211.h +9 -1
index 7bc66b5..23bcbfa 100644
@@ -330,6 +330,8 @@ enum ieee80211_if_types {
  * @if_id: internal interface ID. This number has no particular meaning to
  *	drivers and the only allowed usage is to pass it to
  *	ieee80211_beacon_get() and ieee80211_get_buffered_bc() functions.
+ *	This field is not valid for monitor interfaces
+ *	(interfaces of %IEEE80211_IF_TYPE_MNTR type).
  * @type: one of &enum ieee80211_if_types constants. Determines the type of
  *	added/removed interface.
  * @mac_addr: pointer to MAC address of the interface. This pointer is valid
@@ -476,6 +478,10 @@ struct ieee80211_hw {
 	 */
 	unsigned int device_strips_mic:1;
 
+	/* Device is capable of performing full monitor mode even during
+	 * normal operation. */
+	unsigned int monitor_during_oper:1;
+
 	/* 1 = low-level driver supports skb fraglist (NETIF_F_FRAGLIST), i.e.,
 	 * more than one skb per frame */
 	unsigned int fraglist;
@@ -511,7 +517,9 @@ struct ieee80211_hw {
 	 * more exactly, set UP). If the handler returns zero, the interface
 	 * is added. Driver should perform any initialization it needs prior
 	 * to returning zero. By returning non-zero, adding of the interface
-	 * is not permitted. The open() handler is called after
+	 * is not permitted. Unless monitor_during_oper is set, it is
+	 * guaranteed that monitor interfaces and normal interfaces are
+	 * mutually exclusive. The open() handler is called after
 	 * add_interface() if this is the first device added. At least one
 	 * of open() and add_interface() handler has to be non-NULL. If
 	 * add_interface() is NULL, one STA interface is permitted only. */
net/d80211/ieee80211.c +64 -3

117 lines not on this page · raw message

net/d80211/ieee80211_i.h +1 -0
index 37d533d..2dbb132 100644
@@ -305,6 +305,7 @@ struct ieee80211_local {
         struct net_device *wdev; /* wlan# - default Ethernet (data) devide */
 	struct net_device *apdev; /* wlan#ap - management frames (hostapd) */
 	int open_count;
+	int monitors;
 	struct ieee80211_conf conf;
 
 	int dev_index;
net/d80211/ieee80211_iface.c +7 -0
index 2151bd9..dd809c2 100644
@@ -8,6 +8,7 @@
  * published by the Free Software Foundation.
  */
 #include <linux/kernel.h>
+#include <linux/if_arp.h>
 #include <linux/netdevice.h>
 #include <linux/rtnetlink.h>
 #include <net/d80211.h>
@@ -124,6 +125,9 @@ void ieee80211_if_set_type(struct net_de
 		sdata->bss = &msdata->u.ap;
 		break;
 	}
+	case IEEE80211_IF_TYPE_MNTR:
+		dev->type = ARPHRD_IEEE80211_PRISM;
+		break;
 	default:
 		printk(KERN_WARNING "%s: %s: Unknown interface type 0x%x",
 		       dev->name, __FUNCTION__, type);
@@ -211,6 +215,9 @@ #endif /* CONFIG_D80211_VERBOSE_DEBUG */
 		}
 
 		break;
+	case IEEE80211_IF_TYPE_MNTR:
+		dev->type = ARPHRD_ETHER;
+		break;
 	}
 
 	/* remove all STAs that are bound to this virtual interface */
Signature · 1 line
1.3.0
maintainer
#17 lore raw

Re: [PATCH 16/17] d80211: fix monitor interfaces

Quoted 1 line · Jiri Benc

Also, "soft" and "hard" monitor modes are introduced.

What's the distinction? The code might want some comments about what that

include/net/d80211.h struct ieee80211_hw { · line 482

Quoted 2 lines
include/net/d80211.h +2 -0
+       /* Device is capable of performing full monitor mode even during
+        * normal operation. */

actually means. I suppose it means that the device will receive control frames too, but I don't know if that's right.

johannes

author
#18 lore raw

Re: [PATCH 16/17] d80211: fix monitor interfaces

Quoted 4 lines · Johannes Berg
Quoted 1 line · Jiri Benc

Also, "soft" and "hard" monitor modes are introduced.

Quoted 8 lines

What's the distinction? The code might want some comments about what that

include/net/d80211.h struct ieee80211_hw { · line 482

Quoted 2 lines
include/net/d80211.h +2 -0
+       /* Device is capable of performing full monitor mode even during
+        * normal operation. */

actually means. I suppose it means that the device will receive control frames too, but I don't know if that's right.

Some devices need to be switched to completely different mode to be able to receive all frames (including control ones) or even load another firmware. Such devices are not capable to transmit anything while in monitor mode and their drivers won't set monitor_during_oper.

Another devices are capable to receive all frames while continuing their normal operation. Driver will probably set monitor_during_oper in that case.

"Hard" monitor mode means the card is operating in a true rfmon mode - i.e. you get everything on the given channel. "Soft" monitor mode means that you will get only frames the device is willing to give you at the time - this probably means only frames belonging to your BSS in case of fullmac cards.

So, you can always do

echo -n sta0 > /sys/class/ieee80211/wiphy0/add_iface echo -n mon0 > /sys/class/ieee80211/wiphy0/add_iface iwconfig sta0 mode managed
iwconfig mon0 mode monitor
ifconfig sta0 up
ifconfig mon0 up

and this will work - independently of the value of monitor_during_oper. The difference is that in case of monitor_during_oper == 0, you won't probably receive much more frames from mon0 than from sta0. But - you will most likely receive beacons on mon0 and also monitoring headers (prism2 headers presently).

When monitor_during_oper == 1, you are able to watch all traffic on the current channel on mon0 without interrupting normal functionality.

Signature · 2 lines
Jiri Benc
SUSE Labs
maintainer
#19 lore raw

Re: [PATCH 16/17] d80211: fix monitor interfaces

Quoted 6 lines · Jiri Benc

"Hard" monitor mode means the card is operating in a true rfmon mode - i.e. you get everything on the given channel. "Soft" monitor mode means that you will get only frames the device is willing to give you at the time - this probably means only frames belonging to your BSS in case of fullmac cards.

Ok, thanks for clarifying; this description should be somewhere in the comments or so IMHO.

Quoted 5 lines

and this will work - independently of the value of monitor_during_oper. The difference is that in case of monitor_during_oper == 0, you won't probably receive much more frames from mon0 than from sta0. But - you will most likely receive beacons on mon0 and also monitoring headers (prism2 headers presently).

This I don't understand, doesn't the UI kind of suck as opposed to just putting the sta0 device into promisc mode?

johannes

author
#20 lore raw

Re: [PATCH 16/17] d80211: fix monitor interfaces

Quoted 8 lines · Johannes Berg
Quoted 5 lines

and this will work - independently of the value of monitor_during_oper. The difference is that in case of monitor_during_oper == 0, you won't probably receive much more frames from mon0 than from sta0. But - you will most likely receive beacons on mon0 and also monitoring headers (prism2 headers presently).

This I don't understand, doesn't the UI kind of suck as opposed to just putting the sta0 device into promisc mode?

In promisc mode, you receive only packets destined to your BSS, regardless of their source or destination address (so it's similar to the way promisc works with Ethernet). On monitor interface, you receive all packets regardless of BSSID.

Jiri

Signature · 2 lines
Jiri Benc
SUSE Labs
maintainer
#21 lore raw

Re: [PATCH 16/17] d80211: fix monitor interfaces

Quoted 7 lines · Jiri Benc
Quoted 6 lines · Johannes Berg
Quoted 5 lines

and this will work - independently of the value of monitor_during_oper. The difference is that in case of monitor_during_oper == 0, you won't probably receive much more frames from mon0 than from sta0. But - you will most likely receive beacons on mon0 and also monitoring headers (prism2 headers presently).

Quoted 7 lines
Quoted 2 lines

This I don't understand, doesn't the UI kind of suck as opposed to just putting the sta0 device into promisc mode?

In promisc mode, you receive only packets destined to your BSS, regardless of their source or destination address (so it's similar to the way promisc works with Ethernet). On monitor interface, you receive all packets regardless of BSSID.

Yes, but didn't you just say that when monitor_during_oper == 0 then it's equivalent to promisc mode?

johannes

author
#22 lore raw

Re: [PATCH 16/17] d80211: fix monitor interfaces

Quoted 2 lines · Johannes Berg

Yes, but didn't you just say that when monitor_during_oper == 0 then it's equivalent to promisc mode?

Not necessary. It was just an example of the worst case. In typical case, you will receive something more - probably all data and management frames but no control frames.

Jiri

Signature · 2 lines
Jiri Benc
SUSE Labs
maintainer
#23 lore raw

Re: [PATCH 16/17] d80211: fix monitor interfaces

Quoted 3 lines · Jiri Benc

Not necessary. It was just an example of the worst case. In typical case, you will receive something more - probably all data and management frames but no control frames.

Ah right, yeah makes sense then I guess. So monitor is a way of telling the driver "give me everything that you can" :)

johannes

author
#24 lore raw

PATCH 17/17 d80211: fix AP interfaces

In reply to Jiri Benc

This allows interfaces of IEEE80211_IF_TYPE_MGMT type (wlan%dap interfaces) to be put UP.

---

 net/d80211/ieee80211.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

906a789aa674216a18ad5dc13c0635bc5664b793

net/d80211/ieee80211.c +2 -0
index b199b9e..64cc66f 100644
@@ -1893,6 +1893,8 @@ static inline int identical_mac_addr_all
 {
 	return (type1 == IEEE80211_IF_TYPE_MNTR ||
 		type2 == IEEE80211_IF_TYPE_MNTR ||
+		type1 == IEEE80211_IF_TYPE_MGMT ||
+		type2 == IEEE80211_IF_TYPE_MGMT ||
 		(type1 == IEEE80211_IF_TYPE_AP &&
 		 type2 == IEEE80211_IF_TYPE_WDS) ||
 		(type1 == IEEE80211_IF_TYPE_WDS &&
Signature · 1 line
1.3.0
#25 lore raw
In reply to Jiri Benc
Quoted 1 line · you

Please note that these changes break d80211 drivers.

Can you please send your hacky patch for the bcm43xx to me, so I can come up with a clean one?
(I think you already sent it to me, but I lost it :) ) Thanks.

Signature · 1 line
Greetings Michael.
author
#26 lore raw
Quoted 2 lines · Michael Buesch

Can you please send your hacky patch for the bcm43xx to me, so I can come up with a clean one?

Sure, actually I planned to do it in a few minutes :-)

 drivers/net/wireless/bcm43xx-d80211/bcm43xx.h      |    1 
 drivers/net/wireless/bcm43xx-d80211/bcm43xx_main.c |   45 +++++++++++++++++++--
 2 files changed, 42 insertions(+), 4 deletions(-)
drivers/net/wireless/bcm43xx-d80211/bcm43xx.h +1 -0
@@ -721,6 +721,7 @@ struct bcm43xx_private {
 	/* Informational stuff. */
 	char nick[IW_ESSID_MAX_SIZE + 1];
 	u8 bssid[ETH_ALEN];
+	int interfaces;
 
 	/* encryption/decryption */
 	u16 security_offset;
drivers/net/wireless/bcm43xx-d80211/bcm43xx_main.c +41 -4

70 lines not on this page · raw message

Signature · 2 lines
Jiri Benc
SUSE Labs
#27 lore raw
Quoted 5 lines · Jiri Benc
Quoted 2 lines · Michael Buesch

Can you please send your hacky patch for the bcm43xx to me, so I can come up with a clean one?

Sure, actually I planned to do it in a few minutes :-)

Hacky or not, I'm applying this patch to keep the bcm43xx driver from breaking. I don't suppose you have a patch for the rt2x00 driver?

John

Signature · 2 lines
John W. Linville
[email protected]
#28 lore raw
Quoted 9 lines · John W. Linville
Quoted 5 lines · Jiri Benc
Quoted 2 lines · Michael Buesch

Can you please send your hacky patch for the bcm43xx to me, so I can come up with a clean one?

Sure, actually I planned to do it in a few minutes :-)

Hacky or not, I'm applying this patch to keep the bcm43xx driver from breaking. I don't suppose you have a patch for the rt2x00 driver?

Hi,

I had promised to create this patch before, but due to shortage of time hadn't managed to do so. At the moment a compatibility fix for the updates is already present in our CVS tree.
I am already working on a patch series to send for wireless-dev to bring rt2x00 up to date. The change for compatibility for the stack is update is also amongst the patches. I am still working on the final patches for the series, but will be able to send all (+/- 30 patches) tomorow.

After that I hope to send new patches for rt2x00 on a more regular basis, to prevent large patch series like this one to be send in a single day.

IvD

#29 lore raw
In reply to John W. Linville
Quoted 9 lines · John W. Linville
Quoted 5 lines · Jiri Benc
Quoted 2 lines · Michael Buesch

Can you please send your hacky patch for the bcm43xx to me, so I can come up with a clean one?

Sure, actually I planned to do it in a few minutes :-)

Hacky or not, I'm applying this patch to keep the bcm43xx driver from breaking.

That's perfectly fine.
The correct patch needs a little bit of rewriting in the "mode" code. I will do that after I finished the 4318 fixes (should take quite some time).

Signature · 1 line
Greetings Michael.
author
#30 lore raw

PATCH 1/1 bcm43xx_d80211: fix bug in open

In reply to John W. Linville
Quoted 2 lines · John W. Linville

Hacky or not, I'm applying this patch to keep the bcm43xx driver from breaking. I don't suppose you have a patch for the rt2x00 driver?

The patch for bcm43xx was really just quick fix, only partially tested...

---

 drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/d80211/bcm43xx/bcm43xx_main.c +1 -1
@@ -4172,7 +4172,7 @@ static int bcm43xx_net_open(struct net_d
 	int res;
 
 	res = bcm43xx_init_board(bcm);
-	if (!res)
+	if (res)
 		return res;
 	bcm43xx_set_iwmode(bcm, bcm->iw_mode);
 	return 0;
Signature · 2 lines
Jiri Benc
SUSE Labs