Skip to content

Commit b3fbdcf

Browse files
jmberglinvjw
authored andcommitted
mac80211: pass vif and station to update_tkip_key
When a TKIP key is updated, we should pass the station pointer instead of just the address, since drivers can use that to store their own data. We also need to pass the virtual interface pointer. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent e4fca00 commit b3fbdcf

6 files changed

Lines changed: 43 additions & 25 deletions

File tree

‎drivers/net/wireless/b43/main.c‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -844,8 +844,10 @@ static void rx_tkip_phase1_write(struct b43_wldev *dev, u8 index, u32 iv32,
844844
}
845845

846846
static void b43_op_update_tkip_key(struct ieee80211_hw *hw,
847-
struct ieee80211_key_conf *keyconf, const u8 *addr,
848-
u32 iv32, u16 *phase1key)
847+
struct ieee80211_vif *vif,
848+
struct ieee80211_key_conf *keyconf,
849+
struct ieee80211_sta *sta,
850+
u32 iv32, u16 *phase1key)
849851
{
850852
struct b43_wl *wl = hw_to_b43_wl(hw);
851853
struct b43_wldev *dev;
@@ -863,7 +865,10 @@ static void b43_op_update_tkip_key(struct ieee80211_hw *hw,
863865
keymac_write(dev, index, NULL); /* First zero out mac to avoid race */
864866

865867
rx_tkip_phase1_write(dev, index, iv32, phase1key);
866-
keymac_write(dev, index, addr);
868+
/* only pairwise TKIP keys are supported right now */
869+
if (WARN_ON(!sta))
870+
goto out_unlock;
871+
keymac_write(dev, index, sta->addr);
867872

868873
out_unlock:
869874
mutex_unlock(&wl->mutex);

‎drivers/net/wireless/iwlwifi/iwl-agn.c‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2839,14 +2839,18 @@ void iwl_config_ap(struct iwl_priv *priv)
28392839
}
28402840

28412841
static void iwl_mac_update_tkip_key(struct ieee80211_hw *hw,
2842-
struct ieee80211_key_conf *keyconf, const u8 *addr,
2843-
u32 iv32, u16 *phase1key)
2842+
struct ieee80211_vif *vif,
2843+
struct ieee80211_key_conf *keyconf,
2844+
struct ieee80211_sta *sta,
2845+
u32 iv32, u16 *phase1key)
28442846
{
28452847

28462848
struct iwl_priv *priv = hw->priv;
28472849
IWL_DEBUG_MAC80211(priv, "enter\n");
28482850

2849-
iwl_update_tkip_key(priv, keyconf, addr, iv32, phase1key);
2851+
iwl_update_tkip_key(priv, keyconf,
2852+
sta ? sta->addr : iwl_bcast_addr,
2853+
iv32, phase1key);
28502854

28512855
IWL_DEBUG_MAC80211(priv, "leave\n");
28522856
}

‎include/net/mac80211.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,8 +1614,10 @@ struct ieee80211_ops {
16141614
struct ieee80211_vif *vif, struct ieee80211_sta *sta,
16151615
struct ieee80211_key_conf *key);
16161616
void (*update_tkip_key)(struct ieee80211_hw *hw,
1617-
struct ieee80211_key_conf *conf, const u8 *address,
1618-
u32 iv32, u16 *phase1key);
1617+
struct ieee80211_vif *vif,
1618+
struct ieee80211_key_conf *conf,
1619+
struct ieee80211_sta *sta,
1620+
u32 iv32, u16 *phase1key);
16191621
int (*hw_scan)(struct ieee80211_hw *hw,
16201622
struct cfg80211_scan_request *req);
16211623
void (*sw_scan_start)(struct ieee80211_hw *hw);

‎net/mac80211/driver-ops.h‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,16 +137,22 @@ static inline int drv_set_key(struct ieee80211_local *local,
137137
}
138138

139139
static inline void drv_update_tkip_key(struct ieee80211_local *local,
140+
struct ieee80211_sub_if_data *sdata,
140141
struct ieee80211_key_conf *conf,
141-
const u8 *address, u32 iv32,
142+
struct sta_info *sta, u32 iv32,
142143
u16 *phase1key)
143144
{
145+
struct ieee80211_sta *ista = NULL;
146+
144147
might_sleep();
145148

149+
if (sta)
150+
ista = &sta->sta;
151+
146152
if (local->ops->update_tkip_key)
147-
local->ops->update_tkip_key(&local->hw, conf, address,
148-
iv32, phase1key);
149-
trace_drv_update_tkip_key(local, conf, address, iv32);
153+
local->ops->update_tkip_key(&local->hw, &sdata->vif, conf,
154+
ista, iv32, phase1key);
155+
trace_drv_update_tkip_key(local, sdata, conf, ista, iv32);
150156
}
151157

152158
static inline int drv_hw_scan(struct ieee80211_local *local,

‎net/mac80211/driver-trace.h‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,26 +331,29 @@ TRACE_EVENT(drv_set_key,
331331

332332
TRACE_EVENT(drv_update_tkip_key,
333333
TP_PROTO(struct ieee80211_local *local,
334+
struct ieee80211_sub_if_data *sdata,
334335
struct ieee80211_key_conf *conf,
335-
const u8 *address, u32 iv32),
336+
struct ieee80211_sta *sta, u32 iv32),
336337

337-
TP_ARGS(local, conf, address, iv32),
338+
TP_ARGS(local, sdata, conf, sta, iv32),
338339

339340
TP_STRUCT__entry(
340341
LOCAL_ENTRY
341-
__array(u8, addr, 6)
342+
VIF_ENTRY
343+
STA_ENTRY
342344
__field(u32, iv32)
343345
),
344346

345347
TP_fast_assign(
346348
LOCAL_ASSIGN;
347-
memcpy(__entry->addr, address, 6);
349+
VIF_ASSIGN;
350+
STA_ASSIGN;
348351
__entry->iv32 = iv32;
349352
),
350353

351354
TP_printk(
352-
LOCAL_PR_FMT " addr:%pM iv32:%#x",
353-
LOCAL_PR_ARG, __entry->addr, __entry->iv32
355+
LOCAL_PR_FMT VIF_PR_FMT STA_PR_FMT " iv32:%#x",
356+
LOCAL_PR_ARG,VIF_PR_ARG,STA_PR_ARG, __entry->iv32
354357
)
355358
);
356359

‎net/mac80211/tkip.c‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -304,14 +304,12 @@ int ieee80211_tkip_decrypt_data(struct crypto_blkcipher *tfm,
304304
if (key->local->ops->update_tkip_key &&
305305
key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE &&
306306
key->u.tkip.rx[queue].state != TKIP_STATE_PHASE1_HW_UPLOADED) {
307-
static const u8 bcast[ETH_ALEN] =
308-
{0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
309-
const u8 *sta_addr = key->sta->sta.addr;
307+
struct ieee80211_sub_if_data *sdata = key->sdata;
310308

311-
if (is_multicast_ether_addr(ra))
312-
sta_addr = bcast;
313-
314-
drv_update_tkip_key(key->local, &key->conf, sta_addr,
309+
if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
310+
sdata = container_of(key->sdata->bss,
311+
struct ieee80211_sub_if_data, u.ap);
312+
drv_update_tkip_key(key->local, sdata, &key->conf, key->sta,
315313
iv32, key->u.tkip.rx[queue].p1k);
316314
key->u.tkip.rx[queue].state = TKIP_STATE_PHASE1_HW_UPLOADED;
317315
}

0 commit comments

Comments
 (0)