* [PATCH 1/6] mac80211: clean up eapol frame handling/port control
2007-12-19 0:31 [PATCH 0/6] mac80211 updates Johannes Berg
@ 2007-12-19 0:31 ` Johannes Berg
2007-12-19 0:31 ` [PATCH 2/6] mac80211: clean up eapol handling in TX path Johannes Berg
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Johannes Berg @ 2007-12-19 0:31 UTC (permalink / raw)
To: John Linville; +Cc: Michael Wu, linux-wireless
This cleans up the eapol frame handling and some related code in the
receive and transmit paths. After this patch
* EAPOL frames addressed to us or the EAPOL group address are
always accepted regardless of whether they are encrypted or not
* other frames from a station are dropped if PAE is enabled and
the station is not authorized
* unencrypted frames (except the EAPOL frames above) are dropped if
drop_unencrypted is enabled
* some superfluous code that eth_type_trans handles anyway is gone
* port control is done for transmitted packets
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
I've made a corresponding hostapd patch which is on my website
http://johannes.sipsolutions.net/patches/hostap/all/2007-12-12-17%3a18/005-eapol-on-regular-iface.patch
It works fine and is IMHO nicer than doing the eapol stuff over the
management interface.
net/mac80211/debugfs_netdev.c | 27 ++------
net/mac80211/ieee80211_i.h | 22 ++----
net/mac80211/ieee80211_iface.c | 1
net/mac80211/rx.c | 133 ++++++++++++++++++++---------------------
net/mac80211/tx.c | 53 ++++++++++------
5 files changed, 119 insertions(+), 117 deletions(-)
--- everything.orig/net/mac80211/ieee80211_i.h 2007-12-19 00:39:58.193026096 +0100
+++ everything/net/mac80211/ieee80211_i.h 2007-12-19 01:09:45.373023817 +0100
@@ -306,11 +306,11 @@ struct ieee80211_sub_if_data {
unsigned int flags;
int drop_unencrypted;
- int eapol; /* 0 = process EAPOL frames as normal data frames,
- * 1 = send EAPOL frames through wlan#ap to hostapd
- * (default) */
- int ieee802_1x; /* IEEE 802.1X PAE - drop packet to/from unauthorized
- * port */
+ /*
+ * IEEE 802.1X Port access control in effect,
+ * drop packets to/from unauthorized port
+ */
+ int ieee802_1x_pac;
u16 sequence;
@@ -339,8 +339,7 @@ struct ieee80211_sub_if_data {
struct {
struct dentry *channel_use;
struct dentry *drop_unencrypted;
- struct dentry *eapol;
- struct dentry *ieee8021_x;
+ struct dentry *ieee802_1x_pac;
struct dentry *state;
struct dentry *bssid;
struct dentry *prev_bssid;
@@ -359,8 +358,7 @@ struct ieee80211_sub_if_data {
struct {
struct dentry *channel_use;
struct dentry *drop_unencrypted;
- struct dentry *eapol;
- struct dentry *ieee8021_x;
+ struct dentry *ieee802_1x_pac;
struct dentry *num_sta_ps;
struct dentry *dtim_period;
struct dentry *dtim_count;
@@ -374,15 +372,13 @@ struct ieee80211_sub_if_data {
struct {
struct dentry *channel_use;
struct dentry *drop_unencrypted;
- struct dentry *eapol;
- struct dentry *ieee8021_x;
+ struct dentry *ieee802_1x_pac;
struct dentry *peer;
} wds;
struct {
struct dentry *channel_use;
struct dentry *drop_unencrypted;
- struct dentry *eapol;
- struct dentry *ieee8021_x;
+ struct dentry *ieee802_1x_pac;
} vlan;
struct {
struct dentry *mode;
--- everything.orig/net/mac80211/rx.c 2007-12-19 00:39:58.343023763 +0100
+++ everything/net/mac80211/rx.c 2007-12-19 01:09:41.173023112 +0100
@@ -206,7 +206,7 @@ ieee80211_rx_monitor(struct ieee80211_lo
rthdr->it_len = cpu_to_le16(rtap_len);
}
- skb_set_mac_header(skb, 0);
+ skb_reset_mac_header(skb);
skb->ip_summed = CHECKSUM_UNNECESSARY;
skb->pkt_type = PACKET_OTHERHOST;
skb->protocol = htons(ETH_P_802_2);
@@ -403,18 +403,6 @@ ieee80211_rx_h_check(struct ieee80211_tx
return TXRX_DROP;
}
- if (!(rx->flags & IEEE80211_TXRXD_RXRA_MATCH))
- rx->skb->pkt_type = PACKET_OTHERHOST;
- else if (compare_ether_addr(rx->dev->dev_addr, hdr->addr1) == 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.
*
@@ -983,18 +971,10 @@ ieee80211_rx_h_remove_qos_control(struct
}
static int
-ieee80211_drop_802_1x_pae(struct ieee80211_txrx_data *rx, int hdrlen)
+ieee80211_802_1x_port_control(struct ieee80211_txrx_data *rx)
{
- if (rx->sdata->eapol && ieee80211_is_eapol(rx->skb, hdrlen) &&
- rx->sdata->type != IEEE80211_IF_TYPE_STA &&
- (rx->flags & IEEE80211_TXRXD_RXRA_MATCH))
- return 0;
-
- if (unlikely(rx->sdata->ieee802_1x &&
- (rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA &&
- (rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_NULLFUNC &&
- (!rx->sta || !(rx->sta->flags & WLAN_STA_AUTHORIZED)) &&
- !ieee80211_is_eapol(rx->skb, hdrlen))) {
+ if (unlikely(rx->sdata->ieee802_1x_pac &&
+ (!rx->sta || !(rx->sta->flags & WLAN_STA_AUTHORIZED)))) {
#ifdef CONFIG_MAC80211_DEBUG
printk(KERN_DEBUG "%s: dropped frame "
"(unauthorized port)\n", rx->dev->name);
@@ -1006,7 +986,7 @@ ieee80211_drop_802_1x_pae(struct ieee802
}
static int
-ieee80211_drop_unencrypted(struct ieee80211_txrx_data *rx, int hdrlen)
+ieee80211_drop_unencrypted(struct ieee80211_txrx_data *rx)
{
/*
* Pass through unencrypted frames if the hardware has
@@ -1019,9 +999,7 @@ ieee80211_drop_unencrypted(struct ieee80
if (unlikely(!(rx->fc & IEEE80211_FCTL_PROTECTED) &&
(rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA &&
(rx->fc & IEEE80211_FCTL_STYPE) != IEEE80211_STYPE_NULLFUNC &&
- (rx->key || rx->sdata->drop_unencrypted) &&
- (rx->sdata->eapol == 0 ||
- !ieee80211_is_eapol(rx->skb, hdrlen)))) {
+ (rx->key || rx->sdata->drop_unencrypted))) {
if (net_ratelimit())
printk(KERN_DEBUG "%s: RX non-WEP frame, but expected "
"encryption\n", rx->dev->name);
@@ -1149,6 +1127,7 @@ ieee80211_data_to_8023(struct ieee80211_
} else {
struct ethhdr *ehdr;
__be16 len;
+
skb_pull(skb, hdrlen);
len = htons(skb->len);
ehdr = (struct ethhdr *) skb_push(skb, sizeof(struct ethhdr));
@@ -1159,6 +1138,34 @@ ieee80211_data_to_8023(struct ieee80211_
return 0;
}
+/*
+ * requires that rx->skb is a frame with ethernet header
+ */
+static bool ieee80211_frame_allowed(struct ieee80211_txrx_data *rx)
+{
+ static const u8 pae_group_addr[ETH_ALEN]
+ = { 0x01, 0x80, 0xC2, 0x00, 0x00, 0x03 };
+ struct ethhdr *ehdr = (struct ethhdr *) rx->skb->data;
+
+ /*
+ * Allow EAPOL frames to us/the PAE group address regardless
+ * of whether the frame was encrypted or not.
+ */
+ if (ehdr->h_proto == htons(ETH_P_PAE) &&
+ (compare_ether_addr(ehdr->h_dest, rx->dev->dev_addr) == 0 ||
+ compare_ether_addr(ehdr->h_dest, pae_group_addr) == 0))
+ return true;
+
+ if (ieee80211_802_1x_port_control(rx) ||
+ ieee80211_drop_unencrypted(rx))
+ return false;
+
+ return true;
+}
+
+/*
+ * requires that rx->skb is a frame with ethernet header
+ */
static void
ieee80211_deliver_skb(struct ieee80211_txrx_data *rx)
{
@@ -1166,31 +1173,32 @@ ieee80211_deliver_skb(struct ieee80211_t
struct ieee80211_local *local = rx->local;
struct sk_buff *skb, *xmit_skb;
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+ struct ethhdr *ehdr = (struct ethhdr *) rx->skb->data;
+ struct sta_info *dsta;
skb = rx->skb;
xmit_skb = NULL;
- if (local->bridge_packets && (sdata->type == IEEE80211_IF_TYPE_AP
- || sdata->type == IEEE80211_IF_TYPE_VLAN) &&
+ if (local->bridge_packets && (sdata->type == IEEE80211_IF_TYPE_AP ||
+ sdata->type == IEEE80211_IF_TYPE_VLAN) &&
(rx->flags & IEEE80211_TXRXD_RXRA_MATCH)) {
- if (is_multicast_ether_addr(skb->data)) {
- /* send multicast frames both to higher layers in
- * local net stack and back to the wireless media */
+ if (is_multicast_ether_addr(ehdr->h_dest)) {
+ /*
+ * send multicast frames both to higher layers in
+ * local net stack and back to the wireless medium
+ */
xmit_skb = skb_copy(skb, GFP_ATOMIC);
if (!xmit_skb && net_ratelimit())
printk(KERN_DEBUG "%s: failed to clone "
"multicast frame\n", dev->name);
} else {
- struct sta_info *dsta;
dsta = sta_info_get(local, skb->data);
- if (dsta && !dsta->dev) {
- if (net_ratelimit())
- printk(KERN_DEBUG "Station with null "
- "dev structure!\n");
- } else if (dsta && dsta->dev == dev) {
- /* Destination station is associated to this
- * AP, so send the frame directly to it and
- * do not pass the frame to local net stack.
+ if (dsta && dsta->dev == dev) {
+ /*
+ * The destination station is associated to
+ * this AP (in this VLAN), so send the frame
+ * directly to it and do not pass it to local
+ * net stack.
*/
xmit_skb = skb;
skb = NULL;
@@ -1210,8 +1218,8 @@ ieee80211_deliver_skb(struct ieee80211_t
if (xmit_skb) {
/* send to wireless media */
xmit_skb->protocol = __constant_htons(ETH_P_802_3);
- skb_set_network_header(xmit_skb, 0);
- skb_set_mac_header(xmit_skb, 0);
+ skb_reset_network_header(xmit_skb);
+ skb_reset_mac_header(xmit_skb);
dev_queue_xmit(xmit_skb);
}
}
@@ -1296,38 +1304,36 @@ ieee80211_rx_h_amsdu(struct ieee80211_tx
}
}
- skb_set_network_header(frame, 0);
+ skb_reset_network_header(frame);
frame->dev = dev;
frame->priority = skb->priority;
rx->skb = frame;
- if ((ieee80211_drop_802_1x_pae(rx, 0)) ||
- (ieee80211_drop_unencrypted(rx, 0))) {
- if (skb == frame) /* last frame */
- return TXRX_DROP;
- dev_kfree_skb(frame);
- continue;
- }
-
payload = frame->data;
ethertype = (payload[6] << 8) | payload[7];
if (likely((compare_ether_addr(payload, rfc1042_header) == 0 &&
- ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
- compare_ether_addr(payload,
- bridge_tunnel_header) == 0)) {
+ ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
+ compare_ether_addr(payload,
+ bridge_tunnel_header) == 0)) {
/* remove RFC1042 or Bridge-Tunnel
* encapsulation and replace EtherType */
skb_pull(frame, 6);
memcpy(skb_push(frame, ETH_ALEN), src, ETH_ALEN);
memcpy(skb_push(frame, ETH_ALEN), dst, ETH_ALEN);
} else {
- memcpy(skb_push(frame, sizeof(__be16)), &len,
- sizeof(__be16));
+ memcpy(skb_push(frame, sizeof(__be16)),
+ &len, sizeof(__be16));
memcpy(skb_push(frame, ETH_ALEN), src, ETH_ALEN);
memcpy(skb_push(frame, ETH_ALEN), dst, ETH_ALEN);
}
+ if (!ieee80211_frame_allowed(rx)) {
+ if (skb == frame) /* last frame */
+ return TXRX_DROP;
+ dev_kfree_skb(frame);
+ continue;
+ }
ieee80211_deliver_skb(rx);
}
@@ -1340,7 +1346,7 @@ ieee80211_rx_h_data(struct ieee80211_txr
{
struct net_device *dev = rx->dev;
u16 fc;
- int err, hdrlen;
+ int err;
fc = rx->fc;
if (unlikely((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA))
@@ -1349,16 +1355,13 @@ ieee80211_rx_h_data(struct ieee80211_txr
if (unlikely(!WLAN_FC_DATA_PRESENT(fc)))
return TXRX_DROP;
- hdrlen = ieee80211_get_hdrlen(fc);
-
- if ((ieee80211_drop_802_1x_pae(rx, hdrlen)) ||
- (ieee80211_drop_unencrypted(rx, hdrlen)))
- return TXRX_DROP;
-
err = ieee80211_data_to_8023(rx);
if (unlikely(err))
return TXRX_DROP;
+ if (!ieee80211_frame_allowed(rx))
+ return TXRX_DROP;
+
rx->skb->dev = dev;
dev->stats.rx_packets++;
--- everything.orig/net/mac80211/debugfs_netdev.c 2007-12-19 00:39:58.463023654 +0100
+++ everything/net/mac80211/debugfs_netdev.c 2007-12-19 01:09:40.833031141 +0100
@@ -91,8 +91,7 @@ static const struct file_operations name
/* common attributes */
IEEE80211_IF_FILE(channel_use, channel_use, DEC);
IEEE80211_IF_FILE(drop_unencrypted, drop_unencrypted, DEC);
-IEEE80211_IF_FILE(eapol, eapol, DEC);
-IEEE80211_IF_FILE(ieee8021_x, ieee802_1x, DEC);
+IEEE80211_IF_FILE(ieee802_1x_pac, ieee802_1x_pac, DEC);
/* STA/IBSS attributes */
IEEE80211_IF_FILE(state, u.sta.state, DEC);
@@ -170,8 +169,7 @@ static void add_sta_files(struct ieee802
{
DEBUGFS_ADD(channel_use, sta);
DEBUGFS_ADD(drop_unencrypted, sta);
- DEBUGFS_ADD(eapol, sta);
- DEBUGFS_ADD(ieee8021_x, sta);
+ DEBUGFS_ADD(ieee802_1x_pac, sta);
DEBUGFS_ADD(state, sta);
DEBUGFS_ADD(bssid, sta);
DEBUGFS_ADD(prev_bssid, sta);
@@ -192,8 +190,7 @@ static void add_ap_files(struct ieee8021
{
DEBUGFS_ADD(channel_use, ap);
DEBUGFS_ADD(drop_unencrypted, ap);
- DEBUGFS_ADD(eapol, ap);
- DEBUGFS_ADD(ieee8021_x, ap);
+ DEBUGFS_ADD(ieee802_1x_pac, ap);
DEBUGFS_ADD(num_sta_ps, ap);
DEBUGFS_ADD(dtim_period, ap);
DEBUGFS_ADD(dtim_count, ap);
@@ -209,8 +206,7 @@ static void add_wds_files(struct ieee802
{
DEBUGFS_ADD(channel_use, wds);
DEBUGFS_ADD(drop_unencrypted, wds);
- DEBUGFS_ADD(eapol, wds);
- DEBUGFS_ADD(ieee8021_x, wds);
+ DEBUGFS_ADD(ieee802_1x_pac, wds);
DEBUGFS_ADD(peer, wds);
}
@@ -218,8 +214,7 @@ static void add_vlan_files(struct ieee80
{
DEBUGFS_ADD(channel_use, vlan);
DEBUGFS_ADD(drop_unencrypted, vlan);
- DEBUGFS_ADD(eapol, vlan);
- DEBUGFS_ADD(ieee8021_x, vlan);
+ DEBUGFS_ADD(ieee802_1x_pac, vlan);
}
static void add_monitor_files(struct ieee80211_sub_if_data *sdata)
@@ -263,8 +258,7 @@ static void del_sta_files(struct ieee802
{
DEBUGFS_DEL(channel_use, sta);
DEBUGFS_DEL(drop_unencrypted, sta);
- DEBUGFS_DEL(eapol, sta);
- DEBUGFS_DEL(ieee8021_x, sta);
+ DEBUGFS_DEL(ieee802_1x_pac, sta);
DEBUGFS_DEL(state, sta);
DEBUGFS_DEL(bssid, sta);
DEBUGFS_DEL(prev_bssid, sta);
@@ -285,8 +279,7 @@ static void del_ap_files(struct ieee8021
{
DEBUGFS_DEL(channel_use, ap);
DEBUGFS_DEL(drop_unencrypted, ap);
- DEBUGFS_DEL(eapol, ap);
- DEBUGFS_DEL(ieee8021_x, ap);
+ DEBUGFS_DEL(ieee802_1x_pac, ap);
DEBUGFS_DEL(num_sta_ps, ap);
DEBUGFS_DEL(dtim_period, ap);
DEBUGFS_DEL(dtim_count, ap);
@@ -302,8 +295,7 @@ static void del_wds_files(struct ieee802
{
DEBUGFS_DEL(channel_use, wds);
DEBUGFS_DEL(drop_unencrypted, wds);
- DEBUGFS_DEL(eapol, wds);
- DEBUGFS_DEL(ieee8021_x, wds);
+ DEBUGFS_DEL(ieee802_1x_pac, wds);
DEBUGFS_DEL(peer, wds);
}
@@ -311,8 +303,7 @@ static void del_vlan_files(struct ieee80
{
DEBUGFS_DEL(channel_use, vlan);
DEBUGFS_DEL(drop_unencrypted, vlan);
- DEBUGFS_DEL(eapol, vlan);
- DEBUGFS_DEL(ieee8021_x, vlan);
+ DEBUGFS_DEL(ieee802_1x_pac, vlan);
}
static void del_monitor_files(struct ieee80211_sub_if_data *sdata)
--- everything.orig/net/mac80211/ieee80211_iface.c 2007-12-19 00:39:58.583023003 +0100
+++ everything/net/mac80211/ieee80211_iface.c 2007-12-19 01:09:42.613022569 +0100
@@ -22,7 +22,6 @@ void ieee80211_if_sdata_init(struct ieee
/* Default values for sub-interface parameters */
sdata->drop_unencrypted = 0;
- sdata->eapol = 1;
for (i = 0; i < IEEE80211_FRAGMENT_MAX; i++)
skb_queue_head_init(&sdata->fragments[i].skb_list);
--- everything.orig/net/mac80211/tx.c 2007-12-19 00:39:58.623022948 +0100
+++ everything/net/mac80211/tx.c 2007-12-19 01:09:53.523023546 +0100
@@ -261,18 +261,6 @@ ieee80211_tx_h_check_assoc(struct ieee80
return TXRX_CONTINUE;
}
- if (unlikely(/* !injected && */ tx->sdata->ieee802_1x &&
- !(sta_flags & WLAN_STA_AUTHORIZED))) {
-#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
- DECLARE_MAC_BUF(mac);
- printk(KERN_DEBUG "%s: dropped frame to %s"
- " (unauthorized port)\n", tx->dev->name,
- print_mac(mac, hdr->addr1));
-#endif
- I802_DEBUG_INC(tx->local->tx_handlers_drop_unauth_port);
- return TXRX_DROP;
- }
-
return TXRX_CONTINUE;
}
@@ -445,8 +433,7 @@ ieee80211_tx_h_select_key(struct ieee802
else if ((key = rcu_dereference(tx->sdata->default_key)))
tx->key = key;
else if (tx->sdata->drop_unencrypted &&
- !(tx->sdata->eapol &&
- ieee80211_is_eapol(tx->skb, ieee80211_get_hdrlen(fc)))) {
+ !ieee80211_is_eapol(tx->skb, ieee80211_get_hdrlen(fc))) {
I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted);
return TXRX_DROP;
} else
@@ -1355,6 +1342,7 @@ int ieee80211_subif_start_xmit(struct sk
int encaps_len, skip_header_bytes;
int nh_pos, h_pos;
struct sta_info *sta;
+ u32 sta_flags = 0;
sdata = IEEE80211_DEV_TO_SUB_IF(dev);
if (unlikely(skb->len < ETH_HLEN)) {
@@ -1370,7 +1358,6 @@ int ieee80211_subif_start_xmit(struct sk
/* convert Ethernet header to proper 802.11 header (based on
* operation mode) */
ethertype = (skb->data[12] << 8) | skb->data[13];
- /* TODO: handling for 802.1x authorized/unauthorized port */
fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA;
switch (sdata->type) {
@@ -1412,16 +1399,42 @@ int ieee80211_subif_start_xmit(struct sk
goto fail;
}
- /* receiver is QoS enabled, use a QoS type frame */
sta = sta_info_get(local, hdr.addr1);
if (sta) {
- if (sta->flags & WLAN_STA_WME) {
- fc |= IEEE80211_STYPE_QOS_DATA;
- hdrlen += 2;
- }
+ sta_flags = sta->flags;
sta_info_put(sta);
}
+ /* receiver is QoS enabled, use a QoS type frame */
+ if (sta_flags & WLAN_STA_WME) {
+ fc |= IEEE80211_STYPE_QOS_DATA;
+ hdrlen += 2;
+ }
+
+ /*
+ * If port access control is enabled, drop frames to unauthorised
+ * stations unless they are EAPOL frames from the local station.
+ */
+ if (unlikely(sdata->ieee802_1x_pac &&
+ !(sta_flags & WLAN_STA_AUTHORIZED) &&
+ !(ethertype == ETH_P_PAE &&
+ compare_ether_addr(dev->dev_addr,
+ skb->data + ETH_ALEN) == 0))) {
+#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
+ DECLARE_MAC_BUF(mac);
+
+ if (net_ratelimit())
+ printk(KERN_DEBUG "%s: dropped frame to %s"
+ " (unauthorized port)\n", dev->name,
+ print_mac(mac, hdr.addr1));
+#endif
+
+ I802_DEBUG_INC(local->tx_handlers_drop_unauth_port);
+
+ ret = 0;
+ goto fail;
+ }
+
hdr.frame_control = cpu_to_le16(fc);
hdr.duration_id = 0;
hdr.seq_ctrl = 0;
--
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 2/6] mac80211: clean up eapol handling in TX path
2007-12-19 0:31 [PATCH 0/6] mac80211 updates Johannes Berg
2007-12-19 0:31 ` [PATCH 1/6] mac80211: clean up eapol frame handling/port control Johannes Berg
@ 2007-12-19 0:31 ` Johannes Berg
2007-12-19 0:31 ` [PATCH 3/6] mac80211: make ieee80211_rx_mgmt_action static Johannes Berg
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Johannes Berg @ 2007-12-19 0:31 UTC (permalink / raw)
To: John Linville; +Cc: Michael Wu, linux-wireless
The previous patch left only one user of the ieee80211_is_eapol()
function and that user can be eliminated easily by introducing
a new "frame is EAPOL" flag to handle the frame specially (we
already have this information) instead of doing the (expensive)
ieee80211_is_eapol() all the time.
Also, allow unencrypted frames to be sent when they are injected.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
include/net/mac80211.h | 1 +
net/mac80211/ieee80211.c | 2 ++
net/mac80211/ieee80211_i.h | 2 +-
net/mac80211/tx.c | 7 ++++++-
net/mac80211/util.c | 17 -----------------
5 files changed, 10 insertions(+), 19 deletions(-)
--- everything.orig/include/net/mac80211.h 2007-12-19 00:35:35.883023653 +0100
+++ everything/include/net/mac80211.h 2007-12-19 00:42:11.913023383 +0100
@@ -307,6 +307,7 @@ struct ieee80211_tx_control {
* using the through
* set_retry_limit configured
* long retry value */
+#define IEEE80211_TXCTL_EAPOL_FRAME (1<<11) /* internal to mac80211 */
u32 flags; /* tx control flags defined
* above */
u8 key_idx; /* keyidx from hw->set_key(), undefined if
--- everything.orig/net/mac80211/ieee80211.c 2007-12-19 00:35:35.613024685 +0100
+++ everything/net/mac80211/ieee80211.c 2007-12-19 00:42:11.923022461 +0100
@@ -732,6 +732,8 @@ static void ieee80211_remove_tx_extra(st
pkt_data->flags |= IEEE80211_TXPD_DO_NOT_ENCRYPT;
if (control->flags & IEEE80211_TXCTL_REQUEUE)
pkt_data->flags |= IEEE80211_TXPD_REQUEUE;
+ if (control->flags & IEEE80211_TXCTL_EAPOL_FRAME)
+ pkt_data->flags |= IEEE80211_TXPD_EAPOL_FRAME;
pkt_data->queue = control->queue;
hdrlen = ieee80211_get_hdrlen_from_skb(skb);
--- everything.orig/net/mac80211/ieee80211_i.h 2007-12-19 00:40:00.863027777 +0100
+++ everything/net/mac80211/ieee80211_i.h 2007-12-19 00:42:11.923022461 +0100
@@ -164,6 +164,7 @@ struct ieee80211_txrx_data {
#define IEEE80211_TXPD_REQ_TX_STATUS BIT(0)
#define IEEE80211_TXPD_DO_NOT_ENCRYPT BIT(1)
#define IEEE80211_TXPD_REQUEUE BIT(2)
+#define IEEE80211_TXPD_EAPOL_FRAME BIT(3)
/* Stored in sk_buff->cb */
struct ieee80211_tx_packet_data {
int ifindex;
@@ -798,7 +799,6 @@ extern void *mac80211_wiphy_privid; /* f
extern const unsigned char rfc1042_header[6];
extern const unsigned char bridge_tunnel_header[6];
u8 *ieee80211_get_bssid(struct ieee80211_hdr *hdr, size_t len);
-int ieee80211_is_eapol(const struct sk_buff *skb, int hdrlen);
int ieee80211_frame_duration(struct ieee80211_local *local, size_t len,
int rate, int erp, int short_preamble);
void mac80211_ev_michael_mic_failure(struct net_device *dev, int keyidx,
--- everything.orig/net/mac80211/tx.c 2007-12-19 00:40:00.873022460 +0100
+++ everything/net/mac80211/tx.c 2007-12-19 00:46:23.673022786 +0100
@@ -433,7 +433,8 @@ ieee80211_tx_h_select_key(struct ieee802
else if ((key = rcu_dereference(tx->sdata->default_key)))
tx->key = key;
else if (tx->sdata->drop_unencrypted &&
- !ieee80211_is_eapol(tx->skb, ieee80211_get_hdrlen(fc))) {
+ !(tx->u.tx.control->flags & IEEE80211_TXCTL_EAPOL_FRAME) &&
+ !(tx->flags & IEEE80211_TXRXD_TX_INJECTED)) {
I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted);
return TXRX_DROP;
} else
@@ -1250,6 +1251,8 @@ int ieee80211_master_start_xmit(struct s
control.flags |= IEEE80211_TXCTL_DO_NOT_ENCRYPT;
if (pkt_data->flags & IEEE80211_TXPD_REQUEUE)
control.flags |= IEEE80211_TXCTL_REQUEUE;
+ if (pkt_data->flags & IEEE80211_TXPD_EAPOL_FRAME)
+ control.flags |= IEEE80211_TXCTL_EAPOL_FRAME;
control.queue = pkt_data->queue;
ret = ieee80211_tx(odev, skb, &control);
@@ -1523,6 +1526,8 @@ int ieee80211_subif_start_xmit(struct sk
pkt_data = (struct ieee80211_tx_packet_data *)skb->cb;
memset(pkt_data, 0, sizeof(struct ieee80211_tx_packet_data));
pkt_data->ifindex = dev->ifindex;
+ if (ethertype == ETH_P_PAE)
+ pkt_data->flags |= IEEE80211_TXPD_EAPOL_FRAME;
skb->dev = local->mdev;
dev->stats.tx_packets++;
--- everything.orig/net/mac80211/util.c 2007-12-19 00:35:35.713024848 +0100
+++ everything/net/mac80211/util.c 2007-12-19 00:42:11.933022568 +0100
@@ -40,10 +40,6 @@ const unsigned char rfc1042_header[] =
const unsigned char bridge_tunnel_header[] =
{ 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 };
-/* No encapsulation header if EtherType < 0x600 (=length) */
-static const unsigned char eapol_header[] =
- { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00, 0x88, 0x8e };
-
static int rate_list_match(const int *rate_list, int rate)
{
@@ -218,19 +214,6 @@ int ieee80211_get_hdrlen_from_skb(const
}
EXPORT_SYMBOL(ieee80211_get_hdrlen_from_skb);
-int ieee80211_is_eapol(const struct sk_buff *skb, int hdrlen)
-{
- if (unlikely(skb->len < 10))
- return 0;
-
- if (unlikely(skb->len >= hdrlen + sizeof(eapol_header) &&
- memcmp(skb->data + hdrlen, eapol_header,
- sizeof(eapol_header)) == 0))
- return 1;
-
- return 0;
-}
-
void ieee80211_tx_set_iswep(struct ieee80211_txrx_data *tx)
{
struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) tx->skb->data;
--
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 3/6] mac80211: make ieee80211_rx_mgmt_action static
2007-12-19 0:31 [PATCH 0/6] mac80211 updates Johannes Berg
2007-12-19 0:31 ` [PATCH 1/6] mac80211: clean up eapol frame handling/port control Johannes Berg
2007-12-19 0:31 ` [PATCH 2/6] mac80211: clean up eapol handling in TX path Johannes Berg
@ 2007-12-19 0:31 ` Johannes Berg
2007-12-19 0:31 ` [PATCH 4/6] mac80211: allow easier multicast/broadcast buffering in hardware Johannes Berg
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Johannes Berg @ 2007-12-19 0:31 UTC (permalink / raw)
To: John Linville; +Cc: Michael Wu, linux-wireless
The function is only used locally.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
net/mac80211/ieee80211_sta.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
--- everything.orig/net/mac80211/ieee80211_sta.c 2007-12-19 00:35:22.723022189 +0100
+++ everything/net/mac80211/ieee80211_sta.c 2007-12-19 00:48:26.783024250 +0100
@@ -1994,10 +1994,10 @@ static void ieee80211_rx_mgmt_probe_req(
ieee80211_sta_tx(dev, skb, 0);
}
-void ieee80211_rx_mgmt_action(struct net_device *dev,
- struct ieee80211_if_sta *ifsta,
- struct ieee80211_mgmt *mgmt,
- size_t len)
+static void ieee80211_rx_mgmt_action(struct net_device *dev,
+ struct ieee80211_if_sta *ifsta,
+ struct ieee80211_mgmt *mgmt,
+ size_t len)
{
if (len < IEEE80211_MIN_ACTION_SIZE)
return;
--
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 4/6] mac80211: allow easier multicast/broadcast buffering in hardware
2007-12-19 0:31 [PATCH 0/6] mac80211 updates Johannes Berg
` (2 preceding siblings ...)
2007-12-19 0:31 ` [PATCH 3/6] mac80211: make ieee80211_rx_mgmt_action static Johannes Berg
@ 2007-12-19 0:31 ` Johannes Berg
2007-12-19 0:31 ` [PATCH 5/6] mac80211: dont use interface indices in drivers Johannes Berg
2007-12-19 0:31 ` [PATCH 6/6] mac80211: move interface type to vif structure Johannes Berg
5 siblings, 0 replies; 7+ messages in thread
From: Johannes Berg @ 2007-12-19 0:31 UTC (permalink / raw)
To: John Linville; +Cc: Michael Wu, linux-wireless, Michael Buesch
There are various decisions influencing the decision whether to buffer
a frame for after the next DTIM beacon. The "do we have stations in PS
mode" condition cannot be tested by the driver so mac80211 has to do
that. To ease driver writing for hardware that can buffer frames until
after the next DTIM beacon, introduce a new txctl flag telling the
driver to buffer a specific frame.
While at it, restructure and comment the code for multicast buffering
and remove spurious "inline" directives.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Michael Buesch <mb@bu3sch.de>
---
include/net/mac80211.h | 2 ++
net/mac80211/tx.c | 32 +++++++++++++++++++++++---------
2 files changed, 25 insertions(+), 9 deletions(-)
--- everything.orig/include/net/mac80211.h 2007-12-19 00:42:11.913023383 +0100
+++ everything/include/net/mac80211.h 2007-12-19 00:49:47.343023166 +0100
@@ -308,6 +308,8 @@ struct ieee80211_tx_control {
* set_retry_limit configured
* long retry value */
#define IEEE80211_TXCTL_EAPOL_FRAME (1<<11) /* internal to mac80211 */
+#define IEEE80211_TXCTL_SEND_AFTER_DTIM (1<<12) /* send this frame after DTIM
+ * beacon */
u32 flags; /* tx control flags defined
* above */
u8 key_idx; /* keyidx from hw->set_key(), undefined if
--- everything.orig/net/mac80211/tx.c 2007-12-19 00:46:23.673022786 +0100
+++ everything/net/mac80211/tx.c 2007-12-19 00:49:31.823024413 +0100
@@ -322,16 +322,27 @@ static void purge_old_ps_buffers(struct
wiphy_name(local->hw.wiphy), purged);
}
-static inline ieee80211_txrx_result
+static ieee80211_txrx_result
ieee80211_tx_h_multicast_ps_buf(struct ieee80211_txrx_data *tx)
{
- /* broadcast/multicast frame */
- /* 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.flags & IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING) &&
- tx->sdata->type != IEEE80211_IF_TYPE_WDS &&
- tx->sdata->bss && atomic_read(&tx->sdata->bss->num_sta_ps) &&
- !(tx->fc & IEEE80211_FCTL_ORDER)) {
+ /*
+ * broadcast/multicast frame
+ *
+ * If any of the associated stations is in power save mode,
+ * the frame is buffered to be sent after DTIM beacon frame.
+ * This is done either by the hardware or us.
+ */
+
+ /* not AP/IBSS or ordered frame */
+ if (!tx->sdata->bss || (tx->fc & IEEE80211_FCTL_ORDER))
+ return TXRX_CONTINUE;
+
+ /* no stations in PS mode */
+ if (!atomic_read(&tx->sdata->bss->num_sta_ps))
+ return TXRX_CONTINUE;
+
+ /* buffered in mac80211 */
+ if (tx->local->hw.flags & IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING) {
if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER)
purge_old_ps_buffers(tx->local);
if (skb_queue_len(&tx->sdata->bss->ps_bc_buf) >=
@@ -348,10 +359,13 @@ ieee80211_tx_h_multicast_ps_buf(struct i
return TXRX_QUEUED;
}
+ /* buffered in hardware */
+ tx->u.tx.control->flags |= IEEE80211_TXCTL_SEND_AFTER_DTIM;
+
return TXRX_CONTINUE;
}
-static inline ieee80211_txrx_result
+static ieee80211_txrx_result
ieee80211_tx_h_unicast_ps_buf(struct ieee80211_txrx_data *tx)
{
struct sta_info *sta = tx->sta;
--
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 5/6] mac80211: dont use interface indices in drivers
2007-12-19 0:31 [PATCH 0/6] mac80211 updates Johannes Berg
` (3 preceding siblings ...)
2007-12-19 0:31 ` [PATCH 4/6] mac80211: allow easier multicast/broadcast buffering in hardware Johannes Berg
@ 2007-12-19 0:31 ` Johannes Berg
2007-12-19 0:31 ` [PATCH 6/6] mac80211: move interface type to vif structure Johannes Berg
5 siblings, 0 replies; 7+ messages in thread
From: Johannes Berg @ 2007-12-19 0:31 UTC (permalink / raw)
To: John Linville; +Cc: Michael Wu, linux-wireless
This patch gets rid of the if_id stuff where possible in favour of
a new per-virtual-interface structure "struct ieee80211_vif". This
structure is located at the end of the per-interface structure and
contains a variable length driver-use data area.
This has two advantages:
* removes the need to look up interfaces by if_id, this is better
for working with network namespaces and performance
* allows drivers to store and retrieve per-interface data without
having to allocate own lists/hash tables
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
drivers/net/wireless/adm8211.c | 3 -
drivers/net/wireless/ath5k/base.c | 15 +++---
drivers/net/wireless/ath5k/base.h | 2
drivers/net/wireless/ath5k/hw.c | 2
drivers/net/wireless/b43/b43.h | 5 --
drivers/net/wireless/b43/main.c | 13 ++---
drivers/net/wireless/b43/xmit.c | 6 +-
drivers/net/wireless/b43legacy/b43legacy.h | 5 --
drivers/net/wireless/b43legacy/main.c | 13 ++---
drivers/net/wireless/b43legacy/xmit.c | 6 +-
drivers/net/wireless/iwlwifi/iwl-3945.h | 2
drivers/net/wireless/iwlwifi/iwl-4965.h | 2
drivers/net/wireless/iwlwifi/iwl3945-base.c | 28 +++++------
drivers/net/wireless/iwlwifi/iwl4965-base.c | 28 +++++------
drivers/net/wireless/p54common.c | 3 -
drivers/net/wireless/rt2x00/rt2x00.h | 5 +-
drivers/net/wireless/rt2x00/rt2x00mac.c | 5 +-
drivers/net/wireless/rtl8180.h | 2
drivers/net/wireless/rtl8180_dev.c | 11 ++--
drivers/net/wireless/rtl8187.h | 2
drivers/net/wireless/rtl8187_dev.c | 8 +--
drivers/net/wireless/zd1211rw/zd_mac.c | 3 -
include/net/mac80211.h | 70 ++++++++++++++++++----------
net/mac80211/ieee80211.c | 12 ++--
net/mac80211/ieee80211_i.h | 8 +++
net/mac80211/ieee80211_iface.c | 2
net/mac80211/sta_info.c | 27 ++++++++--
net/mac80211/tx.c | 46 ++++++++----------
net/mac80211/util.c | 45 ++++++------------
29 files changed, 205 insertions(+), 174 deletions(-)
--- everything.orig/include/net/mac80211.h 2007-12-19 00:49:47.343023166 +0100
+++ everything/include/net/mac80211.h 2007-12-19 00:50:11.193025987 +0100
@@ -280,6 +280,7 @@ struct ieee80211_low_level_stats {
* the hardware to use given values (depending on what is supported). */
struct ieee80211_tx_control {
+ struct ieee80211_vif *vif;
int tx_rate; /* Transmit rate, given as the hw specific value for the
* rate (from struct ieee80211_rate) */
int rts_cts_rate; /* Transmit rate for RTS/CTS frame, given as the hw
@@ -332,7 +333,6 @@ struct ieee80211_tx_control {
* packet dropping when probing higher rates, if hw
* supports multiple retry rates. -1 = not used */
int type; /* internal */
- int ifindex; /* internal */
};
@@ -530,13 +530,25 @@ enum ieee80211_if_types {
};
/**
+ * struct ieee80211_vif - per-interface data
+ *
+ * Data in this structure is continually present for driver
+ * use during the life of a virtual interface.
+ *
+ * @drv_priv: data area for driver use, will always be aligned to
+ * sizeof(void *).
+ */
+struct ieee80211_vif {
+ /* must be last */
+ u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *))));
+};
+
+/**
* 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.
- * This field is not valid for monitor interfaces
- * (interfaces of %IEEE80211_IF_TYPE_MNTR type).
+ * @vif: pointer to a driver-use per-interface structure. The pointer
+ * itself is also used for various functions including
+ * ieee80211_beacon_get() and ieee80211_get_buffered_bc().
* @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
@@ -553,8 +565,8 @@ enum ieee80211_if_types {
* in pure monitor mode.
*/
struct ieee80211_if_init_conf {
- int if_id;
enum ieee80211_if_types type;
+ struct ieee80211_vif *vif;
void *mac_addr;
};
@@ -760,6 +772,9 @@ enum ieee80211_hw_flags {
* @rate_control_algorithm: rate control algorithm for this hardware.
* If unset (NULL), the default algorithm will be used. Must be
* set before calling ieee80211_register_hw().
+ *
+ * @vif_data_size: size (in bytes) of the drv_priv data area
+ * within &struct ieee80211_vif.
*/
struct ieee80211_hw {
struct ieee80211_conf conf;
@@ -770,6 +785,7 @@ struct ieee80211_hw {
u32 flags;
unsigned int extra_tx_headroom;
int channel_change_time;
+ int vif_data_size;
u8 queues;
s8 max_rssi;
s8 max_signal;
@@ -1061,7 +1077,8 @@ struct ieee80211_ops {
struct ieee80211_if_init_conf *conf);
int (*config)(struct ieee80211_hw *hw, struct ieee80211_conf *conf);
int (*config_interface)(struct ieee80211_hw *hw,
- int if_id, struct ieee80211_if_conf *conf);
+ struct ieee80211_vif *vif,
+ struct ieee80211_if_conf *conf);
void (*configure_filter)(struct ieee80211_hw *hw,
unsigned int changed_flags,
unsigned int *total_flags,
@@ -1080,7 +1097,7 @@ struct ieee80211_ops {
int (*set_frag_threshold)(struct ieee80211_hw *hw, u32 value);
int (*set_retry_limit)(struct ieee80211_hw *hw,
u32 short_retry, u32 long_retr);
- void (*sta_notify)(struct ieee80211_hw *hw, int if_id,
+ void (*sta_notify)(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
enum sta_notify_cmd, const u8 *addr);
void (*erp_ie_changed)(struct ieee80211_hw *hw, u8 changes,
int cts_protection, int preamble);
@@ -1263,7 +1280,7 @@ void ieee80211_tx_status_irqsafe(struct
/**
* ieee80211_beacon_get - beacon generation function
* @hw: pointer obtained from ieee80211_alloc_hw().
- * @if_id: interface ID from &struct ieee80211_if_init_conf.
+ * @vif: &struct ieee80211_vif pointer 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
@@ -1274,13 +1291,13 @@ void ieee80211_tx_status_irqsafe(struct
* is responsible of freeing it.
*/
struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
- int if_id,
+ struct ieee80211_vif *vif,
struct ieee80211_tx_control *control);
/**
* ieee80211_rts_get - RTS frame generation function
* @hw: pointer obtained from ieee80211_alloc_hw().
- * @if_id: interface ID from &struct ieee80211_if_init_conf.
+ * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
* @frame: pointer to the frame that is going to be protected by the RTS.
* @frame_len: the frame length (in octets).
* @frame_txctl: &struct ieee80211_tx_control of the frame.
@@ -1291,7 +1308,7 @@ struct sk_buff *ieee80211_beacon_get(str
* the next RTS frame from the 802.11 code. The low-level is responsible
* for calling this function before and RTS frame is needed.
*/
-void ieee80211_rts_get(struct ieee80211_hw *hw, int if_id,
+void ieee80211_rts_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
const void *frame, size_t frame_len,
const struct ieee80211_tx_control *frame_txctl,
struct ieee80211_rts *rts);
@@ -1299,7 +1316,7 @@ void ieee80211_rts_get(struct ieee80211_
/**
* ieee80211_rts_duration - Get the duration field for an RTS frame
* @hw: pointer obtained from ieee80211_alloc_hw().
- * @if_id: interface ID from &struct ieee80211_if_init_conf.
+ * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
* @frame_len: the length of the frame that is going to be protected by the RTS.
* @frame_txctl: &struct ieee80211_tx_control of the frame.
*
@@ -1307,14 +1324,14 @@ void ieee80211_rts_get(struct ieee80211_
* the duration field, the low-level driver uses this function to receive
* the duration field value in little-endian byteorder.
*/
-__le16 ieee80211_rts_duration(struct ieee80211_hw *hw, int if_id,
- size_t frame_len,
+__le16 ieee80211_rts_duration(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif, size_t frame_len,
const struct ieee80211_tx_control *frame_txctl);
/**
* ieee80211_ctstoself_get - CTS-to-self frame generation function
* @hw: pointer obtained from ieee80211_alloc_hw().
- * @if_id: interface ID from &struct ieee80211_if_init_conf.
+ * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
* @frame: pointer to the frame that is going to be protected by the CTS-to-self.
* @frame_len: the frame length (in octets).
* @frame_txctl: &struct ieee80211_tx_control of the frame.
@@ -1325,7 +1342,8 @@ __le16 ieee80211_rts_duration(struct iee
* the next CTS-to-self frame from the 802.11 code. The low-level is responsible
* for calling this function before and CTS-to-self frame is needed.
*/
-void ieee80211_ctstoself_get(struct ieee80211_hw *hw, int if_id,
+void ieee80211_ctstoself_get(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
const void *frame, size_t frame_len,
const struct ieee80211_tx_control *frame_txctl,
struct ieee80211_cts *cts);
@@ -1333,7 +1351,7 @@ void ieee80211_ctstoself_get(struct ieee
/**
* ieee80211_ctstoself_duration - Get the duration field for a CTS-to-self frame
* @hw: pointer obtained from ieee80211_alloc_hw().
- * @if_id: interface ID from &struct ieee80211_if_init_conf.
+ * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
* @frame_len: the length of the frame that is going to be protected by the CTS-to-self.
* @frame_txctl: &struct ieee80211_tx_control of the frame.
*
@@ -1341,28 +1359,30 @@ void ieee80211_ctstoself_get(struct ieee
* the duration field, the low-level driver uses this function to receive
* the duration field value in little-endian byteorder.
*/
-__le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, int if_id,
+__le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
size_t frame_len,
const struct ieee80211_tx_control *frame_txctl);
/**
* ieee80211_generic_frame_duration - Calculate the duration field for a frame
* @hw: pointer obtained from ieee80211_alloc_hw().
- * @if_id: interface ID from &struct ieee80211_if_init_conf.
+ * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf.
* @frame_len: the length of the frame.
* @rate: the rate (in 100kbps) at which the frame is going to be transmitted.
*
* Calculate the duration field of some generic frame, given its
* length and transmission rate (in 100kbps).
*/
-__le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, int if_id,
+__le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
size_t frame_len,
int rate);
/**
* ieee80211_get_buffered_bc - accessing buffered broadcast and multicast frames
* @hw: pointer as obtained from ieee80211_alloc_hw().
- * @if_id: interface ID from &struct ieee80211_if_init_conf.
+ * @vif: &struct ieee80211_vif pointer 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
@@ -1381,7 +1401,7 @@ __le16 ieee80211_generic_frame_duration(
* use common code for all beacons.
*/
struct sk_buff *
-ieee80211_get_buffered_bc(struct ieee80211_hw *hw, int if_id,
+ieee80211_get_buffered_bc(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
struct ieee80211_tx_control *control);
/**
@@ -1471,7 +1491,7 @@ void ieee80211_scan_completed(struct iee
*/
void ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw,
void (*iterator)(void *data, u8 *mac,
- int if_id),
+ struct ieee80211_vif *vif),
void *data);
#endif /* MAC80211_H */
--- everything.orig/net/mac80211/ieee80211.c 2007-12-19 00:42:11.923022461 +0100
+++ everything/net/mac80211/ieee80211.c 2007-12-19 00:50:11.203023546 +0100
@@ -242,7 +242,7 @@ static int ieee80211_open(struct net_dev
sdata->u.sta.flags &= ~IEEE80211_STA_PREV_BSSID_SET;
/* fall through */
default:
- conf.if_id = dev->ifindex;
+ conf.vif = &sdata->vif;
conf.type = sdata->type;
conf.mac_addr = dev->dev_addr;
res = local->ops->add_interface(local_to_hw(local), &conf);
@@ -368,7 +368,7 @@ static int ieee80211_stop(struct net_dev
sdata->u.sta.extra_ie_len = 0;
/* fall through */
default:
- conf.if_id = dev->ifindex;
+ conf.vif = &sdata->vif;
conf.type = sdata->type;
conf.mac_addr = dev->dev_addr;
/* disable all keys for as long as this netdev is down */
@@ -503,7 +503,7 @@ static int __ieee80211_if_config(struct
conf.beacon_control = control;
}
return local->ops->config_interface(local_to_hw(local),
- dev->ifindex, &conf);
+ &sdata->vif, &conf);
}
int ieee80211_if_config(struct net_device *dev)
@@ -515,11 +515,13 @@ int ieee80211_if_config_beacon(struct ne
{
struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
struct ieee80211_tx_control control;
+ struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
struct sk_buff *skb;
if (!(local->hw.flags & IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE))
return 0;
- skb = ieee80211_beacon_get(local_to_hw(local), dev->ifindex, &control);
+ skb = ieee80211_beacon_get(local_to_hw(local), &sdata->vif,
+ &control);
if (!skb)
return -ENOMEM;
return __ieee80211_if_config(dev, skb, &control);
@@ -724,7 +726,7 @@ static void ieee80211_remove_tx_extra(st
struct ieee80211_tx_packet_data *pkt_data;
pkt_data = (struct ieee80211_tx_packet_data *)skb->cb;
- pkt_data->ifindex = control->ifindex;
+ pkt_data->ifindex = vif_to_sdata(control->vif)->dev->ifindex;
pkt_data->flags = 0;
if (control->flags & IEEE80211_TXCTL_REQ_TX_STATUS)
pkt_data->flags |= IEEE80211_TXPD_REQ_TX_STATUS;
--- everything.orig/net/mac80211/ieee80211_i.h 2007-12-19 00:42:11.923022461 +0100
+++ everything/net/mac80211/ieee80211_i.h 2007-12-19 00:50:11.213056044 +0100
@@ -387,8 +387,16 @@ struct ieee80211_sub_if_data {
struct dentry *default_key;
} debugfs;
#endif
+ /* must be last, dynamically sized area in this! */
+ struct ieee80211_vif vif;
};
+static inline
+struct ieee80211_sub_if_data *vif_to_sdata(struct ieee80211_vif *p)
+{
+ return container_of(p, struct ieee80211_sub_if_data, vif);
+}
+
#define IEEE80211_DEV_TO_SUB_IF(dev) netdev_priv(dev)
enum {
--- everything.orig/net/mac80211/util.c 2007-12-19 00:42:11.933022568 +0100
+++ everything/net/mac80211/util.c 2007-12-19 00:50:11.213056044 +0100
@@ -284,44 +284,34 @@ int ieee80211_frame_duration(struct ieee
}
/* Exported duration function for driver use */
-__le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, int if_id,
+__le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
size_t frame_len, int rate)
{
struct ieee80211_local *local = hw_to_local(hw);
- struct net_device *bdev = dev_get_by_index(&init_net, if_id);
- struct ieee80211_sub_if_data *sdata;
+ struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
u16 dur;
int erp;
- if (unlikely(!bdev))
- return 0;
-
- sdata = IEEE80211_DEV_TO_SUB_IF(bdev);
erp = ieee80211_is_erp_rate(hw->conf.phymode, rate);
dur = ieee80211_frame_duration(local, frame_len, rate,
erp, sdata->flags & IEEE80211_SDATA_SHORT_PREAMBLE);
- dev_put(bdev);
return cpu_to_le16(dur);
}
EXPORT_SYMBOL(ieee80211_generic_frame_duration);
-__le16 ieee80211_rts_duration(struct ieee80211_hw *hw, int if_id,
- size_t frame_len,
+__le16 ieee80211_rts_duration(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif, size_t frame_len,
const struct ieee80211_tx_control *frame_txctl)
{
struct ieee80211_local *local = hw_to_local(hw);
struct ieee80211_rate *rate;
- struct net_device *bdev = dev_get_by_index(&init_net, if_id);
- struct ieee80211_sub_if_data *sdata;
+ struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
int short_preamble;
int erp;
u16 dur;
- if (unlikely(!bdev))
- return 0;
-
- sdata = IEEE80211_DEV_TO_SUB_IF(bdev);
short_preamble = sdata->flags & IEEE80211_SDATA_SHORT_PREAMBLE;
rate = frame_txctl->rts_rate;
@@ -337,27 +327,22 @@ __le16 ieee80211_rts_duration(struct iee
dur += ieee80211_frame_duration(local, 10, rate->rate,
erp, short_preamble);
- dev_put(bdev);
return cpu_to_le16(dur);
}
EXPORT_SYMBOL(ieee80211_rts_duration);
-__le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, int if_id,
+__le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
size_t frame_len,
const struct ieee80211_tx_control *frame_txctl)
{
struct ieee80211_local *local = hw_to_local(hw);
struct ieee80211_rate *rate;
- struct net_device *bdev = dev_get_by_index(&init_net, if_id);
- struct ieee80211_sub_if_data *sdata;
+ struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
int short_preamble;
int erp;
u16 dur;
- if (unlikely(!bdev))
- return 0;
-
- sdata = IEEE80211_DEV_TO_SUB_IF(bdev);
short_preamble = sdata->flags & IEEE80211_SDATA_SHORT_PREAMBLE;
rate = frame_txctl->rts_rate;
@@ -372,7 +357,6 @@ __le16 ieee80211_ctstoself_duration(stru
erp, short_preamble);
}
- dev_put(bdev);
return cpu_to_le16(dur);
}
EXPORT_SYMBOL(ieee80211_ctstoself_duration);
@@ -457,10 +441,11 @@ void ieee80211_wake_queues(struct ieee80
}
EXPORT_SYMBOL(ieee80211_wake_queues);
-void ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw,
- void (*iterator)(void *data, u8 *mac,
- int if_id),
- void *data)
+void ieee80211_iterate_active_interfaces(
+ struct ieee80211_hw *hw,
+ void (*iterator)(void *data, u8 *mac,
+ struct ieee80211_vif *vif),
+ void *data)
{
struct ieee80211_local *local = hw_to_local(hw);
struct ieee80211_sub_if_data *sdata;
@@ -483,7 +468,7 @@ void ieee80211_iterate_active_interfaces
continue;
if (netif_running(sdata->dev))
iterator(data, sdata->dev->dev_addr,
- sdata->dev->ifindex);
+ &sdata->vif);
}
rcu_read_unlock();
--- everything.orig/net/mac80211/tx.c 2007-12-19 00:49:31.823024413 +0100
+++ everything/net/mac80211/tx.c 2007-12-19 00:50:11.223023816 +0100
@@ -1004,9 +1004,7 @@ __ieee80211_tx_prepare(struct ieee80211_
return res;
}
-/* Device in tx->dev has a reference added; use dev_put(tx->dev) when
- * finished with it.
- *
+/*
* NB: @tx is uninitialised when passed in here
*/
static int ieee80211_tx_prepare(struct ieee80211_txrx_data *tx,
@@ -1027,6 +1025,7 @@ static int ieee80211_tx_prepare(struct i
return -ENODEV;
/* initialises tx with control */
__ieee80211_tx_prepare(tx, skb, dev, control);
+ dev_put(dev);
return 0;
}
@@ -1257,7 +1256,7 @@ int ieee80211_master_start_xmit(struct s
}
}
- control.ifindex = odev->ifindex;
+ control.vif = &osdata->vif;
control.type = osdata->type;
if (pkt_data->flags & IEEE80211_TXPD_REQ_TX_STATUS)
control.flags |= IEEE80211_TXCTL_REQ_TX_STATUS;
@@ -1696,7 +1695,8 @@ static void ieee80211_beacon_add_tim(str
read_unlock_bh(&local->sta_lock);
}
-struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, int if_id,
+struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
struct ieee80211_tx_control *control)
{
struct ieee80211_local *local = hw_to_local(hw);
@@ -1709,19 +1709,16 @@ struct sk_buff *ieee80211_beacon_get(str
u8 *b_head, *b_tail;
int bh_len, bt_len;
- bdev = dev_get_by_index(&init_net, if_id);
- if (bdev) {
- sdata = IEEE80211_DEV_TO_SUB_IF(bdev);
- ap = &sdata->u.ap;
- dev_put(bdev);
- }
+ sdata = vif_to_sdata(vif);
+ bdev = sdata->dev;
+ ap = &sdata->u.ap;
if (!ap || sdata->type != IEEE80211_IF_TYPE_AP ||
!ap->beacon_head) {
#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
if (net_ratelimit())
- printk(KERN_DEBUG "no beacon data avail for idx=%d "
- "(%s)\n", if_id, bdev ? bdev->name : "N/A");
+ printk(KERN_DEBUG "no beacon data avail for %s\n",
+ bdev->name);
#endif /* CONFIG_MAC80211_VERBOSE_DEBUG */
return NULL;
}
@@ -1778,7 +1775,7 @@ struct sk_buff *ieee80211_beacon_get(str
}
EXPORT_SYMBOL(ieee80211_beacon_get);
-void ieee80211_rts_get(struct ieee80211_hw *hw, int if_id,
+void ieee80211_rts_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
const void *frame, size_t frame_len,
const struct ieee80211_tx_control *frame_txctl,
struct ieee80211_rts *rts)
@@ -1788,13 +1785,14 @@ void ieee80211_rts_get(struct ieee80211_
fctl = IEEE80211_FTYPE_CTL | IEEE80211_STYPE_RTS;
rts->frame_control = cpu_to_le16(fctl);
- rts->duration = ieee80211_rts_duration(hw, if_id, frame_len, frame_txctl);
+ rts->duration = ieee80211_rts_duration(hw, vif, frame_len,
+ frame_txctl);
memcpy(rts->ra, hdr->addr1, sizeof(rts->ra));
memcpy(rts->ta, hdr->addr2, sizeof(rts->ta));
}
EXPORT_SYMBOL(ieee80211_rts_get);
-void ieee80211_ctstoself_get(struct ieee80211_hw *hw, int if_id,
+void ieee80211_ctstoself_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
const void *frame, size_t frame_len,
const struct ieee80211_tx_control *frame_txctl,
struct ieee80211_cts *cts)
@@ -1804,13 +1802,15 @@ void ieee80211_ctstoself_get(struct ieee
fctl = IEEE80211_FTYPE_CTL | IEEE80211_STYPE_CTS;
cts->frame_control = cpu_to_le16(fctl);
- cts->duration = ieee80211_ctstoself_duration(hw, if_id, frame_len, frame_txctl);
+ cts->duration = ieee80211_ctstoself_duration(hw, vif,
+ frame_len, frame_txctl);
memcpy(cts->ra, hdr->addr1, sizeof(cts->ra));
}
EXPORT_SYMBOL(ieee80211_ctstoself_get);
struct sk_buff *
-ieee80211_get_buffered_bc(struct ieee80211_hw *hw, int if_id,
+ieee80211_get_buffered_bc(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
struct ieee80211_tx_control *control)
{
struct ieee80211_local *local = hw_to_local(hw);
@@ -1823,12 +1823,9 @@ ieee80211_get_buffered_bc(struct ieee802
struct ieee80211_sub_if_data *sdata;
struct ieee80211_if_ap *bss = NULL;
- bdev = dev_get_by_index(&init_net, if_id);
- if (bdev) {
- sdata = IEEE80211_DEV_TO_SUB_IF(bdev);
- bss = &sdata->u.ap;
- dev_put(bdev);
- }
+ sdata = vif_to_sdata(vif);
+ bdev = sdata->dev;
+
if (!bss || sdata->type != IEEE80211_IF_TYPE_AP || !bss->beacon_head)
return NULL;
@@ -1864,7 +1861,6 @@ ieee80211_get_buffered_bc(struct ieee802
if (res == TXRX_DROP || res == TXRX_QUEUED)
break;
}
- dev_put(tx.dev);
skb = tx.skb; /* handlers are allowed to change skb */
if (res == TXRX_DROP) {
--- everything.orig/drivers/net/wireless/b43/b43.h 2007-12-18 23:29:57.293022624 +0100
+++ everything/drivers/net/wireless/b43/b43.h 2007-12-19 00:50:11.233023436 +0100
@@ -620,10 +620,7 @@ struct b43_wl {
* at a time. General information about this interface follows.
*/
- /* Opaque ID of the operating interface from the ieee80211
- * subsystem. Do not modify.
- */
- int if_id;
+ struct ieee80211_vif *vif;
/* The MAC address of the operating interface. */
u8 mac_addr[ETH_ALEN];
/* Current BSSID */
--- everything.orig/drivers/net/wireless/b43/main.c 2007-12-18 23:29:57.353022677 +0100
+++ everything/drivers/net/wireless/b43/main.c 2007-12-19 00:50:11.263026041 +0100
@@ -1180,7 +1180,7 @@ static void b43_write_probe_resp_plcp(st
plcp.data = 0;
b43_generate_plcp_hdr(&plcp, size + FCS_LEN, rate);
dur = ieee80211_generic_frame_duration(dev->wl->hw,
- dev->wl->if_id, size,
+ dev->wl->vif, size,
B43_RATE_TO_BASE100KBPS(rate));
/* Write PLCP in two parts and timing for packet transfer */
tmp = le32_to_cpu(plcp.data);
@@ -1237,7 +1237,7 @@ static u8 *b43_generate_probe_resp(struc
hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
IEEE80211_STYPE_PROBE_RESP);
dur = ieee80211_generic_frame_duration(dev->wl->hw,
- dev->wl->if_id, *dest_size,
+ dev->wl->vif, *dest_size,
B43_RATE_TO_BASE100KBPS(rate));
hdr->duration_id = dur;
@@ -2949,7 +2949,7 @@ static void b43_op_configure_filter(stru
}
static int b43_op_config_interface(struct ieee80211_hw *hw,
- int if_id,
+ struct ieee80211_vif *vif,
struct ieee80211_if_conf *conf)
{
struct b43_wl *wl = hw_to_b43_wl(hw);
@@ -2960,7 +2960,7 @@ static int b43_op_config_interface(struc
return -ENODEV;
mutex_lock(&wl->mutex);
spin_lock_irqsave(&wl->irq_lock, flags);
- B43_WARN_ON(wl->if_id != if_id);
+ B43_WARN_ON(wl->vif != vif);
if (conf->bssid)
memcpy(wl->bssid, conf->bssid, ETH_ALEN);
else
@@ -3466,7 +3466,7 @@ static int b43_op_add_interface(struct i
dev = wl->current_dev;
wl->operating = 1;
- wl->if_id = conf->if_id;
+ wl->vif = conf->vif;
wl->if_type = conf->type;
memcpy(wl->mac_addr, conf->mac_addr, ETH_ALEN);
@@ -3494,7 +3494,8 @@ static void b43_op_remove_interface(stru
mutex_lock(&wl->mutex);
B43_WARN_ON(!wl->operating);
- B43_WARN_ON(wl->if_id != conf->if_id);
+ B43_WARN_ON(wl->vif != conf->vif);
+ wl->vif = NULL;
wl->operating = 0;
--- everything.orig/drivers/net/wireless/b43/xmit.c 2007-12-18 23:29:57.423022460 +0100
+++ everything/drivers/net/wireless/b43/xmit.c 2007-12-19 00:50:11.293023436 +0100
@@ -221,7 +221,7 @@ static void generate_txhdr_fw4(struct b4
} else {
int fbrate_base100kbps = B43_RATE_TO_BASE100KBPS(rate_fb);
txhdr->dur_fb = ieee80211_generic_frame_duration(dev->wl->hw,
- dev->wl->if_id,
+ txctl->vif,
fragment_len,
fbrate_base100kbps);
}
@@ -311,7 +311,7 @@ static void generate_txhdr_fw4(struct b4
rts_rate_fb_ofdm = b43_is_ofdm_rate(rts_rate_fb);
if (txctl->flags & IEEE80211_TXCTL_USE_CTS_PROTECT) {
- ieee80211_ctstoself_get(dev->wl->hw, dev->wl->if_id,
+ ieee80211_ctstoself_get(dev->wl->hw, txctl->vif,
fragment_data, fragment_len,
txctl,
(struct ieee80211_cts *)(txhdr->
@@ -319,7 +319,7 @@ static void generate_txhdr_fw4(struct b4
mac_ctl |= B43_TX4_MAC_SENDCTS;
len = sizeof(struct ieee80211_cts);
} else {
- ieee80211_rts_get(dev->wl->hw, dev->wl->if_id,
+ ieee80211_rts_get(dev->wl->hw, txctl->vif,
fragment_data, fragment_len, txctl,
(struct ieee80211_rts *)(txhdr->
rts_frame));
--- everything.orig/drivers/net/wireless/b43legacy/b43legacy.h 2007-12-18 23:29:57.453037326 +0100
+++ everything/drivers/net/wireless/b43legacy/b43legacy.h 2007-12-19 00:50:11.333023275 +0100
@@ -577,10 +577,7 @@ struct b43legacy_wl {
* at a time. General information about this interface follows.
*/
- /* Opaque ID of the operating interface from the ieee80211
- * subsystem. Do not modify.
- */
- int if_id;
+ struct ieee80211_vif *vif;
/* MAC address (can be NULL). */
u8 mac_addr[ETH_ALEN];
/* Current BSSID (can be NULL). */
--- everything.orig/drivers/net/wireless/b43legacy/main.c 2007-12-18 23:29:57.533028916 +0100
+++ everything/drivers/net/wireless/b43legacy/main.c 2007-12-19 00:50:11.343033149 +0100
@@ -976,7 +976,7 @@ static void b43legacy_write_probe_resp_p
plcp.data = 0;
b43legacy_generate_plcp_hdr(&plcp, size + FCS_LEN, rate);
dur = ieee80211_generic_frame_duration(dev->wl->hw,
- dev->wl->if_id,
+ dev->wl->vif,
size,
B43legacy_RATE_TO_100KBPS(rate));
/* Write PLCP in two parts and timing for packet transfer */
@@ -1042,7 +1042,7 @@ static u8 *b43legacy_generate_probe_resp
hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
IEEE80211_STYPE_PROBE_RESP);
dur = ieee80211_generic_frame_duration(dev->wl->hw,
- dev->wl->if_id,
+ dev->wl->vif,
*dest_size,
B43legacy_RATE_TO_100KBPS(rate));
hdr->duration_id = dur;
@@ -2650,7 +2650,7 @@ static void b43legacy_op_configure_filte
}
static int b43legacy_op_config_interface(struct ieee80211_hw *hw,
- int if_id,
+ struct ieee80211_vif *vif,
struct ieee80211_if_conf *conf)
{
struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
@@ -2661,7 +2661,7 @@ static int b43legacy_op_config_interface
return -ENODEV;
mutex_lock(&wl->mutex);
spin_lock_irqsave(&wl->irq_lock, flags);
- B43legacy_WARN_ON(wl->if_id != if_id);
+ B43legacy_WARN_ON(wl->vif != vif);
if (conf->bssid)
memcpy(wl->bssid, conf->bssid, ETH_ALEN);
else
@@ -3183,7 +3183,7 @@ static int b43legacy_op_add_interface(st
dev = wl->current_dev;
wl->operating = 1;
- wl->if_id = conf->if_id;
+ wl->vif = conf->vif;
wl->if_type = conf->type;
memcpy(wl->mac_addr, conf->mac_addr, ETH_ALEN);
@@ -3211,7 +3211,8 @@ static void b43legacy_op_remove_interfac
mutex_lock(&wl->mutex);
B43legacy_WARN_ON(!wl->operating);
- B43legacy_WARN_ON(wl->if_id != conf->if_id);
+ B43legacy_WARN_ON(wl->vif != conf->vif);
+ wl->vif = NULL;
wl->operating = 0;
--- everything.orig/drivers/net/wireless/b43legacy/xmit.c 2007-12-18 23:29:57.593023763 +0100
+++ everything/drivers/net/wireless/b43legacy/xmit.c 2007-12-19 00:50:11.343033149 +0100
@@ -223,7 +223,7 @@ static void generate_txhdr_fw3(struct b4
} else {
int fbrate_base100kbps = B43legacy_RATE_TO_100KBPS(rate_fb);
txhdr->dur_fb = ieee80211_generic_frame_duration(dev->wl->hw,
- dev->wl->if_id,
+ txctl->vif,
fragment_len,
fbrate_base100kbps);
}
@@ -312,7 +312,7 @@ static void generate_txhdr_fw3(struct b4
if (txctl->flags & IEEE80211_TXCTL_USE_CTS_PROTECT) {
ieee80211_ctstoself_get(dev->wl->hw,
- dev->wl->if_id,
+ txctl->vif,
fragment_data,
fragment_len, txctl,
(struct ieee80211_cts *)
@@ -321,7 +321,7 @@ static void generate_txhdr_fw3(struct b4
len = sizeof(struct ieee80211_cts);
} else {
ieee80211_rts_get(dev->wl->hw,
- dev->wl->if_id,
+ txctl->vif,
fragment_data, fragment_len, txctl,
(struct ieee80211_rts *)
(txhdr->rts_frame));
--- everything.orig/drivers/net/wireless/ath5k/base.c 2007-12-18 23:29:57.633022569 +0100
+++ everything/drivers/net/wireless/ath5k/base.c 2007-12-19 00:50:11.363023437 +0100
@@ -178,7 +178,8 @@ static void ath5k_remove_interface(struc
struct ieee80211_if_init_conf *conf);
static int ath5k_config(struct ieee80211_hw *hw,
struct ieee80211_conf *conf);
-static int ath5k_config_interface(struct ieee80211_hw *hw, int if_id,
+static int ath5k_config_interface(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
struct ieee80211_if_conf *conf);
static void ath5k_configure_filter(struct ieee80211_hw *hw,
unsigned int changed_flags,
@@ -2505,12 +2506,12 @@ static int ath5k_add_interface(struct ie
int ret;
mutex_lock(&sc->lock);
- if (sc->iface_id) {
+ if (sc->vif) {
ret = 0;
goto end;
}
- sc->iface_id = conf->if_id;
+ sc->vif = conf->vif;
switch (conf->type) {
case IEEE80211_IF_TYPE_STA:
@@ -2535,10 +2536,10 @@ ath5k_remove_interface(struct ieee80211_
struct ath5k_softc *sc = hw->priv;
mutex_lock(&sc->lock);
- if (sc->iface_id != conf->if_id)
+ if (sc->vif != conf->vif)
goto end;
- sc->iface_id = 0;
+ sc->vif = NULL;
end:
mutex_unlock(&sc->lock);
}
@@ -2556,7 +2557,7 @@ ath5k_config(struct ieee80211_hw *hw,
}
static int
-ath5k_config_interface(struct ieee80211_hw *hw, int if_id,
+ath5k_config_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
struct ieee80211_if_conf *conf)
{
struct ath5k_softc *sc = hw->priv;
@@ -2567,7 +2568,7 @@ ath5k_config_interface(struct ieee80211_
* be set to mac80211's value at ath5k_config(). */
sc->bintval = 1000 * 1000 / 1024;
mutex_lock(&sc->lock);
- if (sc->iface_id != if_id) {
+ if (sc->vif != vif) {
ret = -EIO;
goto unlock;
}
--- everything.orig/drivers/net/wireless/ath5k/base.h 2007-12-18 23:29:57.723023058 +0100
+++ everything/drivers/net/wireless/ath5k/base.h 2007-12-19 00:50:11.363023437 +0100
@@ -123,7 +123,7 @@ struct ath5k_softc {
unsigned int curmode; /* current phy mode */
struct ieee80211_channel *curchan; /* current h/w channel */
- int iface_id; /* add/remove_interface id */
+ struct ieee80211_vif *vif;
struct {
u8 rxflags; /* radiotap rx flags */
--- everything.orig/drivers/net/wireless/ath5k/hw.c 2007-12-18 23:29:57.803022895 +0100
+++ everything/drivers/net/wireless/ath5k/hw.c 2007-12-19 00:50:11.373051594 +0100
@@ -533,7 +533,7 @@ static inline void ath5k_hw_write_rate_d
* ieee80211_duration() for a brief description of
* what rate we should choose to TX ACKs. */
tx_time = ieee80211_generic_frame_duration(sc->hw,
- sc->iface_id, 10, control_rate->rate_kbps/100);
+ sc->vif, 10, control_rate->rate_kbps/100);
ath5k_hw_reg_write(ah, tx_time, reg);
--- everything.orig/drivers/net/wireless/iwlwifi/iwl-3945.h 2007-12-18 23:29:57.833022569 +0100
+++ everything/drivers/net/wireless/iwlwifi/iwl-3945.h 2007-12-19 00:50:11.373051594 +0100
@@ -885,7 +885,7 @@ struct iwl3945_priv {
u32 timestamp1;
u16 beacon_int;
struct iwl3945_driver_hw_info hw_setting;
- int interface_id;
+ struct ieee80211_vif *vif;
/* Current association information needed to configure the
* hardware */
--- everything.orig/drivers/net/wireless/iwlwifi/iwl-4965.h 2007-12-18 23:29:57.923024739 +0100
+++ everything/drivers/net/wireless/iwlwifi/iwl-4965.h 2007-12-19 00:50:11.383024304 +0100
@@ -1234,7 +1234,7 @@ struct iwl4965_priv {
u32 timestamp1;
u16 beacon_int;
struct iwl4965_driver_hw_info hw_setting;
- int interface_id;
+ struct ieee80211_vif *vif;
/* Current association information needed to configure the
* hardware */
--- everything.orig/drivers/net/wireless/rtl8187.h 2007-12-18 23:29:58.103023220 +0100
+++ everything/drivers/net/wireless/rtl8187.h 2007-12-19 00:50:11.383024304 +0100
@@ -65,8 +65,8 @@ struct rtl8187_priv {
/* common between rtl818x drivers */
struct rtl818x_csr *map;
void (*rf_init)(struct ieee80211_hw *);
+ struct ieee80211_vif *vif;
int mode;
- int if_id;
/* rtl8187 specific */
struct ieee80211_channel channels[14];
--- everything.orig/drivers/net/wireless/rtl8187_dev.c 2007-12-18 23:29:58.193023058 +0100
+++ everything/drivers/net/wireless/rtl8187_dev.c 2007-12-19 00:50:11.393023654 +0100
@@ -150,7 +150,8 @@ static int rtl8187_tx(struct ieee80211_h
flags |= RTL8187_TX_FLAG_MORE_FRAG;
if (control->flags & IEEE80211_TXCTL_USE_RTS_CTS) {
flags |= RTL8187_TX_FLAG_RTS;
- rts_dur = ieee80211_rts_duration(dev, priv->if_id, skb->len, control);
+ rts_dur = ieee80211_rts_duration(dev, priv->vif,
+ skb->len, control);
}
if (control->flags & IEEE80211_TXCTL_USE_CTS_PROTECT)
flags |= RTL8187_TX_FLAG_CTS;
@@ -566,14 +567,13 @@ static int rtl8187_config(struct ieee802
return 0;
}
-static int rtl8187_config_interface(struct ieee80211_hw *dev, int if_id,
+static int rtl8187_config_interface(struct ieee80211_hw *dev,
+ struct ieee80211_vif *vif,
struct ieee80211_if_conf *conf)
{
struct rtl8187_priv *priv = dev->priv;
int i;
- priv->if_id = if_id;
-
for (i = 0; i < ETH_ALEN; i++)
rtl818x_iowrite8(priv, &priv->map->BSSID[i], conf->bssid[i]);
--- everything.orig/drivers/net/wireless/adm8211.c 2007-12-18 23:29:58.243022623 +0100
+++ everything/drivers/net/wireless/adm8211.c 2007-12-19 00:50:11.463024087 +0100
@@ -1312,7 +1312,8 @@ static int adm8211_config(struct ieee802
return 0;
}
-static int adm8211_config_interface(struct ieee80211_hw *dev, int if_id,
+static int adm8211_config_interface(struct ieee80211_hw *dev,
+ struct ieee80211_vif *vif,
struct ieee80211_if_conf *conf)
{
struct adm8211_priv *priv = dev->priv;
--- everything.orig/drivers/net/wireless/p54common.c 2007-12-18 23:29:58.303023980 +0100
+++ everything/drivers/net/wireless/p54common.c 2007-12-19 00:50:11.463024087 +0100
@@ -854,7 +854,8 @@ static int p54_config(struct ieee80211_h
return ret;
}
-static int p54_config_interface(struct ieee80211_hw *dev, int if_id,
+static int p54_config_interface(struct ieee80211_hw *dev,
+ struct ieee80211_vif *vif,
struct ieee80211_if_conf *conf)
{
struct p54_common *priv = dev->priv;
--- everything.orig/drivers/net/wireless/rtl8180_dev.c 2007-12-18 23:29:58.323023057 +0100
+++ everything/drivers/net/wireless/rtl8180_dev.c 2007-12-19 00:50:11.473060384 +0100
@@ -235,7 +235,8 @@ static int rtl8180_tx(struct ieee80211_h
if (control->flags & IEEE80211_TXCTL_USE_RTS_CTS)
entry->rts_duration =
- ieee80211_rts_duration(dev, priv->if_id, skb->len, control);
+ ieee80211_rts_duration(dev, priv->vif, skb->len,
+ control);
if (!priv->r8185) {
unsigned int remainder;
@@ -624,6 +625,8 @@ static int rtl8180_add_interface(struct
return -EOPNOTSUPP;
}
+ priv->vif = conf->vif;
+
rtl818x_iowrite8(priv, &priv->map->EEPROM_CMD, RTL818X_EEPROM_CMD_CONFIG);
rtl818x_iowrite32(priv, (__le32 __iomem *)&priv->map->MAC[0],
cpu_to_le32(*(u32 *)conf->mac_addr));
@@ -639,6 +642,7 @@ static void rtl8180_remove_interface(str
{
struct rtl8180_priv *priv = dev->priv;
priv->mode = IEEE80211_IF_TYPE_MNTR;
+ priv->vif = NULL;
}
static int rtl8180_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf)
@@ -650,14 +654,13 @@ static int rtl8180_config(struct ieee802
return 0;
}
-static int rtl8180_config_interface(struct ieee80211_hw *dev, int if_id,
+static int rtl8180_config_interface(struct ieee80211_hw *dev,
+ struct ieee80211_vif *vif,
struct ieee80211_if_conf *conf)
{
struct rtl8180_priv *priv = dev->priv;
int i;
- priv->if_id = if_id;
-
for (i = 0; i < ETH_ALEN; i++)
rtl818x_iowrite8(priv, &priv->map->BSSID[i], conf->bssid[i]);
--- everything.orig/drivers/net/wireless/rtl8180.h 2007-12-18 23:29:58.433022514 +0100
+++ everything/drivers/net/wireless/rtl8180.h 2007-12-19 00:50:11.473060384 +0100
@@ -92,8 +92,8 @@ struct rtl8180_priv {
void (*rf_init)(struct ieee80211_hw *);
void (*rf_stop)(struct ieee80211_hw *);
void (*rf_set_chan)(struct ieee80211_hw *, struct ieee80211_conf *);
+ struct ieee80211_vif *vif;
int mode;
- int if_id;
/* rtl8180 driver specific */
spinlock_t lock;
--- everything.orig/drivers/net/wireless/iwlwifi/iwl3945-base.c 2007-12-18 23:29:57.953022732 +0100
+++ everything/drivers/net/wireless/iwlwifi/iwl3945-base.c 2007-12-19 00:50:11.493055664 +0100
@@ -2777,8 +2777,8 @@ static int iwl3945_tx_skb(struct iwl3945
goto drop_unlock;
}
- if (!priv->interface_id) {
- IWL_DEBUG_DROP("Dropping - !priv->interface_id\n");
+ if (!priv->vif) {
+ IWL_DEBUG_DROP("Dropping - !priv->vif\n");
goto drop_unlock;
}
@@ -3647,7 +3647,7 @@ static void iwl3945_bg_beacon_update(str
struct sk_buff *beacon;
/* Pull updated AP beacon from mac80211. will fail if not in AP mode */
- beacon = ieee80211_beacon_get(priv->hw, priv->interface_id, NULL);
+ beacon = ieee80211_beacon_get(priv->hw, priv->vif, NULL);
if (!beacon) {
IWL_ERROR("update beacon failed\n");
@@ -6864,7 +6864,7 @@ static void iwl3945_bg_post_associate(st
mutex_lock(&priv->mutex);
- if (!priv->interface_id || !priv->is_open) {
+ if (!priv->vif || !priv->is_open) {
mutex_unlock(&priv->mutex);
return;
}
@@ -7065,15 +7065,15 @@ static int iwl3945_mac_add_interface(str
unsigned long flags;
DECLARE_MAC_BUF(mac);
- IWL_DEBUG_MAC80211("enter: id %d, type %d\n", conf->if_id, conf->type);
+ IWL_DEBUG_MAC80211("enter: type %d\n", conf->type);
- if (priv->interface_id) {
- IWL_DEBUG_MAC80211("leave - interface_id != 0\n");
+ if (priv->vif) {
+ IWL_DEBUG_MAC80211("leave - vif != NULL\n");
return -EOPNOTSUPP;
}
spin_lock_irqsave(&priv->lock, flags);
- priv->interface_id = conf->if_id;
+ priv->vif = conf->vif;
spin_unlock_irqrestore(&priv->lock, flags);
@@ -7257,7 +7257,8 @@ static void iwl3945_config_ap(struct iwl
* clear sta table, add BCAST sta... */
}
-static int iwl3945_mac_config_interface(struct ieee80211_hw *hw, int if_id,
+static int iwl3945_mac_config_interface(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
struct ieee80211_if_conf *conf)
{
struct iwl3945_priv *priv = hw->priv;
@@ -7279,7 +7280,6 @@ static int iwl3945_mac_config_interface(
mutex_lock(&priv->mutex);
- IWL_DEBUG_MAC80211("enter: interface id %d\n", if_id);
if (conf->bssid)
IWL_DEBUG_MAC80211("bssid: %s\n",
print_mac(mac, conf->bssid));
@@ -7296,8 +7296,8 @@ static int iwl3945_mac_config_interface(
return 0;
}
- if (priv->interface_id != if_id) {
- IWL_DEBUG_MAC80211("leave - interface_id != if_id\n");
+ if (priv->vif != vif) {
+ IWL_DEBUG_MAC80211("leave - priv->vif != vif\n");
mutex_unlock(&priv->mutex);
return 0;
}
@@ -7395,8 +7395,8 @@ static void iwl3945_mac_remove_interface
priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
iwl3945_commit_rxon(priv);
}
- if (priv->interface_id == conf->if_id) {
- priv->interface_id = 0;
+ if (priv->vif == conf->vif) {
+ priv->vif = NULL;
memset(priv->bssid, 0, ETH_ALEN);
memset(priv->essid, 0, IW_ESSID_MAX_SIZE);
priv->essid_len = 0;
--- everything.orig/drivers/net/wireless/iwlwifi/iwl4965-base.c 2007-12-18 23:29:58.063023057 +0100
+++ everything/drivers/net/wireless/iwlwifi/iwl4965-base.c 2007-12-19 00:50:11.513023274 +0100
@@ -2898,8 +2898,8 @@ static int iwl4965_tx_skb(struct iwl4965
goto drop_unlock;
}
- if (!priv->interface_id) {
- IWL_DEBUG_DROP("Dropping - !priv->interface_id\n");
+ if (!priv->vif) {
+ IWL_DEBUG_DROP("Dropping - !priv->vif\n");
goto drop_unlock;
}
@@ -3981,7 +3981,7 @@ static void iwl4965_bg_beacon_update(str
struct sk_buff *beacon;
/* Pull updated AP beacon from mac80211. will fail if not in AP mode */
- beacon = ieee80211_beacon_get(priv->hw, priv->interface_id, NULL);
+ beacon = ieee80211_beacon_get(priv->hw, priv->vif, NULL);
if (!beacon) {
IWL_ERROR("update beacon failed\n");
@@ -7297,7 +7297,7 @@ static void iwl4965_bg_post_associate(st
mutex_lock(&priv->mutex);
- if (!priv->interface_id || !priv->is_open) {
+ if (!priv->vif || !priv->is_open) {
mutex_unlock(&priv->mutex);
return;
}
@@ -7508,15 +7508,15 @@ static int iwl4965_mac_add_interface(str
unsigned long flags;
DECLARE_MAC_BUF(mac);
- IWL_DEBUG_MAC80211("enter: id %d, type %d\n", conf->if_id, conf->type);
+ IWL_DEBUG_MAC80211("enter: type %d\n", conf->type);
- if (priv->interface_id) {
- IWL_DEBUG_MAC80211("leave - interface_id != 0\n");
+ if (priv->vif) {
+ IWL_DEBUG_MAC80211("leave - vif != NULL\n");
return 0;
}
spin_lock_irqsave(&priv->lock, flags);
- priv->interface_id = conf->if_id;
+ priv->vif = conf->vif;
spin_unlock_irqrestore(&priv->lock, flags);
@@ -7716,7 +7716,8 @@ static void iwl4965_config_ap(struct iwl
* clear sta table, add BCAST sta... */
}
-static int iwl4965_mac_config_interface(struct ieee80211_hw *hw, int if_id,
+static int iwl4965_mac_config_interface(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
struct ieee80211_if_conf *conf)
{
struct iwl4965_priv *priv = hw->priv;
@@ -7736,7 +7737,6 @@ static int iwl4965_mac_config_interface(
mutex_lock(&priv->mutex);
- IWL_DEBUG_MAC80211("enter: interface id %d\n", if_id);
if (conf->bssid)
IWL_DEBUG_MAC80211("bssid: %s\n",
print_mac(mac, conf->bssid));
@@ -7753,8 +7753,8 @@ static int iwl4965_mac_config_interface(
return 0;
}
- if (priv->interface_id != if_id) {
- IWL_DEBUG_MAC80211("leave - interface_id != if_id\n");
+ if (priv->vif != vif) {
+ IWL_DEBUG_MAC80211("leave - priv->vif != vif\n");
mutex_unlock(&priv->mutex);
return 0;
}
@@ -7852,8 +7852,8 @@ static void iwl4965_mac_remove_interface
priv->staging_rxon.filter_flags &= ~RXON_FILTER_ASSOC_MSK;
iwl4965_commit_rxon(priv);
}
- if (priv->interface_id == conf->if_id) {
- priv->interface_id = 0;
+ if (priv->vif == conf->vif) {
+ priv->vif = NULL;
memset(priv->bssid, 0, ETH_ALEN);
memset(priv->essid, 0, IW_ESSID_MAX_SIZE);
priv->essid_len = 0;
--- everything.orig/drivers/net/wireless/rt2x00/rt2x00.h 2007-12-18 23:29:58.463023058 +0100
+++ everything/drivers/net/wireless/rt2x00/rt2x00.h 2007-12-19 00:50:11.523048556 +0100
@@ -372,7 +372,7 @@ struct interface {
* to us by the 80211 stack, and is used to request
* new beacons.
*/
- int id;
+ struct ieee80211_vif *id;
/*
* Current working type (IEEE80211_IF_TYPE_*).
@@ -927,7 +927,8 @@ int rt2x00mac_add_interface(struct ieee8
void rt2x00mac_remove_interface(struct ieee80211_hw *hw,
struct ieee80211_if_init_conf *conf);
int rt2x00mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf);
-int rt2x00mac_config_interface(struct ieee80211_hw *hw, int if_id,
+int rt2x00mac_config_interface(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
struct ieee80211_if_conf *conf);
int rt2x00mac_get_stats(struct ieee80211_hw *hw,
struct ieee80211_low_level_stats *stats);
--- everything.orig/drivers/net/wireless/rt2x00/rt2x00mac.c 2007-12-18 23:29:58.533023166 +0100
+++ everything/drivers/net/wireless/rt2x00/rt2x00mac.c 2007-12-19 00:50:11.523048556 +0100
@@ -208,7 +208,7 @@ int rt2x00mac_add_interface(struct ieee8
is_interface_present(intf))
return -ENOBUFS;
- intf->id = conf->if_id;
+ intf->id = conf->vif;
intf->type = conf->type;
if (conf->type == IEEE80211_IF_TYPE_AP)
memcpy(&intf->bssid, conf->mac_addr, ETH_ALEN);
@@ -292,7 +292,8 @@ int rt2x00mac_config(struct ieee80211_hw
}
EXPORT_SYMBOL_GPL(rt2x00mac_config);
-int rt2x00mac_config_interface(struct ieee80211_hw *hw, int if_id,
+int rt2x00mac_config_interface(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
struct ieee80211_if_conf *conf)
{
struct rt2x00_dev *rt2x00dev = hw->priv;
--- everything.orig/drivers/net/wireless/zd1211rw/zd_mac.c 2007-12-18 23:29:58.603024251 +0100
+++ everything/drivers/net/wireless/zd1211rw/zd_mac.c 2007-12-19 00:50:11.533049315 +0100
@@ -718,7 +718,8 @@ static int zd_op_config(struct ieee80211
return zd_chip_set_channel(&mac->chip, conf->channel);
}
-static int zd_op_config_interface(struct ieee80211_hw *hw, int if_id,
+static int zd_op_config_interface(struct ieee80211_hw *hw,
+ struct ieee80211_vif *vif,
struct ieee80211_if_conf *conf)
{
struct zd_mac *mac = zd_hw_mac(hw);
--- everything.orig/net/mac80211/sta_info.c 2007-12-18 23:29:57.163025011 +0100
+++ everything/net/mac80211/sta_info.c 2007-12-19 00:50:11.533049315 +0100
@@ -160,9 +160,16 @@ struct sta_info * sta_info_add(struct ie
list_add(&sta->list, &local->sta_list);
local->num_sta++;
sta_info_hash_add(local, sta);
- if (local->ops->sta_notify)
- local->ops->sta_notify(local_to_hw(local), dev->ifindex,
- STA_NOTIFY_ADD, addr);
+ if (local->ops->sta_notify) {
+ struct ieee80211_sub_if_data *sdata;
+
+ sdata = IEEE80211_DEV_TO_SUB_IF(dev);
+ if (sdata->type == IEEE80211_IF_TYPE_VLAN)
+ sdata = sdata->u.vlan.ap;
+
+ local->ops->sta_notify(local_to_hw(local), &sdata->vif,
+ STA_NOTIFY_ADD, addr);
+ }
write_unlock_bh(&local->sta_lock);
#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
@@ -230,9 +237,17 @@ void sta_info_free(struct sta_info *sta)
ieee80211_key_free(sta->key);
sta->key = NULL;
- if (local->ops->sta_notify)
- local->ops->sta_notify(local_to_hw(local), sta->dev->ifindex,
- STA_NOTIFY_REMOVE, sta->addr);
+ if (local->ops->sta_notify) {
+ struct ieee80211_sub_if_data *sdata;
+
+ sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
+
+ if (sdata->type == IEEE80211_IF_TYPE_VLAN)
+ sdata = sdata->u.vlan.ap;
+
+ local->ops->sta_notify(local_to_hw(local), &sdata->vif,
+ STA_NOTIFY_REMOVE, sta->addr);
+ }
rate_control_remove_sta_debugfs(sta);
ieee80211_sta_debugfs_remove(sta);
--- everything.orig/net/mac80211/ieee80211_iface.c 2007-12-19 00:40:00.863027777 +0100
+++ everything/net/mac80211/ieee80211_iface.c 2007-12-19 00:50:11.533049315 +0100
@@ -47,7 +47,7 @@ int ieee80211_if_add(struct net_device *
int ret;
ASSERT_RTNL();
- ndev = alloc_netdev(sizeof(struct ieee80211_sub_if_data),
+ ndev = alloc_netdev(sizeof(*sdata) + local->hw.vif_data_size,
name, ieee80211_if_setup);
if (!ndev)
return -ENOMEM;
--
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 6/6] mac80211: move interface type to vif structure
2007-12-19 0:31 [PATCH 0/6] mac80211 updates Johannes Berg
` (4 preceding siblings ...)
2007-12-19 0:31 ` [PATCH 5/6] mac80211: dont use interface indices in drivers Johannes Berg
@ 2007-12-19 0:31 ` Johannes Berg
5 siblings, 0 replies; 7+ messages in thread
From: Johannes Berg @ 2007-12-19 0:31 UTC (permalink / raw)
To: John Linville; +Cc: Michael Wu, linux-wireless
Drivers that support mixed AP/STA operation may well need to
know the type of a virtual interface when iterating over them.
The easiest way to support that is to move the interface type
variable into the vif structure.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
include/net/mac80211.h | 2 +
net/mac80211/cfg.c | 2 -
net/mac80211/debugfs_netdev.c | 4 +-
net/mac80211/ieee80211.c | 36 +++++++++++-----------
net/mac80211/ieee80211_i.h | 1
net/mac80211/ieee80211_iface.c | 10 +++---
net/mac80211/ieee80211_ioctl.c | 65 ++++++++++++++++++++---------------------
net/mac80211/ieee80211_sta.c | 46 ++++++++++++++---------------
net/mac80211/key.c | 6 +--
net/mac80211/rx.c | 32 ++++++++++----------
net/mac80211/sta_info.c | 4 +-
net/mac80211/tx.c | 17 +++++-----
net/mac80211/util.c | 2 -
13 files changed, 114 insertions(+), 113 deletions(-)
--- everything.orig/include/net/mac80211.h 2007-12-19 00:50:11.193025987 +0100
+++ everything/include/net/mac80211.h 2007-12-19 00:50:13.963022840 +0100
@@ -535,10 +535,12 @@ enum ieee80211_if_types {
* Data in this structure is continually present for driver
* use during the life of a virtual interface.
*
+ * @type: type of this virtual interface
* @drv_priv: data area for driver use, will always be aligned to
* sizeof(void *).
*/
struct ieee80211_vif {
+ enum ieee80211_if_types type;
/* must be last */
u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *))));
};
--- everything.orig/net/mac80211/cfg.c 2007-12-18 23:29:55.493043131 +0100
+++ everything/net/mac80211/cfg.c 2007-12-19 00:50:13.963022840 +0100
@@ -90,7 +90,7 @@ static int ieee80211_change_iface(struct
sdata = IEEE80211_DEV_TO_SUB_IF(dev);
- if (sdata->type == IEEE80211_IF_TYPE_VLAN)
+ if (sdata->vif.type == IEEE80211_IF_TYPE_VLAN)
return -EOPNOTSUPP;
ieee80211_if_reinit(dev);
--- everything.orig/net/mac80211/debugfs_netdev.c 2007-12-19 00:40:00.863027777 +0100
+++ everything/net/mac80211/debugfs_netdev.c 2007-12-19 00:50:13.963022840 +0100
@@ -226,7 +226,7 @@ static void add_files(struct ieee80211_s
if (!sdata->debugfsdir)
return;
- switch (sdata->type) {
+ switch (sdata->vif.type) {
case IEEE80211_IF_TYPE_STA:
case IEEE80211_IF_TYPE_IBSS:
add_sta_files(sdata);
@@ -353,7 +353,7 @@ void ieee80211_debugfs_add_netdev(struct
void ieee80211_debugfs_remove_netdev(struct ieee80211_sub_if_data *sdata)
{
- del_files(sdata, sdata->type);
+ del_files(sdata, sdata->vif.type);
debugfs_remove(sdata->debugfsdir);
sdata->debugfsdir = NULL;
}
--- everything.orig/net/mac80211/ieee80211.c 2007-12-19 00:50:11.203023546 +0100
+++ everything/net/mac80211/ieee80211.c 2007-12-19 00:50:13.963022840 +0100
@@ -177,21 +177,21 @@ static int ieee80211_open(struct net_dev
/*
* check whether it may have the same address
*/
- if (!identical_mac_addr_allowed(sdata->type,
- nsdata->type))
+ if (!identical_mac_addr_allowed(sdata->vif.type,
+ nsdata->vif.type))
return -ENOTUNIQ;
/*
* can only add VLANs to enabled APs
*/
- if (sdata->type == IEEE80211_IF_TYPE_VLAN &&
- nsdata->type == IEEE80211_IF_TYPE_AP &&
+ if (sdata->vif.type == IEEE80211_IF_TYPE_VLAN &&
+ nsdata->vif.type == IEEE80211_IF_TYPE_AP &&
netif_running(nsdata->dev))
sdata->u.vlan.ap = nsdata;
}
}
- switch (sdata->type) {
+ switch (sdata->vif.type) {
case IEEE80211_IF_TYPE_WDS:
if (is_zero_ether_addr(sdata->u.wds.remote_addr))
return -ENOLINK;
@@ -221,7 +221,7 @@ static int ieee80211_open(struct net_dev
ieee80211_hw_config(local);
}
- switch (sdata->type) {
+ switch (sdata->vif.type) {
case IEEE80211_IF_TYPE_VLAN:
list_add(&sdata->u.vlan.list, &sdata->u.vlan.ap->u.ap.vlans);
/* no need to tell driver */
@@ -243,7 +243,7 @@ static int ieee80211_open(struct net_dev
/* fall through */
default:
conf.vif = &sdata->vif;
- conf.type = sdata->type;
+ conf.type = sdata->vif.type;
conf.mac_addr = dev->dev_addr;
res = local->ops->add_interface(local_to_hw(local), &conf);
if (res && !local->open_count && local->ops->stop)
@@ -255,7 +255,7 @@ static int ieee80211_open(struct net_dev
ieee80211_reset_erp_info(dev);
ieee80211_enable_keys(sdata);
- if (sdata->type == IEEE80211_IF_TYPE_STA &&
+ if (sdata->vif.type == IEEE80211_IF_TYPE_STA &&
!(sdata->flags & IEEE80211_SDATA_USERSPACE_MLME))
netif_carrier_off(dev);
else
@@ -312,7 +312,7 @@ static int ieee80211_stop(struct net_dev
dev_mc_unsync(local->mdev, dev);
/* down all dependent devices, that is VLANs */
- if (sdata->type == IEEE80211_IF_TYPE_AP) {
+ if (sdata->vif.type == IEEE80211_IF_TYPE_AP) {
struct ieee80211_sub_if_data *vlan, *tmp;
list_for_each_entry_safe(vlan, tmp, &sdata->u.ap.vlans,
@@ -323,7 +323,7 @@ static int ieee80211_stop(struct net_dev
local->open_count--;
- switch (sdata->type) {
+ switch (sdata->vif.type) {
case IEEE80211_IF_TYPE_VLAN:
list_del(&sdata->u.vlan.list);
sdata->u.vlan.ap = NULL;
@@ -369,7 +369,7 @@ static int ieee80211_stop(struct net_dev
/* fall through */
default:
conf.vif = &sdata->vif;
- conf.type = sdata->type;
+ conf.type = sdata->vif.type;
conf.mac_addr = dev->dev_addr;
/* disable all keys for as long as this netdev is down */
ieee80211_disable_keys(sdata);
@@ -490,13 +490,13 @@ static int __ieee80211_if_config(struct
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.type = sdata->vif.type;
+ if (sdata->vif.type == IEEE80211_IF_TYPE_STA ||
+ sdata->vif.type == IEEE80211_IF_TYPE_IBSS) {
conf.bssid = sdata->u.sta.bssid;
conf.ssid = sdata->u.sta.ssid;
conf.ssid_len = sdata->u.sta.ssid_len;
- } else if (sdata->type == IEEE80211_IF_TYPE_AP) {
+ } else if (sdata->vif.type == IEEE80211_IF_TYPE_AP) {
conf.ssid = sdata->u.ap.ssid;
conf.ssid_len = sdata->u.ap.ssid_len;
conf.beacon = beacon;
@@ -691,7 +691,7 @@ static void ieee80211_tasklet_handler(un
case IEEE80211_RX_MSG:
/* status is in skb->cb */
memcpy(&rx_status, skb->cb, sizeof(rx_status));
- /* Clear skb->type in order to not confuse kernel
+ /* Clear skb->pkt_type in order to not confuse kernel
* netstack. */
skb->pkt_type = 0;
__ieee80211_rx(local_to_hw(local), skb, &rx_status);
@@ -952,7 +952,7 @@ void ieee80211_tx_status(struct ieee8021
if (!monitors || !skb)
goto out;
- if (sdata->type == IEEE80211_IF_TYPE_MNTR) {
+ if (sdata->vif.type == IEEE80211_IF_TYPE_MNTR) {
if (!netif_running(sdata->dev))
continue;
monitors--;
@@ -1074,7 +1074,7 @@ struct ieee80211_hw *ieee80211_alloc_hw(
mdev->header_ops = &ieee80211_header_ops;
mdev->set_multicast_list = ieee80211_master_set_multicast_list;
- sdata->type = IEEE80211_IF_TYPE_AP;
+ sdata->vif.type = IEEE80211_IF_TYPE_AP;
sdata->dev = mdev;
sdata->local = local;
sdata->u.ap.force_unicast_rateidx = -1;
--- everything.orig/net/mac80211/ieee80211_iface.c 2007-12-19 00:50:11.533049315 +0100
+++ everything/net/mac80211/ieee80211_iface.c 2007-12-19 00:50:13.973022461 +0100
@@ -66,7 +66,7 @@ int ieee80211_if_add(struct net_device *
sdata = IEEE80211_DEV_TO_SUB_IF(ndev);
ndev->ieee80211_ptr = &sdata->wdev;
sdata->wdev.wiphy = local->hw.wiphy;
- sdata->type = IEEE80211_IF_TYPE_AP;
+ sdata->vif.type = IEEE80211_IF_TYPE_AP;
sdata->dev = ndev;
sdata->local = local;
ieee80211_if_sdata_init(sdata);
@@ -98,7 +98,7 @@ fail:
void ieee80211_if_set_type(struct net_device *dev, int type)
{
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
- int oldtype = sdata->type;
+ int oldtype = sdata->vif.type;
/*
* We need to call this function on the master interface
@@ -116,7 +116,7 @@ void ieee80211_if_set_type(struct net_de
/* most have no BSS pointer */
sdata->bss = NULL;
- sdata->type = type;
+ sdata->vif.type = type;
switch (type) {
case IEEE80211_IF_TYPE_WDS:
@@ -181,7 +181,7 @@ void ieee80211_if_reinit(struct net_devi
ieee80211_if_sdata_deinit(sdata);
- switch (sdata->type) {
+ switch (sdata->vif.type) {
case IEEE80211_IF_TYPE_INVALID:
/* cannot happen */
WARN_ON(1);
@@ -279,7 +279,7 @@ int ieee80211_if_remove(struct net_devic
ASSERT_RTNL();
list_for_each_entry_safe(sdata, n, &local->interfaces, list) {
- if ((sdata->type == id || id == -1) &&
+ if ((sdata->vif.type == id || id == -1) &&
strcmp(name, sdata->dev->name) == 0 &&
sdata->dev != local->mdev) {
list_del_rcu(&sdata->list);
--- everything.orig/net/mac80211/ieee80211_ioctl.c 2007-12-18 23:29:55.693022786 +0100
+++ everything/net/mac80211/ieee80211_ioctl.c 2007-12-19 00:50:13.973022461 +0100
@@ -111,8 +111,8 @@ static int ieee80211_ioctl_siwgenie(stru
if (sdata->flags & IEEE80211_SDATA_USERSPACE_MLME)
return -EOPNOTSUPP;
- if (sdata->type == IEEE80211_IF_TYPE_STA ||
- sdata->type == IEEE80211_IF_TYPE_IBSS) {
+ if (sdata->vif.type == IEEE80211_IF_TYPE_STA ||
+ sdata->vif.type == IEEE80211_IF_TYPE_IBSS) {
int ret = ieee80211_sta_set_extra_ie(dev, extra, data->length);
if (ret)
return ret;
@@ -231,7 +231,7 @@ static int ieee80211_ioctl_siwmode(struc
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
int type;
- if (sdata->type == IEEE80211_IF_TYPE_VLAN)
+ if (sdata->vif.type == IEEE80211_IF_TYPE_VLAN)
return -EOPNOTSUPP;
switch (*mode) {
@@ -248,7 +248,7 @@ static int ieee80211_ioctl_siwmode(struc
return -EINVAL;
}
- if (type == sdata->type)
+ if (type == sdata->vif.type)
return 0;
if (netif_running(dev))
return -EBUSY;
@@ -267,7 +267,7 @@ static int ieee80211_ioctl_giwmode(struc
struct ieee80211_sub_if_data *sdata;
sdata = IEEE80211_DEV_TO_SUB_IF(dev);
- switch (sdata->type) {
+ switch (sdata->vif.type) {
case IEEE80211_IF_TYPE_AP:
*mode = IW_MODE_MASTER;
break;
@@ -335,13 +335,13 @@ static int ieee80211_ioctl_siwfreq(struc
struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
- if (sdata->type == IEEE80211_IF_TYPE_STA)
+ if (sdata->vif.type == IEEE80211_IF_TYPE_STA)
sdata->u.sta.flags &= ~IEEE80211_STA_AUTO_CHANNEL_SEL;
/* freq->e == 0: freq->m = channel; otherwise freq = m * 10^e */
if (freq->e == 0) {
if (freq->m < 0) {
- if (sdata->type == IEEE80211_IF_TYPE_STA)
+ if (sdata->vif.type == IEEE80211_IF_TYPE_STA)
sdata->u.sta.flags |=
IEEE80211_STA_AUTO_CHANNEL_SEL;
return 0;
@@ -387,8 +387,8 @@ static int ieee80211_ioctl_siwessid(stru
len--;
sdata = IEEE80211_DEV_TO_SUB_IF(dev);
- if (sdata->type == IEEE80211_IF_TYPE_STA ||
- sdata->type == IEEE80211_IF_TYPE_IBSS) {
+ if (sdata->vif.type == IEEE80211_IF_TYPE_STA ||
+ sdata->vif.type == IEEE80211_IF_TYPE_IBSS) {
int ret;
if (sdata->flags & IEEE80211_SDATA_USERSPACE_MLME) {
if (len > IEEE80211_MAX_SSID_LEN)
@@ -408,7 +408,7 @@ static int ieee80211_ioctl_siwessid(stru
return 0;
}
- if (sdata->type == IEEE80211_IF_TYPE_AP) {
+ if (sdata->vif.type == IEEE80211_IF_TYPE_AP) {
memcpy(sdata->u.ap.ssid, ssid, len);
memset(sdata->u.ap.ssid + len, 0,
IEEE80211_MAX_SSID_LEN - len);
@@ -427,8 +427,8 @@ static int ieee80211_ioctl_giwessid(stru
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) {
+ if (sdata->vif.type == IEEE80211_IF_TYPE_STA ||
+ sdata->vif.type == IEEE80211_IF_TYPE_IBSS) {
int res = ieee80211_sta_get_ssid(dev, ssid, &len);
if (res == 0) {
data->length = len;
@@ -438,7 +438,7 @@ static int ieee80211_ioctl_giwessid(stru
return res;
}
- if (sdata->type == IEEE80211_IF_TYPE_AP) {
+ if (sdata->vif.type == IEEE80211_IF_TYPE_AP) {
len = sdata->u.ap.ssid_len;
if (len > IW_ESSID_MAX_SIZE)
len = IW_ESSID_MAX_SIZE;
@@ -458,8 +458,8 @@ static int ieee80211_ioctl_siwap(struct
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) {
+ if (sdata->vif.type == IEEE80211_IF_TYPE_STA ||
+ sdata->vif.type == IEEE80211_IF_TYPE_IBSS) {
int ret;
if (sdata->flags & IEEE80211_SDATA_USERSPACE_MLME) {
memcpy(sdata->u.sta.bssid, (u8 *) &ap_addr->sa_data,
@@ -478,7 +478,7 @@ static int ieee80211_ioctl_siwap(struct
return ret;
ieee80211_sta_req_auth(dev, &sdata->u.sta);
return 0;
- } else if (sdata->type == IEEE80211_IF_TYPE_WDS) {
+ } else if (sdata->vif.type == IEEE80211_IF_TYPE_WDS) {
if (memcmp(sdata->u.wds.remote_addr, (u8 *) &ap_addr->sa_data,
ETH_ALEN) == 0)
return 0;
@@ -496,12 +496,12 @@ static int ieee80211_ioctl_giwap(struct
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) {
+ if (sdata->vif.type == IEEE80211_IF_TYPE_STA ||
+ sdata->vif.type == IEEE80211_IF_TYPE_IBSS) {
ap_addr->sa_family = ARPHRD_ETHER;
memcpy(&ap_addr->sa_data, sdata->u.sta.bssid, ETH_ALEN);
return 0;
- } else if (sdata->type == IEEE80211_IF_TYPE_WDS) {
+ } else if (sdata->vif.type == IEEE80211_IF_TYPE_WDS) {
ap_addr->sa_family = ARPHRD_ETHER;
memcpy(&ap_addr->sa_data, sdata->u.wds.remote_addr, ETH_ALEN);
return 0;
@@ -523,11 +523,10 @@ static int ieee80211_ioctl_siwscan(struc
if (!netif_running(dev))
return -ENETDOWN;
- if (sdata->type != IEEE80211_IF_TYPE_STA &&
- sdata->type != IEEE80211_IF_TYPE_IBSS &&
- sdata->type != IEEE80211_IF_TYPE_AP) {
+ if (sdata->vif.type != IEEE80211_IF_TYPE_STA &&
+ sdata->vif.type != IEEE80211_IF_TYPE_IBSS &&
+ sdata->vif.type != IEEE80211_IF_TYPE_AP)
return -EOPNOTSUPP;
- }
/* if SSID was specified explicitly then use that */
if (wrqu->data.length == sizeof(struct iw_scan_req) &&
@@ -605,7 +604,7 @@ static int ieee80211_ioctl_giwrate(struc
struct ieee80211_sub_if_data *sdata;
sdata = IEEE80211_DEV_TO_SUB_IF(dev);
- if (sdata->type == IEEE80211_IF_TYPE_STA)
+ if (sdata->vif.type == IEEE80211_IF_TYPE_STA)
sta = sta_info_get(local, sdata->u.sta.bssid);
else
return -EOPNOTSUPP;
@@ -818,8 +817,8 @@ static int ieee80211_ioctl_siwmlme(struc
struct iw_mlme *mlme = (struct iw_mlme *) extra;
sdata = IEEE80211_DEV_TO_SUB_IF(dev);
- if (sdata->type != IEEE80211_IF_TYPE_STA &&
- sdata->type != IEEE80211_IF_TYPE_IBSS)
+ if (sdata->vif.type != IEEE80211_IF_TYPE_STA &&
+ sdata->vif.type != IEEE80211_IF_TYPE_IBSS)
return -EINVAL;
switch (mlme->cmd) {
@@ -936,7 +935,7 @@ static int ieee80211_ioctl_siwauth(struc
sdata->drop_unencrypted = !!data->value;
break;
case IW_AUTH_PRIVACY_INVOKED:
- if (sdata->type != IEEE80211_IF_TYPE_STA)
+ if (sdata->vif.type != IEEE80211_IF_TYPE_STA)
ret = -EINVAL;
else {
sdata->u.sta.flags &= ~IEEE80211_STA_PRIVACY_INVOKED;
@@ -951,8 +950,8 @@ static int ieee80211_ioctl_siwauth(struc
}
break;
case IW_AUTH_80211_AUTH_ALG:
- if (sdata->type == IEEE80211_IF_TYPE_STA ||
- sdata->type == IEEE80211_IF_TYPE_IBSS)
+ if (sdata->vif.type == IEEE80211_IF_TYPE_STA ||
+ sdata->vif.type == IEEE80211_IF_TYPE_IBSS)
sdata->u.sta.auth_algs = data->value;
else
ret = -EOPNOTSUPP;
@@ -972,8 +971,8 @@ static struct iw_statistics *ieee80211_g
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
struct sta_info *sta = NULL;
- if (sdata->type == IEEE80211_IF_TYPE_STA ||
- sdata->type == IEEE80211_IF_TYPE_IBSS)
+ if (sdata->vif.type == IEEE80211_IF_TYPE_STA ||
+ sdata->vif.type == IEEE80211_IF_TYPE_IBSS)
sta = sta_info_get(local, sdata->u.sta.bssid);
if (!sta) {
wstats->discard.fragment = 0;
@@ -1001,8 +1000,8 @@ static int ieee80211_ioctl_giwauth(struc
switch (data->flags & IW_AUTH_INDEX) {
case IW_AUTH_80211_AUTH_ALG:
- if (sdata->type == IEEE80211_IF_TYPE_STA ||
- sdata->type == IEEE80211_IF_TYPE_IBSS)
+ if (sdata->vif.type == IEEE80211_IF_TYPE_STA ||
+ sdata->vif.type == IEEE80211_IF_TYPE_IBSS)
data->value = sdata->u.sta.auth_algs;
else
ret = -EOPNOTSUPP;
--- everything.orig/net/mac80211/ieee80211_sta.c 2007-12-19 00:48:26.783024250 +0100
+++ everything/net/mac80211/ieee80211_sta.c 2007-12-19 00:50:13.983023871 +0100
@@ -464,7 +464,7 @@ static void ieee80211_set_associated(str
ifsta->flags |= IEEE80211_STA_ASSOCIATED;
sdata = IEEE80211_DEV_TO_SUB_IF(dev);
- if (sdata->type != IEEE80211_IF_TYPE_STA)
+ if (sdata->vif.type != IEEE80211_IF_TYPE_STA)
return;
bss = ieee80211_rx_bss_get(dev, ifsta->bssid,
@@ -1017,7 +1017,7 @@ static void ieee80211_send_addba_resp(st
memset(mgmt, 0, 24);
memcpy(mgmt->da, da, ETH_ALEN);
memcpy(mgmt->sa, dev->dev_addr, ETH_ALEN);
- if (sdata->type == IEEE80211_IF_TYPE_AP)
+ if (sdata->vif.type == IEEE80211_IF_TYPE_AP)
memcpy(mgmt->bssid, dev->dev_addr, ETH_ALEN);
else
memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN);
@@ -1090,7 +1090,7 @@ static void ieee80211_rx_mgmt_auth(struc
DECLARE_MAC_BUF(mac);
if (ifsta->state != IEEE80211_AUTHENTICATE &&
- sdata->type != IEEE80211_IF_TYPE_IBSS) {
+ sdata->vif.type != IEEE80211_IF_TYPE_IBSS) {
printk(KERN_DEBUG "%s: authentication frame received from "
"%s, but not in authenticate state - ignored\n",
dev->name, print_mac(mac, mgmt->sa));
@@ -1104,7 +1104,7 @@ static void ieee80211_rx_mgmt_auth(struc
return;
}
- if (sdata->type != IEEE80211_IF_TYPE_IBSS &&
+ if (sdata->vif.type != IEEE80211_IF_TYPE_IBSS &&
memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN) != 0) {
printk(KERN_DEBUG "%s: authentication frame received from "
"unknown AP (SA=%s BSSID=%s) - "
@@ -1113,7 +1113,7 @@ static void ieee80211_rx_mgmt_auth(struc
return;
}
- if (sdata->type != IEEE80211_IF_TYPE_IBSS &&
+ if (sdata->vif.type != IEEE80211_IF_TYPE_IBSS &&
memcmp(ifsta->bssid, mgmt->bssid, ETH_ALEN) != 0) {
printk(KERN_DEBUG "%s: authentication frame received from "
"unknown BSSID (SA=%s BSSID=%s) - "
@@ -1131,7 +1131,7 @@ static void ieee80211_rx_mgmt_auth(struc
dev->name, print_mac(mac, mgmt->sa), auth_alg,
auth_transaction, status_code);
- if (sdata->type == IEEE80211_IF_TYPE_IBSS) {
+ if (sdata->vif.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
@@ -1624,7 +1624,7 @@ static void ieee80211_rx_bss_info(struct
timestamp = le64_to_cpu(mgmt->u.beacon.timestamp);
- if (sdata->type == IEEE80211_IF_TYPE_IBSS && beacon &&
+ if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS && beacon &&
memcmp(mgmt->bssid, sdata->u.sta.bssid, ETH_ALEN) == 0) {
#ifdef CONFIG_MAC80211_IBSS_DEBUG
static unsigned long last_tsf_debug = 0;
@@ -1649,7 +1649,7 @@ static void ieee80211_rx_bss_info(struct
ieee802_11_parse_elems(mgmt->u.beacon.variable, len - baselen, &elems);
- if (sdata->type == IEEE80211_IF_TYPE_IBSS && elems.supp_rates &&
+ if (sdata->vif.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_hw_mode *mode;
@@ -1878,7 +1878,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_IF_TYPE_STA)
+ if (sdata->vif.type != IEEE80211_IF_TYPE_STA)
return;
ifsta = &sdata->u.sta;
@@ -1938,7 +1938,7 @@ static void ieee80211_rx_mgmt_probe_req(
DECLARE_MAC_BUF(mac3);
#endif
- if (sdata->type != IEEE80211_IF_TYPE_IBSS ||
+ if (sdata->vif.type != IEEE80211_IF_TYPE_IBSS ||
ifsta->state != IEEE80211_IBSS_JOINED ||
len < 24 + 2 || !ifsta->probe_resp)
return;
@@ -2243,10 +2243,10 @@ void ieee80211_sta_work(struct work_stru
if (local->sta_sw_scanning || local->sta_hw_scanning)
return;
- if (sdata->type != IEEE80211_IF_TYPE_STA &&
- sdata->type != IEEE80211_IF_TYPE_IBSS) {
+ if (sdata->vif.type != IEEE80211_IF_TYPE_STA &&
+ sdata->vif.type != IEEE80211_IF_TYPE_IBSS) {
printk(KERN_DEBUG "%s: ieee80211_sta_work: non-STA interface "
- "(type=%d)\n", dev->name, sdata->type);
+ "(type=%d)\n", dev->name, sdata->vif.type);
return;
}
ifsta = &sdata->u.sta;
@@ -2341,7 +2341,7 @@ void ieee80211_sta_req_auth(struct net_d
struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
- if (sdata->type != IEEE80211_IF_TYPE_STA)
+ if (sdata->vif.type != IEEE80211_IF_TYPE_STA)
return;
if ((ifsta->flags & (IEEE80211_STA_BSSID_SET |
@@ -2811,7 +2811,7 @@ int ieee80211_sta_set_ssid(struct net_de
ifsta->flags |= IEEE80211_STA_SSID_SET;
else
ifsta->flags &= ~IEEE80211_STA_SSID_SET;
- if (sdata->type == IEEE80211_IF_TYPE_IBSS &&
+ if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS &&
!(ifsta->flags & IEEE80211_STA_BSSID_SET)) {
ifsta->ibss_join_req = jiffies;
ifsta->state = IEEE80211_IBSS_SEARCH;
@@ -2929,7 +2929,7 @@ void ieee80211_scan_completed(struct iee
if (sdata->dev == local->mdev)
continue;
- if (sdata->type == IEEE80211_IF_TYPE_STA) {
+ if (sdata->vif.type == IEEE80211_IF_TYPE_STA) {
if (sdata->u.sta.flags & IEEE80211_STA_ASSOCIATED)
ieee80211_send_nullfunc(local, sdata, 0);
ieee80211_sta_timer((unsigned long)sdata);
@@ -2941,7 +2941,7 @@ void ieee80211_scan_completed(struct iee
done:
sdata = IEEE80211_DEV_TO_SUB_IF(dev);
- if (sdata->type == IEEE80211_IF_TYPE_IBSS) {
+ if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS) {
struct ieee80211_if_sta *ifsta = &sdata->u.sta;
if (!(ifsta->flags & IEEE80211_STA_BSSID_SET) ||
(!ifsta->state == IEEE80211_IBSS_JOINED &&
@@ -2976,7 +2976,7 @@ void ieee80211_sta_scan_work(struct work
skip = !(local->enabled_modes & (1 << mode->mode));
chan = &mode->channels[local->scan_channel_idx];
if (!(chan->flag & IEEE80211_CHAN_W_SCAN) ||
- (sdata->type == IEEE80211_IF_TYPE_IBSS &&
+ (sdata->vif.type == IEEE80211_IF_TYPE_IBSS &&
!(chan->flag & IEEE80211_CHAN_W_IBSS)) ||
(local->hw_modes & local->enabled_modes &
(1 << MODE_IEEE80211G) && mode->mode == MODE_IEEE80211B))
@@ -3084,7 +3084,7 @@ static int ieee80211_sta_start_scan(stru
continue;
netif_stop_queue(sdata->dev);
- if (sdata->type == IEEE80211_IF_TYPE_STA &&
+ if (sdata->vif.type == IEEE80211_IF_TYPE_STA &&
(sdata->u.sta.flags & IEEE80211_STA_ASSOCIATED))
ieee80211_send_nullfunc(local, sdata, 1);
}
@@ -3125,7 +3125,7 @@ int ieee80211_sta_req_scan(struct net_de
struct ieee80211_if_sta *ifsta = &sdata->u.sta;
struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
- if (sdata->type != IEEE80211_IF_TYPE_STA)
+ if (sdata->vif.type != IEEE80211_IF_TYPE_STA)
return ieee80211_sta_start_scan(dev, ssid, ssid_len);
if (local->sta_sw_scanning || local->sta_hw_scanning) {
@@ -3348,8 +3348,8 @@ int ieee80211_sta_deauthenticate(struct
printk(KERN_DEBUG "%s: deauthenticate(reason=%d)\n",
dev->name, reason);
- if (sdata->type != IEEE80211_IF_TYPE_STA &&
- sdata->type != IEEE80211_IF_TYPE_IBSS)
+ if (sdata->vif.type != IEEE80211_IF_TYPE_STA &&
+ sdata->vif.type != IEEE80211_IF_TYPE_IBSS)
return -EINVAL;
ieee80211_send_deauth(dev, ifsta, reason);
@@ -3366,7 +3366,7 @@ int ieee80211_sta_disassociate(struct ne
printk(KERN_DEBUG "%s: disassociate(reason=%d)\n",
dev->name, reason);
- if (sdata->type != IEEE80211_IF_TYPE_STA)
+ if (sdata->vif.type != IEEE80211_IF_TYPE_STA)
return -EINVAL;
if (!(ifsta->flags & IEEE80211_STA_ASSOCIATED))
--- everything.orig/net/mac80211/key.c 2007-12-18 23:29:55.803040906 +0100
+++ everything/net/mac80211/key.c 2007-12-19 00:50:13.983023871 +0100
@@ -49,8 +49,8 @@ static const u8 *get_mac_for_key(struct
* address to indicate a transmit-only key.
*/
if (key->conf.alg != ALG_WEP &&
- (key->sdata->type == IEEE80211_IF_TYPE_AP ||
- key->sdata->type == IEEE80211_IF_TYPE_VLAN))
+ (key->sdata->vif.type == IEEE80211_IF_TYPE_AP ||
+ key->sdata->vif.type == IEEE80211_IF_TYPE_VLAN))
addr = zero_addr;
if (key->sta)
@@ -172,7 +172,7 @@ struct ieee80211_key *ieee80211_key_allo
if (sta->flags & WLAN_STA_WME)
key->conf.flags |= IEEE80211_KEY_FLAG_WMM_STA;
} else {
- if (sdata->type == IEEE80211_IF_TYPE_STA) {
+ if (sdata->vif.type == IEEE80211_IF_TYPE_STA) {
struct sta_info *ap;
/* same here, the AP could be using QoS */
--- everything.orig/net/mac80211/rx.c 2007-12-19 00:40:00.863027777 +0100
+++ everything/net/mac80211/rx.c 2007-12-19 00:50:13.983023871 +0100
@@ -215,7 +215,7 @@ ieee80211_rx_monitor(struct ieee80211_lo
if (!netif_running(sdata->dev))
continue;
- if (sdata->type != IEEE80211_IF_TYPE_MNTR)
+ if (sdata->vif.type != IEEE80211_IF_TYPE_MNTR)
continue;
if (prev_dev) {
@@ -414,7 +414,7 @@ ieee80211_rx_h_check(struct ieee80211_tx
if (unlikely(((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA ||
((rx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL &&
(rx->fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PSPOLL)) &&
- rx->sdata->type != IEEE80211_IF_TYPE_IBSS &&
+ rx->sdata->vif.type != IEEE80211_IF_TYPE_IBSS &&
(!rx->sta || !(rx->sta->flags & WLAN_STA_ASSOC)))) {
if ((!(rx->fc & IEEE80211_FCTL_FROMDS) &&
!(rx->fc & IEEE80211_FCTL_TODS) &&
@@ -634,13 +634,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_IF_TYPE_IBSS) {
+ if (rx->sdata->vif.type == IEEE80211_IF_TYPE_IBSS) {
u8 *bssid = ieee80211_get_bssid(hdr, rx->skb->len);
if (compare_ether_addr(bssid, rx->sdata->u.sta.bssid) == 0)
sta->last_rx = jiffies;
} else
if (!is_multicast_ether_addr(hdr->addr1) ||
- rx->sdata->type == IEEE80211_IF_TYPE_STA) {
+ rx->sdata->vif.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.
@@ -1047,8 +1047,8 @@ ieee80211_data_to_8023(struct ieee80211_
memcpy(dst, hdr->addr3, ETH_ALEN);
memcpy(src, hdr->addr2, ETH_ALEN);
- if (unlikely(sdata->type != IEEE80211_IF_TYPE_AP &&
- sdata->type != IEEE80211_IF_TYPE_VLAN)) {
+ if (unlikely(sdata->vif.type != IEEE80211_IF_TYPE_AP &&
+ sdata->vif.type != IEEE80211_IF_TYPE_VLAN)) {
if (net_ratelimit())
printk(KERN_DEBUG "%s: dropped ToDS frame "
"(BSSID=%s SA=%s DA=%s)\n",
@@ -1064,7 +1064,7 @@ ieee80211_data_to_8023(struct ieee80211_
memcpy(dst, hdr->addr3, ETH_ALEN);
memcpy(src, hdr->addr4, ETH_ALEN);
- if (unlikely(sdata->type != IEEE80211_IF_TYPE_WDS)) {
+ if (unlikely(sdata->vif.type != IEEE80211_IF_TYPE_WDS)) {
if (net_ratelimit())
printk(KERN_DEBUG "%s: dropped FromDS&ToDS "
"frame (RA=%s TA=%s DA=%s SA=%s)\n",
@@ -1081,7 +1081,7 @@ ieee80211_data_to_8023(struct ieee80211_
memcpy(dst, hdr->addr1, ETH_ALEN);
memcpy(src, hdr->addr3, ETH_ALEN);
- if (sdata->type != IEEE80211_IF_TYPE_STA ||
+ if (sdata->vif.type != IEEE80211_IF_TYPE_STA ||
(is_multicast_ether_addr(dst) &&
!compare_ether_addr(src, dev->dev_addr)))
return -1;
@@ -1091,7 +1091,7 @@ ieee80211_data_to_8023(struct ieee80211_
memcpy(dst, hdr->addr1, ETH_ALEN);
memcpy(src, hdr->addr2, ETH_ALEN);
- if (sdata->type != IEEE80211_IF_TYPE_IBSS) {
+ if (sdata->vif.type != IEEE80211_IF_TYPE_IBSS) {
if (net_ratelimit()) {
printk(KERN_DEBUG "%s: dropped IBSS frame "
"(DA=%s SA=%s BSSID=%s)\n",
@@ -1179,8 +1179,8 @@ ieee80211_deliver_skb(struct ieee80211_t
skb = rx->skb;
xmit_skb = NULL;
- if (local->bridge_packets && (sdata->type == IEEE80211_IF_TYPE_AP ||
- sdata->type == IEEE80211_IF_TYPE_VLAN) &&
+ if (local->bridge_packets && (sdata->vif.type == IEEE80211_IF_TYPE_AP ||
+ sdata->vif.type == IEEE80211_IF_TYPE_VLAN) &&
(rx->flags & IEEE80211_TXRXD_RXRA_MATCH)) {
if (is_multicast_ether_addr(ehdr->h_dest)) {
/*
@@ -1381,8 +1381,8 @@ ieee80211_rx_h_mgmt(struct ieee80211_txr
return TXRX_DROP;
sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev);
- if ((sdata->type == IEEE80211_IF_TYPE_STA ||
- sdata->type == IEEE80211_IF_TYPE_IBSS) &&
+ if ((sdata->vif.type == IEEE80211_IF_TYPE_STA ||
+ sdata->vif.type == IEEE80211_IF_TYPE_IBSS) &&
!(sdata->flags & IEEE80211_SDATA_USERSPACE_MLME))
ieee80211_sta_rx_mgmt(rx->dev, rx->skb, rx->u.rx.status);
else
@@ -1474,7 +1474,7 @@ static void ieee80211_rx_michael_mic_rep
goto ignore;
}
- if (rx->sdata->type == IEEE80211_IF_TYPE_AP && keyidx) {
+ if (rx->sdata->vif.type == IEEE80211_IF_TYPE_AP && keyidx) {
/*
* APs with pairwise keys should never receive Michael MIC
* errors for non-zero keyidx because these are reserved for
@@ -1535,7 +1535,7 @@ static int prepare_for_handlers(struct i
{
int multicast = is_multicast_ether_addr(hdr->addr1);
- switch (sdata->type) {
+ switch (sdata->vif.type) {
case IEEE80211_IF_TYPE_STA:
if (!bssid)
return 0;
@@ -1703,7 +1703,7 @@ void __ieee80211_rx(struct ieee80211_hw
if (!netif_running(sdata->dev))
continue;
- if (sdata->type == IEEE80211_IF_TYPE_MNTR)
+ if (sdata->vif.type == IEEE80211_IF_TYPE_MNTR)
continue;
rx.flags |= IEEE80211_TXRXD_RXRA_MATCH;
--- everything.orig/net/mac80211/tx.c 2007-12-19 00:50:11.223023816 +0100
+++ everything/net/mac80211/tx.c 2007-12-19 00:50:13.993023057 +0100
@@ -237,7 +237,7 @@ ieee80211_tx_h_check_assoc(struct ieee80
if (likely(tx->flags & IEEE80211_TXRXD_TXUNICAST)) {
if (unlikely(!(sta_flags & WLAN_STA_ASSOC) &&
- tx->sdata->type != IEEE80211_IF_TYPE_IBSS &&
+ tx->sdata->vif.type != IEEE80211_IF_TYPE_IBSS &&
(tx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA)) {
#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
DECLARE_MAC_BUF(mac);
@@ -251,7 +251,7 @@ ieee80211_tx_h_check_assoc(struct ieee80
} else {
if (unlikely((tx->fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA &&
tx->local->num_sta == 0 &&
- tx->sdata->type != IEEE80211_IF_TYPE_IBSS)) {
+ tx->sdata->vif.type != IEEE80211_IF_TYPE_IBSS)) {
/*
* No associated STAs - no need to send multicast
* frames.
@@ -294,7 +294,7 @@ static void purge_old_ps_buffers(struct
list_for_each_entry_rcu(sdata, &local->interfaces, list) {
struct ieee80211_if_ap *ap;
if (sdata->dev == local->mdev ||
- sdata->type != IEEE80211_IF_TYPE_AP)
+ sdata->vif.type != IEEE80211_IF_TYPE_AP)
continue;
ap = &sdata->u.ap;
skb = skb_dequeue(&ap->ps_bc_buf);
@@ -954,7 +954,7 @@ __ieee80211_tx_prepare(struct ieee80211_
/* process and remove the injection radiotap header */
sdata = IEEE80211_DEV_TO_SUB_IF(dev);
- if (unlikely(sdata->type == IEEE80211_IF_TYPE_MNTR)) {
+ if (unlikely(sdata->vif.type == IEEE80211_IF_TYPE_MNTR)) {
if (__ieee80211_parse_tx_radiotap(tx, skb) == TXRX_DROP)
return TXRX_DROP;
@@ -1257,7 +1257,7 @@ int ieee80211_master_start_xmit(struct s
}
control.vif = &osdata->vif;
- control.type = osdata->type;
+ control.type = osdata->vif.type;
if (pkt_data->flags & IEEE80211_TXPD_REQ_TX_STATUS)
control.flags |= IEEE80211_TXCTL_REQ_TX_STATUS;
if (pkt_data->flags & IEEE80211_TXPD_DO_NOT_ENCRYPT)
@@ -1376,7 +1376,7 @@ int ieee80211_subif_start_xmit(struct sk
ethertype = (skb->data[12] << 8) | skb->data[13];
fc = IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA;
- switch (sdata->type) {
+ switch (sdata->vif.type) {
case IEEE80211_IF_TYPE_AP:
case IEEE80211_IF_TYPE_VLAN:
fc |= IEEE80211_FCTL_FROMDS;
@@ -1713,7 +1713,7 @@ struct sk_buff *ieee80211_beacon_get(str
bdev = sdata->dev;
ap = &sdata->u.ap;
- if (!ap || sdata->type != IEEE80211_IF_TYPE_AP ||
+ if (!ap || sdata->vif.type != IEEE80211_IF_TYPE_AP ||
!ap->beacon_head) {
#ifdef CONFIG_MAC80211_VERBOSE_DEBUG
if (net_ratelimit())
@@ -1826,7 +1826,8 @@ ieee80211_get_buffered_bc(struct ieee802
sdata = vif_to_sdata(vif);
bdev = sdata->dev;
- if (!bss || sdata->type != IEEE80211_IF_TYPE_AP || !bss->beacon_head)
+ if (!bss || sdata->vif.type != IEEE80211_IF_TYPE_AP ||
+ !bss->beacon_head)
return NULL;
if (bss->dtim_count != 0)
--- everything.orig/net/mac80211/util.c 2007-12-19 00:50:11.213056044 +0100
+++ everything/net/mac80211/util.c 2007-12-19 00:50:13.993023057 +0100
@@ -453,7 +453,7 @@ void ieee80211_iterate_active_interfaces
rcu_read_lock();
list_for_each_entry_rcu(sdata, &local->interfaces, list) {
- switch (sdata->type) {
+ switch (sdata->vif.type) {
case IEEE80211_IF_TYPE_INVALID:
case IEEE80211_IF_TYPE_MNTR:
case IEEE80211_IF_TYPE_VLAN:
--- everything.orig/net/mac80211/ieee80211_i.h 2007-12-19 00:50:11.213056044 +0100
+++ everything/net/mac80211/ieee80211_i.h 2007-12-19 00:50:14.003022188 +0100
@@ -294,7 +294,6 @@ struct ieee80211_if_sta {
#define IEEE80211_SDATA_USERSPACE_MLME BIT(4)
struct ieee80211_sub_if_data {
struct list_head list;
- enum ieee80211_if_types type;
struct wireless_dev wdev;
--- everything.orig/net/mac80211/sta_info.c 2007-12-19 00:50:11.533049315 +0100
+++ everything/net/mac80211/sta_info.c 2007-12-19 00:50:14.003022188 +0100
@@ -164,7 +164,7 @@ struct sta_info * sta_info_add(struct ie
struct ieee80211_sub_if_data *sdata;
sdata = IEEE80211_DEV_TO_SUB_IF(dev);
- if (sdata->type == IEEE80211_IF_TYPE_VLAN)
+ if (sdata->vif.type == IEEE80211_IF_TYPE_VLAN)
sdata = sdata->u.vlan.ap;
local->ops->sta_notify(local_to_hw(local), &sdata->vif,
@@ -242,7 +242,7 @@ void sta_info_free(struct sta_info *sta)
sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
- if (sdata->type == IEEE80211_IF_TYPE_VLAN)
+ if (sdata->vif.type == IEEE80211_IF_TYPE_VLAN)
sdata = sdata->u.vlan.ap;
local->ops->sta_notify(local_to_hw(local), &sdata->vif,
--
^ permalink raw reply [flat|nested] 7+ messages in thread