@@ -3014,7 +3014,7 @@ static int wpa_driver_nl80211_set_key(const char *ifname, struct i802_bss *bss,
struct nl_msg *msg;
struct nl_msg *key_msg;
struct nlattr *types;
- int need_set_key = 0;
+ int skip_set_key = 1;
int ret;
/* Ignore for P2P Device */
@@ -3091,17 +3091,22 @@ static int wpa_driver_nl80211_set_key(const char *ifname, struct i802_bss *bss,
NL80211_KEY_SET_TX))
goto fail;
} else if (alg != WPA_ALG_WEP &&
- key_type != KEY_TYPE_PAIRWISE) {
+ key_type == KEY_TYPE_BROADCAST) {
wpa_printf(MSG_DEBUG, " RSN IBSS RX GTK");
if (nla_put_u32(key_msg, NL80211_KEY_TYPE,
NL80211_KEYTYPE_GROUP))
goto fail;
+ } else if (key_type == KEY_TYPE_DEFAULT) {
+ /* We don't need or handle Pairwise Default Keys */
+ wpa_printf(MSG_ERROR,
+ "Can't set a Pairwise key as default key.");
+ goto fail;
}
} else if (alg != WPA_ALG_NONE) {
/* Default (WEP, GTK or IGTK) key */
if (alg != WPA_ALG_WEP || key_type == KEY_TYPE_DEFAULT) {
wpa_printf(MSG_DEBUG, " require SET_KEY");
- need_set_key = 1;
+ skip_set_key = 0;
}
}
if (nla_put_u8(key_msg, NL80211_KEY_IDX, key_idx) ||
@@ -3122,7 +3127,7 @@ static int wpa_driver_nl80211_set_key(const char *ifname, struct i802_bss *bss,
* If we failed or don't need to set the key as default (below),
* we're done here.
*/
- if (ret || !need_set_key)
+ if (ret || skip_set_key)
return ret;
key_msg = nlmsg_alloc();
@@ -3149,11 +3154,8 @@ static int wpa_driver_nl80211_set_key(const char *ifname, struct i802_bss *bss,
goto fail;
nla_nest_end(key_msg, types);
} else if (!addr) {
- wpa_printf(MSG_DEBUG, " WEP key");
+ wpa_printf(MSG_DEBUG, " WEP/WPA-NONE default key");
} else {
- /* need_set_key must only be set for
- * zero or broadcast addresses
- */
wpa_printf(MSG_ERROR,
"Unicast key when not expecting one, abort!");
goto fail;
This is a correction on top of: [PATCH v6 08/17] nl80211: Switch to the new key_type API & cleanup Changes: - Default Keys must always be either WEP or WPA-NONE Keys: Instead of ignoring the KEY_TYPE_DEFAULT for Pairwise keys refuse to install this combination - Replace need_set_key with skip_set_key and invert the logic - Debug logging message updated Signed-off-by: Alexander Wetzel <alexander@wetzel-home.de> --- src/drivers/driver_nl80211.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)