Commit dc822b5d authored by Johannes Berg's avatar Johannes Berg Committed by John W. Linville

mac80211: clean up set_key callback

The set_key callback now seems rather odd, passing a MAC address
instead of a station struct, and a local address instead of a
vif struct. Change that.
Signed-off-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Acked-by: Bob Copeland <me@bobcopeland.com> [ath5k]
Acked-by: Ivo van Doorn <ivdoorn@gmail.com> [rt2x00]
Acked-by: Christian Lamparter <chunkeey@web.de> [p54]
Tested-by: Kalle Valo <kalle.valo@nokia.com> [iwl3945]
Tested-by: Samuel Ortiz <samuel@sortiz.org> [iwl3945]
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent b3093664
...@@ -232,7 +232,7 @@ static void ath5k_configure_filter(struct ieee80211_hw *hw, ...@@ -232,7 +232,7 @@ static void ath5k_configure_filter(struct ieee80211_hw *hw,
int mc_count, struct dev_mc_list *mclist); int mc_count, struct dev_mc_list *mclist);
static int ath5k_set_key(struct ieee80211_hw *hw, static int ath5k_set_key(struct ieee80211_hw *hw,
enum set_key_cmd cmd, enum set_key_cmd cmd,
const u8 *local_addr, const u8 *addr, struct ieee80211_vif *vif, struct ieee80211_sta *sta,
struct ieee80211_key_conf *key); struct ieee80211_key_conf *key);
static int ath5k_get_stats(struct ieee80211_hw *hw, static int ath5k_get_stats(struct ieee80211_hw *hw,
struct ieee80211_low_level_stats *stats); struct ieee80211_low_level_stats *stats);
...@@ -2991,8 +2991,8 @@ static void ath5k_configure_filter(struct ieee80211_hw *hw, ...@@ -2991,8 +2991,8 @@ static void ath5k_configure_filter(struct ieee80211_hw *hw,
static int static int
ath5k_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, ath5k_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
const u8 *local_addr, const u8 *addr, struct ieee80211_vif *vif, struct ieee80211_sta *sta,
struct ieee80211_key_conf *key) struct ieee80211_key_conf *key)
{ {
struct ath5k_softc *sc = hw->priv; struct ath5k_softc *sc = hw->priv;
int ret = 0; int ret = 0;
...@@ -3015,7 +3015,8 @@ ath5k_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, ...@@ -3015,7 +3015,8 @@ ath5k_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
switch (cmd) { switch (cmd) {
case SET_KEY: case SET_KEY:
ret = ath5k_hw_set_key(sc->ah, key->keyidx, key, addr); ret = ath5k_hw_set_key(sc->ah, key->keyidx, key,
sta ? sta->addr : NULL);
if (ret) { if (ret) {
ATH5K_ERR(sc, "can't set the key\n"); ATH5K_ERR(sc, "can't set the key\n");
goto unlock; goto unlock;
......
...@@ -1139,7 +1139,7 @@ int ath5k_hw_set_key_lladdr(struct ath5k_hw *ah, u16 entry, const u8 *mac) ...@@ -1139,7 +1139,7 @@ int ath5k_hw_set_key_lladdr(struct ath5k_hw *ah, u16 entry, const u8 *mac)
/* MAC may be NULL if it's a broadcast key. In this case no need to /* MAC may be NULL if it's a broadcast key. In this case no need to
* to compute AR5K_LOW_ID and AR5K_HIGH_ID as we already know it. */ * to compute AR5K_LOW_ID and AR5K_HIGH_ID as we already know it. */
if (unlikely(mac == NULL)) { if (!mac) {
low_id = 0xffffffff; low_id = 0xffffffff;
high_id = 0xffff | AR5K_KEYTABLE_VALID; high_id = 0xffff | AR5K_KEYTABLE_VALID;
} else { } else {
......
...@@ -794,7 +794,7 @@ static int ath_reserve_key_cache_slot(struct ath_softc *sc) ...@@ -794,7 +794,7 @@ static int ath_reserve_key_cache_slot(struct ath_softc *sc)
} }
static int ath_key_config(struct ath_softc *sc, static int ath_key_config(struct ath_softc *sc,
const u8 *addr, struct ieee80211_sta *sta,
struct ieee80211_key_conf *key) struct ieee80211_key_conf *key)
{ {
struct ath9k_keyval hk; struct ath9k_keyval hk;
...@@ -828,7 +828,10 @@ static int ath_key_config(struct ath_softc *sc, ...@@ -828,7 +828,10 @@ static int ath_key_config(struct ath_softc *sc,
} else if (key->keyidx) { } else if (key->keyidx) {
struct ieee80211_vif *vif; struct ieee80211_vif *vif;
mac = addr; if (WARN_ON(!sta))
return -EOPNOTSUPP;
mac = sta->addr;
vif = sc->sc_vaps[0]; vif = sc->sc_vaps[0];
if (vif->type != NL80211_IFTYPE_AP) { if (vif->type != NL80211_IFTYPE_AP) {
/* Only keyidx 0 should be used with unicast key, but /* Only keyidx 0 should be used with unicast key, but
...@@ -837,7 +840,10 @@ static int ath_key_config(struct ath_softc *sc, ...@@ -837,7 +840,10 @@ static int ath_key_config(struct ath_softc *sc,
} else } else
return -EIO; return -EIO;
} else { } else {
mac = addr; if (WARN_ON(!sta))
return -EOPNOTSUPP;
mac = sta->addr;
if (key->alg == ALG_TKIP) if (key->alg == ALG_TKIP)
idx = ath_reserve_key_cache_slot_tkip(sc); idx = ath_reserve_key_cache_slot_tkip(sc);
else else
...@@ -2320,8 +2326,8 @@ static int ath9k_conf_tx(struct ieee80211_hw *hw, ...@@ -2320,8 +2326,8 @@ static int ath9k_conf_tx(struct ieee80211_hw *hw,
static int ath9k_set_key(struct ieee80211_hw *hw, static int ath9k_set_key(struct ieee80211_hw *hw,
enum set_key_cmd cmd, enum set_key_cmd cmd,
const u8 *local_addr, struct ieee80211_vif *vif,
const u8 *addr, struct ieee80211_sta *sta,
struct ieee80211_key_conf *key) struct ieee80211_key_conf *key)
{ {
struct ath_softc *sc = hw->priv; struct ath_softc *sc = hw->priv;
...@@ -2331,7 +2337,7 @@ static int ath9k_set_key(struct ieee80211_hw *hw, ...@@ -2331,7 +2337,7 @@ static int ath9k_set_key(struct ieee80211_hw *hw,
switch (cmd) { switch (cmd) {
case SET_KEY: case SET_KEY:
ret = ath_key_config(sc, addr, key); ret = ath_key_config(sc, sta, key);
if (ret >= 0) { if (ret >= 0) {
key->hw_key_idx = ret; key->hw_key_idx = ret;
/* push IV and Michael MIC generation to stack */ /* push IV and Michael MIC generation to stack */
......
...@@ -3476,8 +3476,8 @@ static void b43_op_bss_info_changed(struct ieee80211_hw *hw, ...@@ -3476,8 +3476,8 @@ static void b43_op_bss_info_changed(struct ieee80211_hw *hw,
} }
static int b43_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, static int b43_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
const u8 *local_addr, const u8 *addr, struct ieee80211_vif *vif, struct ieee80211_sta *sta,
struct ieee80211_key_conf *key) struct ieee80211_key_conf *key)
{ {
struct b43_wl *wl = hw_to_b43_wl(hw); struct b43_wl *wl = hw_to_b43_wl(hw);
struct b43_wldev *dev; struct b43_wldev *dev;
...@@ -3542,9 +3542,14 @@ static int b43_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, ...@@ -3542,9 +3542,14 @@ static int b43_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
} }
if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) { if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) {
if (WARN_ON(!sta)) {
err = -EOPNOTSUPP;
goto out_unlock;
}
/* Pairwise key with an assigned MAC address. */ /* Pairwise key with an assigned MAC address. */
err = b43_key_write(dev, -1, algorithm, err = b43_key_write(dev, -1, algorithm,
key->key, key->keylen, addr, key); key->key, key->keylen,
sta->addr, key);
} else { } else {
/* Group key */ /* Group key */
err = b43_key_write(dev, index, algorithm, err = b43_key_write(dev, index, algorithm,
...@@ -3577,7 +3582,7 @@ static int b43_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, ...@@ -3577,7 +3582,7 @@ static int b43_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
b43dbg(wl, "%s hardware based encryption for keyidx: %d, " b43dbg(wl, "%s hardware based encryption for keyidx: %d, "
"mac: %pM\n", "mac: %pM\n",
cmd == SET_KEY ? "Using" : "Disabling", key->keyidx, cmd == SET_KEY ? "Using" : "Disabling", key->keyidx,
addr); sta ? sta->addr : "<group key>");
b43_dump_keymemory(dev); b43_dump_keymemory(dev);
} }
write_unlock(&wl->tx_lock); write_unlock(&wl->tx_lock);
......
...@@ -3021,13 +3021,17 @@ static void iwl_mac_update_tkip_key(struct ieee80211_hw *hw, ...@@ -3021,13 +3021,17 @@ static void iwl_mac_update_tkip_key(struct ieee80211_hw *hw,
} }
static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
const u8 *local_addr, const u8 *addr, struct ieee80211_vif *vif,
struct ieee80211_sta *sta,
struct ieee80211_key_conf *key) struct ieee80211_key_conf *key)
{ {
struct iwl_priv *priv = hw->priv; struct iwl_priv *priv = hw->priv;
int ret = 0; int ret = 0;
u8 sta_id = IWL_INVALID_STATION; u8 sta_id = IWL_INVALID_STATION;
u8 is_default_wep_key = 0; u8 is_default_wep_key = 0;
static const u8 bcast_addr[ETH_ALEN] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, };
static const u8 *addr;
IWL_DEBUG_MAC80211("enter\n"); IWL_DEBUG_MAC80211("enter\n");
...@@ -3036,9 +3040,7 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, ...@@ -3036,9 +3040,7 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
if (is_zero_ether_addr(addr)) addr = sta ? sta->addr : bcast_addr;
/* only support pairwise keys */
return -EOPNOTSUPP;
sta_id = iwl_find_station(priv, addr); sta_id = iwl_find_station(priv, addr);
if (sta_id == IWL_INVALID_STATION) { if (sta_id == IWL_INVALID_STATION) {
......
...@@ -6546,12 +6546,16 @@ static int iwl3945_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len) ...@@ -6546,12 +6546,16 @@ static int iwl3945_mac_hw_scan(struct ieee80211_hw *hw, u8 *ssid, size_t len)
} }
static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
const u8 *local_addr, const u8 *addr, struct ieee80211_vif *vif,
struct ieee80211_key_conf *key) struct ieee80211_sta *sta,
struct ieee80211_key_conf *key)
{ {
struct iwl_priv *priv = hw->priv; struct iwl_priv *priv = hw->priv;
const u8 *addr;
int rc = 0; int rc = 0;
u8 sta_id; u8 sta_id;
static const u8 bcast_addr[ETH_ALEN] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
IWL_DEBUG_MAC80211("enter\n"); IWL_DEBUG_MAC80211("enter\n");
...@@ -6560,9 +6564,7 @@ static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, ...@@ -6560,9 +6564,7 @@ static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
if (is_zero_ether_addr(addr)) addr = sta ? sta->addr : bcast_addr;
/* only support pairwise keys */
return -EOPNOTSUPP;
sta_id = iwl3945_hw_find_station(priv, addr); sta_id = iwl3945_hw_find_station(priv, addr);
if (sta_id == IWL_INVALID_STATION) { if (sta_id == IWL_INVALID_STATION) {
......
...@@ -2127,7 +2127,7 @@ static void p54_bss_info_changed(struct ieee80211_hw *dev, ...@@ -2127,7 +2127,7 @@ static void p54_bss_info_changed(struct ieee80211_hw *dev,
} }
static int p54_set_key(struct ieee80211_hw *dev, enum set_key_cmd cmd, static int p54_set_key(struct ieee80211_hw *dev, enum set_key_cmd cmd,
const u8 *local_address, const u8 *address, struct ieee80211_vif *vif, struct ieee80211_sta *sta,
struct ieee80211_key_conf *key) struct ieee80211_key_conf *key)
{ {
struct p54_common *priv = dev->priv; struct p54_common *priv = dev->priv;
...@@ -2191,8 +2191,8 @@ static int p54_set_key(struct ieee80211_hw *dev, enum set_key_cmd cmd, ...@@ -2191,8 +2191,8 @@ static int p54_set_key(struct ieee80211_hw *dev, enum set_key_cmd cmd,
rxkey->entry = key->keyidx; rxkey->entry = key->keyidx;
rxkey->key_id = key->keyidx; rxkey->key_id = key->keyidx;
rxkey->key_type = algo; rxkey->key_type = algo;
if (address) if (sta)
memcpy(rxkey->mac, address, ETH_ALEN); memcpy(rxkey->mac, sta->addr, ETH_ALEN);
else else
memset(rxkey->mac, ~0, ETH_ALEN); memset(rxkey->mac, ~0, ETH_ALEN);
if (key->alg != ALG_TKIP) { if (key->alg != ALG_TKIP) {
......
...@@ -931,7 +931,7 @@ void rt2x00mac_configure_filter(struct ieee80211_hw *hw, ...@@ -931,7 +931,7 @@ void rt2x00mac_configure_filter(struct ieee80211_hw *hw,
int mc_count, struct dev_addr_list *mc_list); int mc_count, struct dev_addr_list *mc_list);
#ifdef CONFIG_RT2X00_LIB_CRYPTO #ifdef CONFIG_RT2X00_LIB_CRYPTO
int rt2x00mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, int rt2x00mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
const u8 *local_address, const u8 *address, struct ieee80211_vif *vif, struct ieee80211_sta *sta,
struct ieee80211_key_conf *key); struct ieee80211_key_conf *key);
#else #else
#define rt2x00mac_set_key NULL #define rt2x00mac_set_key NULL
......
...@@ -502,15 +502,17 @@ static void memcpy_tkip(struct rt2x00lib_crypto *crypto, u8 *key, u8 key_len) ...@@ -502,15 +502,17 @@ static void memcpy_tkip(struct rt2x00lib_crypto *crypto, u8 *key, u8 key_len)
} }
int rt2x00mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, int rt2x00mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
const u8 *local_address, const u8 *address, struct ieee80211_vif *vif, struct ieee80211_sta *sta,
struct ieee80211_key_conf *key) struct ieee80211_key_conf *key)
{ {
struct rt2x00_dev *rt2x00dev = hw->priv; struct rt2x00_dev *rt2x00dev = hw->priv;
struct ieee80211_sta *sta; struct rt2x00_intf *intf = vif_to_intf(vif);
int (*set_key) (struct rt2x00_dev *rt2x00dev, int (*set_key) (struct rt2x00_dev *rt2x00dev,
struct rt2x00lib_crypto *crypto, struct rt2x00lib_crypto *crypto,
struct ieee80211_key_conf *key); struct ieee80211_key_conf *key);
struct rt2x00lib_crypto crypto; struct rt2x00lib_crypto crypto;
static const u8 bcast_addr[ETH_ALEN] =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, };
if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags)) if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
return 0; return 0;
...@@ -528,32 +530,25 @@ int rt2x00mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, ...@@ -528,32 +530,25 @@ int rt2x00mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
if (rt2x00dev->intf_sta_count) if (rt2x00dev->intf_sta_count)
crypto.bssidx = 0; crypto.bssidx = 0;
else else
crypto.bssidx = crypto.bssidx = intf->mac[5] & (rt2x00dev->ops->max_ap_intf - 1);
local_address[5] & (rt2x00dev->ops->max_ap_intf - 1);
crypto.cipher = rt2x00crypto_key_to_cipher(key); crypto.cipher = rt2x00crypto_key_to_cipher(key);
if (crypto.cipher == CIPHER_NONE) if (crypto.cipher == CIPHER_NONE)
return -EOPNOTSUPP; return -EOPNOTSUPP;
crypto.cmd = cmd; crypto.cmd = cmd;
crypto.address = address;
if (sta) {
/* some drivers need the AID */
crypto.aid = sta->aid;
crypto.address = sta->addr;
} else
crypto.address = bcast_addr;
if (crypto.cipher == CIPHER_TKIP) if (crypto.cipher == CIPHER_TKIP)
memcpy_tkip(&crypto, &key->key[0], key->keylen); memcpy_tkip(&crypto, &key->key[0], key->keylen);
else else
memcpy(&crypto.key, &key->key[0], key->keylen); memcpy(&crypto.key, &key->key[0], key->keylen);
/*
* Discover the Association ID from mac80211.
* Some drivers need this information when updating the
* hardware key (either adding or removing).
*/
rcu_read_lock();
sta = ieee80211_find_sta(hw, address);
if (sta)
crypto.aid = sta->aid;
rcu_read_unlock();
/* /*
* Each BSS has a maximum of 4 shared keys. * Each BSS has a maximum of 4 shared keys.
* Shared key index values: * Shared key index values:
......
...@@ -715,8 +715,8 @@ enum ieee80211_key_flags { ...@@ -715,8 +715,8 @@ enum ieee80211_key_flags {
* - Temporal Encryption Key (128 bits) * - Temporal Encryption Key (128 bits)
* - Temporal Authenticator Tx MIC Key (64 bits) * - Temporal Authenticator Tx MIC Key (64 bits)
* - Temporal Authenticator Rx MIC Key (64 bits) * - Temporal Authenticator Rx MIC Key (64 bits)
* @icv_len: FIXME * @icv_len: The ICV length for this key type
* @iv_len: FIXME * @iv_len: The IV length for this key type
*/ */
struct ieee80211_key_conf { struct ieee80211_key_conf {
enum ieee80211_key_alg alg; enum ieee80211_key_alg alg;
...@@ -1019,16 +1019,12 @@ ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw, ...@@ -1019,16 +1019,12 @@ ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw,
* *
* The set_key() callback in the &struct ieee80211_ops for a given * The set_key() callback in the &struct ieee80211_ops for a given
* device is called to enable hardware acceleration of encryption and * device is called to enable hardware acceleration of encryption and
* decryption. The callback takes an @address parameter that will be * decryption. The callback takes a @sta parameter that will be NULL
* the broadcast address for default keys, the other station's hardware * for default keys or keys used for transmission only, or point to
* address for individual keys or the zero address for keys that will * the station information for the peer for individual keys.
* be used only for transmission.
* Multiple transmission keys with the same key index may be used when * Multiple transmission keys with the same key index may be used when
* VLANs are configured for an access point. * VLANs are configured for an access point.
* *
* The @local_address parameter will always be set to our own address,
* this is only relevant if you support multiple local addresses.
*
* When transmitting, the TX control data will use the @hw_key_idx * When transmitting, the TX control data will use the @hw_key_idx
* selected by the driver by modifying the &struct ieee80211_key_conf * selected by the driver by modifying the &struct ieee80211_key_conf
* pointed to by the @key parameter to the set_key() function. * pointed to by the @key parameter to the set_key() function.
...@@ -1233,8 +1229,8 @@ enum ieee80211_ampdu_mlme_action { ...@@ -1233,8 +1229,8 @@ enum ieee80211_ampdu_mlme_action {
* *
* @set_key: See the section "Hardware crypto acceleration" * @set_key: See the section "Hardware crypto acceleration"
* This callback can sleep, and is only called between add_interface * This callback can sleep, and is only called between add_interface
* and remove_interface calls, i.e. while the interface with the * and remove_interface calls, i.e. while the given virtual interface
* given local_address is enabled. * is enabled.
* *
* @update_tkip_key: See the section "Hardware crypto acceleration" * @update_tkip_key: See the section "Hardware crypto acceleration"
* This callback will be called in the context of Rx. Called for drivers * This callback will be called in the context of Rx. Called for drivers
...@@ -1311,7 +1307,7 @@ struct ieee80211_ops { ...@@ -1311,7 +1307,7 @@ struct ieee80211_ops {
int (*set_tim)(struct ieee80211_hw *hw, struct ieee80211_sta *sta, int (*set_tim)(struct ieee80211_hw *hw, struct ieee80211_sta *sta,
bool set); bool set);
int (*set_key)(struct ieee80211_hw *hw, enum set_key_cmd cmd, int (*set_key)(struct ieee80211_hw *hw, enum set_key_cmd cmd,
const u8 *local_address, const u8 *address, struct ieee80211_vif *vif, struct ieee80211_sta *sta,
struct ieee80211_key_conf *key); struct ieee80211_key_conf *key);
void (*update_tkip_key)(struct ieee80211_hw *hw, void (*update_tkip_key)(struct ieee80211_hw *hw,
struct ieee80211_key_conf *conf, const u8 *address, struct ieee80211_key_conf *conf, const u8 *address,
......
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
*/ */
static const u8 bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; static const u8 bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
static const u8 zero_addr[ETH_ALEN];
/* key mutex: used to synchronise todo runners */ /* key mutex: used to synchronise todo runners */
static DEFINE_MUTEX(key_mutex); static DEFINE_MUTEX(key_mutex);
...@@ -108,29 +107,18 @@ static void assert_key_lock(void) ...@@ -108,29 +107,18 @@ static void assert_key_lock(void)
WARN_ON(!mutex_is_locked(&key_mutex)); WARN_ON(!mutex_is_locked(&key_mutex));
} }
static const u8 *get_mac_for_key(struct ieee80211_key *key) static struct ieee80211_sta *get_sta_for_key(struct ieee80211_key *key)
{ {
const u8 *addr = bcast_addr;
/*
* If we're an AP we won't ever receive frames with a non-WEP
* group key so we tell the driver that by using the zero MAC
* address to indicate a transmit-only key.
*/
if (key->conf.alg != ALG_WEP &&
(key->sdata->vif.type == NL80211_IFTYPE_AP ||
key->sdata->vif.type == NL80211_IFTYPE_AP_VLAN))
addr = zero_addr;
if (key->sta) if (key->sta)
addr = key->sta->sta.addr; return &key->sta->sta;
return addr; return NULL;
} }
static void ieee80211_key_enable_hw_accel(struct ieee80211_key *key) static void ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
{ {
const u8 *addr; struct ieee80211_sub_if_data *sdata;
struct ieee80211_sta *sta;
int ret; int ret;
assert_key_lock(); assert_key_lock();
...@@ -139,11 +127,16 @@ static void ieee80211_key_enable_hw_accel(struct ieee80211_key *key) ...@@ -139,11 +127,16 @@ static void ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
if (!key->local->ops->set_key) if (!key->local->ops->set_key)
return; return;
addr = get_mac_for_key(key); sta = get_sta_for_key(key);
sdata = key->sdata;
if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
sdata = container_of(sdata->bss,
struct ieee80211_sub_if_data,
u.ap);
ret = key->local->ops->set_key(local_to_hw(key->local), SET_KEY, ret = key->local->ops->set_key(local_to_hw(key->local), SET_KEY,
key->sdata->dev->dev_addr, addr, &sdata->vif, sta, &key->conf);
&key->conf);
if (!ret) { if (!ret) {
spin_lock(&todo_lock); spin_lock(&todo_lock);
...@@ -155,12 +148,13 @@ static void ieee80211_key_enable_hw_accel(struct ieee80211_key *key) ...@@ -155,12 +148,13 @@ static void ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
printk(KERN_ERR "mac80211-%s: failed to set key " printk(KERN_ERR "mac80211-%s: failed to set key "
"(%d, %pM) to hardware (%d)\n", "(%d, %pM) to hardware (%d)\n",
wiphy_name(key->local->hw.wiphy), wiphy_name(key->local->hw.wiphy),
key->conf.keyidx, addr, ret); key->conf.keyidx, sta ? sta->addr : bcast_addr, ret);
} }
static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key) static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key)
{ {
const u8 *addr; struct ieee80211_sub_if_data *sdata;
struct ieee80211_sta *sta;
int ret; int ret;
assert_key_lock(); assert_key_lock();
...@@ -176,17 +170,22 @@ static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key) ...@@ -176,17 +170,22 @@ static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key)
} }
spin_unlock(&todo_lock); spin_unlock(&todo_lock);
addr = get_mac_for_key(key); sta = get_sta_for_key(key);
sdata = key->sdata;
if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
sdata = container_of(sdata->bss,
struct ieee80211_sub_if_data,
u.ap);
ret = key->local->ops->set_key(local_to_hw(key->local), DISABLE_KEY, ret = key->local->ops->set_key(local_to_hw(key->local), DISABLE_KEY,
key->sdata->dev->dev_addr, addr, &sdata->vif, sta, &key->conf);
&key->conf);
if (ret) if (ret)
printk(KERN_ERR "mac80211-%s: failed to remove key " printk(KERN_ERR "mac80211-%s: failed to remove key "
"(%d, %pM) from hardware (%d)\n", "(%d, %pM) from hardware (%d)\n",
wiphy_name(key->local->hw.wiphy), wiphy_name(key->local->hw.wiphy),
key->conf.keyidx, addr, ret); key->conf.keyidx, sta ? sta->addr : bcast_addr, ret);
spin_lock(&todo_lock); spin_lock(&todo_lock);
key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment