2015-06-18 08:06:22

by Janusz Dziedzic

[permalink] [raw]
Subject: ath9k: multicast don't work when: two STA (sta + p2p_client) + hwcrypt

STA iface:
ath: phy0: Set HW Key 0 (pairwise) vif: 2c:d0:5a:d3:f1:e9 sta:
f4:b7:e2:38:83:f3 - idx: 4
ath: phy0: Set HW Key 0 (group) vif: 2c:d0:5a:d3:f1:e9 sta:
(null) - idx: 1

P2P_CLIENT iface:
ath: phy0: Set HW Key 0 (pairwise) vif: 2e:d0:5a:d3:f1:e9 sta:
0c:8b:fd:1e:58:9f - idx: 68
ath: phy0: Set HW Key 0 (group) vif: 2e:d0:5a:d3:f1:e9 sta:
(null) - idx: 1

Seems we overwrite multicast hw key - both idx = 1

1) First patch I made:

diff --git a/drivers/net/wireless/ath/key.c b/drivers/net/wireless/ath/key.c
index 1816b4e..b15873b 100644
--- a/drivers/net/wireless/ath/key.c
+++ b/drivers/net/wireless/ath/key.c
@@ -507,6 +507,15 @@ int ath_key_config(struct ath_common *common,

if (!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) {
switch (vif->type) {
+ case NL80211_IFTYPE_STATION:
+ idx = key->keyidx;
+ if (vif->bss_conf.bssid) {
+ ether_addr_copy(gmac, bssid);
+ gmac[0] |= 0x01;
+ mac = gmac;
+ idx =
ath_reserve_key_cache_slot(common, key->cipher);
+ }
+ break;
case NL80211_IFTYPE_AP:
memcpy(gmac, vif->addr, ETH_ALEN);
gmac[0] |= 0x01;

Multicast works fine for STA/P2P_CLIENT but multicast rekeying don't
work correctly, while we have 2 multicast keys installed for the same
bssid (eg. idx 6, 68) after rekey. Seem hw choose always key with
lowest idx - hw decrypt mcast packects correctly every second rekey
:-)

BTW, this needs attention to be sure hw decrypt frames correctly - I
am checking RX_FLAG_DECRYPTED flag, while often HW send crypted
packets and mac80211 decrypt them correctly (every second rekey for
example). So, some mixture of hwcrypt and swcrypt is seen :)

2) works perfectly when ath9k loaded with nohwcrypt=1

Any ideas how to solve this correctly (is it possible with hwcrypt at all)?

BR
Janusz


2015-07-13 05:42:48

by Janusz Dziedzic

[permalink] [raw]
Subject: Re: ath9k: multicast don't work when: two STA (sta + p2p_client) + hwcrypt

On 18 June 2015 at 10:06, Janusz Dziedzic <[email protected]> wrote:
> STA iface:
> ath: phy0: Set HW Key 0 (pairwise) vif: 2c:d0:5a:d3:f1:e9 sta:
> f4:b7:e2:38:83:f3 - idx: 4
> ath: phy0: Set HW Key 0 (group) vif: 2c:d0:5a:d3:f1:e9 sta:
> (null) - idx: 1
>
> P2P_CLIENT iface:
> ath: phy0: Set HW Key 0 (pairwise) vif: 2e:d0:5a:d3:f1:e9 sta:
> 0c:8b:fd:1e:58:9f - idx: 68
> ath: phy0: Set HW Key 0 (group) vif: 2e:d0:5a:d3:f1:e9 sta:
> (null) - idx: 1
>
> Seems we overwrite multicast hw key - both idx = 1
>
> 1) First patch I made:
>
> diff --git a/drivers/net/wireless/ath/key.c b/drivers/net/wireless/ath/key.c
> index 1816b4e..b15873b 100644
> --- a/drivers/net/wireless/ath/key.c
> +++ b/drivers/net/wireless/ath/key.c
> @@ -507,6 +507,15 @@ int ath_key_config(struct ath_common *common,
>
> if (!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)) {
> switch (vif->type) {
> + case NL80211_IFTYPE_STATION:
> + idx = key->keyidx;
> + if (vif->bss_conf.bssid) {
> + ether_addr_copy(gmac, bssid);
> + gmac[0] |= 0x01;
> + mac = gmac;
> + idx =
> ath_reserve_key_cache_slot(common, key->cipher);
> + }
> + break;
> case NL80211_IFTYPE_AP:
> memcpy(gmac, vif->addr, ETH_ALEN);
> gmac[0] |= 0x01;
>
> Multicast works fine for STA/P2P_CLIENT but multicast rekeying don't
> work correctly, while we have 2 multicast keys installed for the same
> bssid (eg. idx 6, 68) after rekey. Seem hw choose always key with
> lowest idx - hw decrypt mcast packects correctly every second rekey
> :-)
>
> BTW, this needs attention to be sure hw decrypt frames correctly - I
> am checking RX_FLAG_DECRYPTED flag, while often HW send crypted
> packets and mac80211 decrypt them correctly (every second rekey for
> example). So, some mixture of hwcrypt and swcrypt is seen :)
>
> 2) works perfectly when ath9k loaded with nohwcrypt=1
>
> Any ideas how to solve this correctly (is it possible with hwcrypt at all)?
>
> BR
> Janusz

Adding [email protected]