Commit 89b706fb authored by Johannes Berg's avatar Johannes Berg

cfg80211: reduce connect key caching struct size

After the previous patches, connect keys can only (correctly)
be used for storing static WEP keys. Therefore, remove all the
data for dealing with key index 4/5 and reduce the size of the
key material to the maximum for WEP keys.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent e9c8f8d3
...@@ -249,9 +249,9 @@ struct cfg80211_event { ...@@ -249,9 +249,9 @@ struct cfg80211_event {
}; };
struct cfg80211_cached_keys { struct cfg80211_cached_keys {
struct key_params params[6]; struct key_params params[4];
u8 data[6][WLAN_MAX_KEY_LEN]; u8 data[4][WLAN_KEY_LEN_WEP104];
int def, defmgmt; int def;
}; };
enum cfg80211_chan_mode { enum cfg80211_chan_mode {
......
...@@ -284,10 +284,8 @@ int cfg80211_ibss_wext_join(struct cfg80211_registered_device *rdev, ...@@ -284,10 +284,8 @@ int cfg80211_ibss_wext_join(struct cfg80211_registered_device *rdev,
if (!netif_running(wdev->netdev)) if (!netif_running(wdev->netdev))
return 0; return 0;
if (wdev->wext.keys) { if (wdev->wext.keys)
wdev->wext.keys->def = wdev->wext.default_key; wdev->wext.keys->def = wdev->wext.default_key;
wdev->wext.keys->defmgmt = wdev->wext.default_mgmt_key;
}
wdev->wext.ibss.privacy = wdev->wext.default_key != -1; wdev->wext.ibss.privacy = wdev->wext.default_key != -1;
...@@ -295,7 +293,7 @@ int cfg80211_ibss_wext_join(struct cfg80211_registered_device *rdev, ...@@ -295,7 +293,7 @@ int cfg80211_ibss_wext_join(struct cfg80211_registered_device *rdev,
ck = kmemdup(wdev->wext.keys, sizeof(*ck), GFP_KERNEL); ck = kmemdup(wdev->wext.keys, sizeof(*ck), GFP_KERNEL);
if (!ck) if (!ck)
return -ENOMEM; return -ENOMEM;
for (i = 0; i < 6; i++) for (i = 0; i < 4; i++)
ck->params[i].key = ck->data[i]; ck->params[i].key = ck->data[i];
} }
err = __cfg80211_join_ibss(rdev, wdev->netdev, err = __cfg80211_join_ibss(rdev, wdev->netdev,
......
...@@ -854,7 +854,6 @@ nl80211_parse_connkeys(struct cfg80211_registered_device *rdev, ...@@ -854,7 +854,6 @@ nl80211_parse_connkeys(struct cfg80211_registered_device *rdev,
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
result->def = -1; result->def = -1;
result->defmgmt = -1;
nla_for_each_nested(key, keys, rem) { nla_for_each_nested(key, keys, rem) {
memset(&parse, 0, sizeof(parse)); memset(&parse, 0, sizeof(parse));
......
...@@ -912,7 +912,7 @@ void cfg80211_upload_connect_keys(struct wireless_dev *wdev) ...@@ -912,7 +912,7 @@ void cfg80211_upload_connect_keys(struct wireless_dev *wdev)
if (!wdev->connect_keys) if (!wdev->connect_keys)
return; return;
for (i = 0; i < 6; i++) { for (i = 0; i < 4; i++) {
if (!wdev->connect_keys->params[i].cipher) if (!wdev->connect_keys->params[i].cipher)
continue; continue;
if (rdev_add_key(rdev, dev, i, false, NULL, if (rdev_add_key(rdev, dev, i, false, NULL,
...@@ -925,9 +925,6 @@ void cfg80211_upload_connect_keys(struct wireless_dev *wdev) ...@@ -925,9 +925,6 @@ void cfg80211_upload_connect_keys(struct wireless_dev *wdev)
netdev_err(dev, "failed to set defkey %d\n", i); netdev_err(dev, "failed to set defkey %d\n", i);
continue; continue;
} }
if (wdev->connect_keys->defmgmt == i)
if (rdev_set_default_mgmt_key(rdev, dev, i))
netdev_err(dev, "failed to set mgtdef %d\n", i);
} }
kzfree(wdev->connect_keys); kzfree(wdev->connect_keys);
......
...@@ -411,7 +411,7 @@ static int __cfg80211_set_encryption(struct cfg80211_registered_device *rdev, ...@@ -411,7 +411,7 @@ static int __cfg80211_set_encryption(struct cfg80211_registered_device *rdev,
GFP_KERNEL); GFP_KERNEL);
if (!wdev->wext.keys) if (!wdev->wext.keys)
return -ENOMEM; return -ENOMEM;
for (i = 0; i < 6; i++) for (i = 0; i < 4; i++)
wdev->wext.keys->params[i].key = wdev->wext.keys->params[i].key =
wdev->wext.keys->data[i]; wdev->wext.keys->data[i];
} }
...@@ -460,7 +460,7 @@ static int __cfg80211_set_encryption(struct cfg80211_registered_device *rdev, ...@@ -460,7 +460,7 @@ static int __cfg80211_set_encryption(struct cfg80211_registered_device *rdev,
if (err == -ENOENT) if (err == -ENOENT)
err = 0; err = 0;
if (!err) { if (!err) {
if (!addr) { if (!addr && idx < 4) {
memset(wdev->wext.keys->data[idx], 0, memset(wdev->wext.keys->data[idx], 0,
sizeof(wdev->wext.keys->data[idx])); sizeof(wdev->wext.keys->data[idx]));
wdev->wext.keys->params[idx].key_len = 0; wdev->wext.keys->params[idx].key_len = 0;
......
...@@ -35,7 +35,6 @@ int cfg80211_mgd_wext_connect(struct cfg80211_registered_device *rdev, ...@@ -35,7 +35,6 @@ int cfg80211_mgd_wext_connect(struct cfg80211_registered_device *rdev,
if (wdev->wext.keys) { if (wdev->wext.keys) {
wdev->wext.keys->def = wdev->wext.default_key; wdev->wext.keys->def = wdev->wext.default_key;
wdev->wext.keys->defmgmt = wdev->wext.default_mgmt_key;
if (wdev->wext.default_key != -1) if (wdev->wext.default_key != -1)
wdev->wext.connect.privacy = true; wdev->wext.connect.privacy = true;
} }
...@@ -47,7 +46,7 @@ int cfg80211_mgd_wext_connect(struct cfg80211_registered_device *rdev, ...@@ -47,7 +46,7 @@ int cfg80211_mgd_wext_connect(struct cfg80211_registered_device *rdev,
ck = kmemdup(wdev->wext.keys, sizeof(*ck), GFP_KERNEL); ck = kmemdup(wdev->wext.keys, sizeof(*ck), GFP_KERNEL);
if (!ck) if (!ck)
return -ENOMEM; return -ENOMEM;
for (i = 0; i < 6; i++) for (i = 0; i < 4; i++)
ck->params[i].key = ck->data[i]; ck->params[i].key = ck->data[i];
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment