aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-12-29 06:55:09 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-01-29 15:59:42 -0500
commitdc822b5db479dc0178d5c04cbb656dad0b6564fb (patch)
treef06d09fb4d70830ce1489f4589cb03a491833955 /net/mac80211
parentb3093664c931aa06fc50da42e25b3b6dc307a915 (diff)
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: Johannes 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: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211')
-rw-r--r--net/mac80211/key.c51
1 files changed, 25 insertions, 26 deletions
diff --git a/net/mac80211/key.c b/net/mac80211/key.c
index 999f7aa42326..b0a025c9b615 100644
--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -47,7 +47,6 @@
47 */ 47 */
48 48
49static const u8 bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; 49static const u8 bcast_addr[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
50static const u8 zero_addr[ETH_ALEN];
51 50
52/* key mutex: used to synchronise todo runners */ 51/* key mutex: used to synchronise todo runners */
53static DEFINE_MUTEX(key_mutex); 52static DEFINE_MUTEX(key_mutex);
@@ -108,29 +107,18 @@ static void assert_key_lock(void)
108 WARN_ON(!mutex_is_locked(&key_mutex)); 107 WARN_ON(!mutex_is_locked(&key_mutex));
109} 108}
110 109
111static const u8 *get_mac_for_key(struct ieee80211_key *key) 110static struct ieee80211_sta *get_sta_for_key(struct ieee80211_key *key)
112{ 111{
113 const u8 *addr = bcast_addr;
114
115 /*
116 * If we're an AP we won't ever receive frames with a non-WEP
117 * group key so we tell the driver that by using the zero MAC
118 * address to indicate a transmit-only key.
119 */
120 if (key->conf.alg != ALG_WEP &&
121 (key->sdata->vif.type == NL80211_IFTYPE_AP ||
122 key->sdata->vif.type == NL80211_IFTYPE_AP_VLAN))
123 addr = zero_addr;
124
125 if (key->sta) 112 if (key->sta)
126 addr = key->sta->sta.addr; 113 return &key->sta->sta;
127 114
128 return addr; 115 return NULL;
129} 116}
130 117
131static void ieee80211_key_enable_hw_accel(struct ieee80211_key *key) 118static void ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
132{ 119{
133 const u8 *addr; 120 struct ieee80211_sub_if_data *sdata;
121 struct ieee80211_sta *sta;
134 int ret; 122 int ret;
135 123
136 assert_key_lock(); 124 assert_key_lock();
@@ -139,11 +127,16 @@ static void ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
139 if (!key->local->ops->set_key) 127 if (!key->local->ops->set_key)
140 return; 128 return;
141 129
142 addr = get_mac_for_key(key); 130 sta = get_sta_for_key(key);
131
132 sdata = key->sdata;
133 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
134 sdata = container_of(sdata->bss,
135 struct ieee80211_sub_if_data,
136 u.ap);
143 137
144 ret = key->local->ops->set_key(local_to_hw(key->local), SET_KEY, 138 ret = key->local->ops->set_key(local_to_hw(key->local), SET_KEY,
145 key->sdata->dev->dev_addr, addr, 139 &sdata->vif, sta, &key->conf);
146 &key->conf);
147 140
148 if (!ret) { 141 if (!ret) {
149 spin_lock(&todo_lock); 142 spin_lock(&todo_lock);
@@ -155,12 +148,13 @@ static void ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
155 printk(KERN_ERR "mac80211-%s: failed to set key " 148 printk(KERN_ERR "mac80211-%s: failed to set key "
156 "(%d, %pM) to hardware (%d)\n", 149 "(%d, %pM) to hardware (%d)\n",
157 wiphy_name(key->local->hw.wiphy), 150 wiphy_name(key->local->hw.wiphy),
158 key->conf.keyidx, addr, ret); 151 key->conf.keyidx, sta ? sta->addr : bcast_addr, ret);
159} 152}
160 153
161static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key) 154static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key)
162{ 155{
163 const u8 *addr; 156 struct ieee80211_sub_if_data *sdata;
157 struct ieee80211_sta *sta;
164 int ret; 158 int ret;
165 159
166 assert_key_lock(); 160 assert_key_lock();
@@ -176,17 +170,22 @@ static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key)
176 } 170 }
177 spin_unlock(&todo_lock); 171 spin_unlock(&todo_lock);
178 172
179 addr = get_mac_for_key(key); 173 sta = get_sta_for_key(key);
174 sdata = key->sdata;
175
176 if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
177 sdata = container_of(sdata->bss,
178 struct ieee80211_sub_if_data,
179 u.ap);
180 180
181 ret = key->local->ops->set_key(local_to_hw(key->local), DISABLE_KEY, 181 ret = key->local->ops->set_key(local_to_hw(key->local), DISABLE_KEY,
182 key->sdata->dev->dev_addr, addr, 182 &sdata->vif, sta, &key->conf);
183 &key->conf);
184 183
185 if (ret) 184 if (ret)
186 printk(KERN_ERR "mac80211-%s: failed to remove key " 185 printk(KERN_ERR "mac80211-%s: failed to remove key "
187 "(%d, %pM) from hardware (%d)\n", 186 "(%d, %pM) from hardware (%d)\n",
188 wiphy_name(key->local->hw.wiphy), 187 wiphy_name(key->local->hw.wiphy),
189 key->conf.keyidx, addr, ret); 188 key->conf.keyidx, sta ? sta->addr : bcast_addr, ret);
190 189
191 spin_lock(&todo_lock); 190 spin_lock(&todo_lock);
192 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; 191 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE;