aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHelmut Schaa <helmut.schaa@googlemail.com>2011-03-03 13:44:33 -0500
committerJohn W. Linville <linville@tuxdriver.com>2011-03-04 14:06:48 -0500
commit1ed3811c33d525be1c657261db1713f294c40c60 (patch)
treefcc8cb8bf9a46cab28809a33daedf9798575aa6d /drivers
parent4df10c8c1353e5db781a9a781cc585698b24f30d (diff)
rt2x00: Fix rt2800 key assignment in multi bssid setups
When setting up multiple BSSIDs in AP mode on an rt2800pci device we previously used the STAs AID to select an appropriate key slot. But since the AID is per VIF we can end up with two STAs having the same AID and thus using the same key index. This resulted in one STA overwriting the key information of another STA. Fix this by simply searching for the next unused entry in the pairwise key table. Also bring the key table init in sync with deleting keys by initializing the key table entries to 0 instead of 1. Signed-off-by: Helmut Schaa <helmut.schaa@googlemail.com> Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/rt2x00/rt2800lib.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 553d4d01a439..2ee6cebb9b25 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -1101,27 +1101,44 @@ int rt2800_config_shared_key(struct rt2x00_dev *rt2x00dev,
1101} 1101}
1102EXPORT_SYMBOL_GPL(rt2800_config_shared_key); 1102EXPORT_SYMBOL_GPL(rt2800_config_shared_key);
1103 1103
1104static inline int rt2800_find_pairwise_keyslot(struct rt2x00_dev *rt2x00dev)
1105{
1106 int idx;
1107 u32 offset, reg;
1108
1109 /*
1110 * Search for the first free pairwise key entry and return the
1111 * corresponding index.
1112 *
1113 * Make sure the WCID starts _after_ the last possible shared key
1114 * entry (>32).
1115 *
1116 * Since parts of the pairwise key table might be shared with
1117 * the beacon frame buffers 6 & 7 we should only write into the
1118 * first 222 entries.
1119 */
1120 for (idx = 33; idx <= 222; idx++) {
1121 offset = MAC_WCID_ATTR_ENTRY(idx);
1122 rt2800_register_read(rt2x00dev, offset, &reg);
1123 if (!reg)
1124 return idx;
1125 }
1126 return -1;
1127}
1128
1104int rt2800_config_pairwise_key(struct rt2x00_dev *rt2x00dev, 1129int rt2800_config_pairwise_key(struct rt2x00_dev *rt2x00dev,
1105 struct rt2x00lib_crypto *crypto, 1130 struct rt2x00lib_crypto *crypto,
1106 struct ieee80211_key_conf *key) 1131 struct ieee80211_key_conf *key)
1107{ 1132{
1108 struct hw_key_entry key_entry; 1133 struct hw_key_entry key_entry;
1109 u32 offset; 1134 u32 offset;
1135 int idx;
1110 1136
1111 if (crypto->cmd == SET_KEY) { 1137 if (crypto->cmd == SET_KEY) {
1112 /* 1138 idx = rt2800_find_pairwise_keyslot(rt2x00dev);
1113 * 1 pairwise key is possible per AID, this means that the AID 1139 if (idx < 0)
1114 * equals our hw_key_idx. Make sure the WCID starts _after_ the
1115 * last possible shared key entry.
1116 *
1117 * Since parts of the pairwise key table might be shared with
1118 * the beacon frame buffers 6 & 7 we should only write into the
1119 * first 222 entries.
1120 */
1121 if (crypto->aid > (222 - 32))
1122 return -ENOSPC; 1140 return -ENOSPC;
1123 1141 key->hw_key_idx = idx;
1124 key->hw_key_idx = 32 + crypto->aid;
1125 1142
1126 memcpy(key_entry.key, crypto->key, 1143 memcpy(key_entry.key, crypto->key,
1127 sizeof(key_entry.key)); 1144 sizeof(key_entry.key));
@@ -2458,7 +2475,7 @@ static int rt2800_init_registers(struct rt2x00_dev *rt2x00dev)
2458 rt2800_register_multiwrite(rt2x00dev, MAC_WCID_ENTRY(i), 2475 rt2800_register_multiwrite(rt2x00dev, MAC_WCID_ENTRY(i),
2459 wcid, sizeof(wcid)); 2476 wcid, sizeof(wcid));
2460 2477
2461 rt2800_register_write(rt2x00dev, MAC_WCID_ATTR_ENTRY(i), 1); 2478 rt2800_register_write(rt2x00dev, MAC_WCID_ATTR_ENTRY(i), 0);
2462 rt2800_register_write(rt2x00dev, MAC_IVEIV_ENTRY(i), 0); 2479 rt2800_register_write(rt2x00dev, MAC_IVEIV_ENTRY(i), 0);
2463 } 2480 }
2464 2481