d80211: allow for hardware crypto of default keys
Subsystems (2)
PATCH 1/7 d80211: allow for hardware crypto of default keys
In reply to a message not in the archiveRemove incorrect prohibition of hardware crypto support. This was originally present to prevent hardware crypto when more than one station interface was created for a single hardware device, the code in question is no longer correct and should be removed.
net/d80211/ieee80211_ioctl.c +1 -8
@@ -537,9 +537,7 @@ static int ieee80211_set_encryption(stru } key = sdata->keys[idx]; -/* Disable hwaccel for default keys when the interface is not -* the default one. -* TODO: consider adding hwaccel support for these; at least +/* TODO: consider adding hwaccel support for these; at least * Atheros key cache should be able to handle this since AP is * only transmitting frames with default keys. */ /* FIX: hw key cache can be used when only one virtual
@@ -548,11 +546,6 @@ static int ieee80211_set_encryption(stru* must be used. This should be done automatically * based on configured station devices. For the time * being, this can be only set at compile time. */ -/* FIXME: There is no more anything like "default -* interface". We should try hwaccel if there is just one -* interface - for now, hwaccel is unconditionaly -* disabled. */ - try_hwaccel =0 ; }else { set_tx_key =0 ;if (idx !=0 ) {
--
PATCH 2/7 d80211: set default_wep_only dynamically
In reply to a message not in the archiveWithout this change d80211 relies on userspace to let it know when it can configure default wep keys. It is always safe to set default_wep_only if there is a single station interface. This allows for hardware accelleration for the case of a single station interface.
net/d80211/ieee80211_i.h +1 -0
@@ -607,6 +607,7 @@ extern const struct iw_handler_def ieee8int ieee80211_set_hw_encryption (struct net_device *dev,struct sta_info *sta,u8 addr[ETH_ALEN ],struct ieee80211_key *key); +void ieee80211_update_default_wep_only (struct ieee80211_local *local);/* ieee80211_scan.c */ void ieee80211_init_scan (struct ieee80211_local *local);
net/d80211/ieee80211_iface.c +4 -0
@@ -97,6 +97,7 @@ int ieee80211_if_add(struct net_device * }list_add (&sdata->list, &local->sub_if_list); +ieee80211_update_default_wep_only (local);return 0 ;
@@ -164,6 +165,7 @@ void ieee80211_if_del_mgmt(struct ieee80void ieee80211_if_set_type (struct net_device *dev,int type) {struct ieee80211_sub_if_data *sdata =IEEE80211_DEV_TO_SUB_IF (dev); +struct ieee80211_local *local = dev->ieee80211_ptr; sdata->type = type;switch (type) {
@@ -205,6 +207,7 @@ void ieee80211_if_set_type(struct net_de dev->name, __FUNCTION__, type); }ieee80211_sysfs_change_if_type (dev); +ieee80211_update_default_wep_only (local); }/* Must be called with rtnl lock held. */
@@ -329,6 +332,7 @@ int ieee80211_if_remove(struct net_devic strcmp(name, sdata->dev->name) == 0 && sdata->dev != local->mdev) {__ieee80211_if_del (local, sdata); +ieee80211_update_default_wep_only (local);return 0 ; } }
net/d80211/ieee80211_ioctl.c +30 -0
@@ -2357,6 +2357,36 @@ static int ieee80211_ioctl_default_wep_o } +void ieee80211_update_default_wep_only (struct ieee80211_local *local) +{ +int i =0 ; +struct ieee80211_sub_if_data *sdata; + +spin_lock_bh (&local->sub_if_lock); +list_for_each_entry (sdata, &local->sub_if_list, list) { + +if (sdata->dev == local->mdev) +continue ; + +/* If there is an AP interface then depend on userspace to +set default_wep_only correctly. */ +if (sdata->type ==IEEE80211_IF_TYPE_AP ) { +spin_unlock_bh (&local->sub_if_lock); +return ; + } + + i++; + } + +if (i <=1 ) +ieee80211_ioctl_default_wep_only (local,1 ); +else +ieee80211_ioctl_default_wep_only (local,0 ); + +spin_unlock_bh (&local->sub_if_lock); +} + +static int ieee80211_ioctl_prism2_param (struct net_device *dev,struct iw_request_info *info,void *wrqu,char *extra)
--
PATCH 3/7 d80211: fix potential interface name overflow
In reply to a message not in the archivedev->name and ndev->name are both IFNAMSIZ in length, the ".%d" is not guarenteed to fit in ndev->name.
net/d80211/ieee80211_iface.c +2 -1
@@ -56,7 +56,8 @@ int ieee80211_if_add(struct net_device *if (strlen (name) ==0 ) { i =0 ; do { - sprintf(ndev->name, "%s.%d", dev->name, i++); + snprintf(ndev->name, sizeof(ndev->name), "%s.%d", + dev->name, i++); tmp_dev = dev_get_by_name(ndev->name); if (!tmp_dev) break;
--
PATCH 4/7 d80211: fix potential invalid array index returning key information
In reply to a message not in the archivesdata->keys[] has NUM_DEFAULT_KEYS elements, don't access past that.
net/d80211/ieee80211_ioctl.c +1 -1
@@ -803,7 +803,7 @@ static int ieee80211_ioctl_get_encryptio param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) { sta =NULL ; -if (param->u.crypt.idx >NUM_DEFAULT_KEYS ) { +if (param->u.crypt.idx >=NUM_DEFAULT_KEYS ) { param->u.crypt.idx = sdata->default_key ? sdata->default_key->keyidx :0 ;return 0 ;
--
PATCH 5/7 d80211: remove unused references to sub interface data
In reply to a message not in the archiveIn these three cases the pointer returned by IEEE80211_DEV_TO_SUB_IF() is never used.
net/d80211/ieee80211.c +1 -3
@@ -1362,11 +1362,9 @@ static int ieee80211_master_start_xmit(sstruct ieee80211_tx_control control;struct ieee80211_tx_packet_data *pkt_data;struct net_device *odev =NULL ; -struct ieee80211_sub_if_data *sdata, *osdata; +struct ieee80211_sub_if_data *osdata;int ret; - sdata =IEEE80211_DEV_TO_SUB_IF (dev); -/* * copy control out of the skb so other people can use skb->cb */
net/d80211/ieee80211_ioctl.c +0 -2
@@ -407,10 +407,8 @@ static int ieee80211_ioctl_get_info_sta(if (param->sta_addr[0 ] ==0xff && param->sta_addr[1 ] ==0xff && param->sta_addr[2 ] ==0xff && param->sta_addr[3 ] ==0xff && param->sta_addr[4 ] ==0xff && param->sta_addr[5 ] ==0xff ) { -struct ieee80211_sub_if_data *sdata;struct net_device_stats *stats; - sdata =IEEE80211_DEV_TO_SUB_IF (dev); stats =ieee80211_dev_stats (local->mdev); param->u.get_info_sta.rx_bytes = stats->rx_bytes; param->u.get_info_sta.tx_bytes = stats->tx_bytes;
net/d80211/ieee80211_iface.c +1 -2
@@ -42,7 +42,7 @@ int ieee80211_if_add(struct net_device * {struct net_device *ndev, *tmp_dev;struct ieee80211_local *local = dev->ieee80211_ptr; -struct ieee80211_sub_if_data *sdata =NULL , *sdata_parent; +struct ieee80211_sub_if_data *sdata =NULL ;int ret;int i;
@@ -83,7 +83,6 @@ int ieee80211_if_add(struct net_device * sdata->type =IEEE80211_IF_TYPE_AP ; sdata->dev = ndev; sdata->local = local; - sdata_parent =IEEE80211_DEV_TO_SUB_IF (dev);ieee80211_if_sdata_init (sdata); ret =register_netdevice (ndev);
--
PATCH 6/7 d80211: fix invalid check for sub interface type AP
In reply to a message not in the archiveWe should be checking the type member, not the raw pointer.
net/d80211/ieee80211_ioctl.c +1 -1
@@ -1996,7 +1996,7 @@ static int ieee80211_ioctl_siwscan(struc sdata->type == IEEE80211_IF_TYPE_IBSS) { ssid = sdata->u.sta.ssid; ssid_len = sdata->u.sta.ssid_len; - } else if (sdata == IEEE80211_IF_TYPE_AP) { + } else if (sdata->type == IEEE80211_IF_TYPE_AP) { ssid = sdata->u.ap.ssid; ssid_len = sdata->u.ap.ssid_len; } else
--
PATCH 7/7 d80211: do not pass an invalid key index to set_key()
In reply to a message not in the archiveIf a hardware key has not been configured then there is no point to calling DISABLE_KEY.
net/d80211/ieee80211_ioctl.c +1 -1
@@ -612,7 +612,7 @@ static int ieee80211_set_encryption(struif (alg ==ALG_NONE ) { keyconf =NULL ; -if (try_hwaccel && key && local->ops->set_key && +if (try_hwaccel && key && key->hw_key_idx !=-1 && local->ops->set_key && (keyconf =ieee80211_key_data2conf (local, key)) !=NULL && local->ops->set_key (local_to_hw (local),DISABLE_KEY , sta_addr, keyconf, sta ? sta->aid :0 )) {
--
Re: [patch 7/7] d80211: do not pass an invalid key index to set_key()
net/d80211/ieee80211_ioctl.c static int ieee80211_set_encryption(stru · line 615
Quoted 10 lines · David Kimdon
Index:
wireless-dev/net/d80211/ieee80211_ioctl.c
===================================================================net/d80211/ieee80211_ioctl.c +1
-1@@ -612,7 +612,7 @@ static int ieee80211_set_encryption(struif (alg ==ALG_NONE ) { keyconf =NULL ; - if (try_hwaccel && key && local->ops->set_key && + if (try_hwaccel && key && key->hw_key_idx != -1 && local->ops->set_key &&
Use HW_KEY_IDX_INVALID, please.
Thanks,
Jiri
Signature · 2 lines
Jiri Benc SUSE Labs
Re: [patch 5/7] d80211: remove unused references to sub interface data
In reply to David KimdonQuoted 3 lines · David Kimdon
plain text document attachment (unused-sdata.patch)
In these three cases the pointer returned byIEEE80211_DEV_TO_SUB_IF()is never used.
Good catch, I must have introduced this when converting the prototypes. Thanks.
johannes
Re: [patch 6/7] d80211: fix invalid check for sub interface type AP
In reply to David KimdonPatches 1 to 6 have been applied to my tree.
Thanks,
Jiri
Quoted 3 lines · David Kimdon
We should be checking the type member, not the raw pointer.
Signed-off-by David Kimdon <[email protected]>
Signature · 2 lines
Jiri Benc SUSE Labs
Re: [patch 7/7] d80211: do not pass an invalid key index to set_key()
In reply to Jiri BencQuoted 2 lines
Use
HW_KEY_IDX_INVALID, please.
oops, here you go (also fixed bad indentation):
------
d80211: do not pass an invalid key index to set_key()
If a hardware key has not been configured then there is no point to calling DISABLE_KEY.
net/d80211/ieee80211_ioctl.c +3 -1
@@ -612,7 +612,9 @@ static int ieee80211_set_encryption(struif (alg ==ALG_NONE ) { keyconf =NULL ; -if (try_hwaccel && key && local->ops->set_key && +if (try_hwaccel && key && + key->hw_key_idx !=HW_KEY_IDX_INVALID && + local->ops->set_key && (keyconf =ieee80211_key_data2conf (local, key)) !=NULL && local->ops->set_key (local_to_hw (local),DISABLE_KEY , sta_addr, keyconf, sta ? sta->aid :0 )) {