airo: fix IW_AUTH_ALG_OPEN_SYSTEM
Subsystems (3)
PATCH v2 1/2 airo: fix IW_AUTH_ALG_OPEN_SYSTEM
IW_AUTH_ALG_OPEN_SYSTEM is ambiguous in set_auth for WEP as wpa_supplicant uses it for both no encryption and WEP open system. Cache the last mode set (only of these two) and use it here.
This allows wpa_supplicant to work with unencrypted APs.
--- drivers/net/wireless/airo.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-)
drivers/net/wireless/airo.c +24 -9
@@ -1237,6 +1237,7 @@ struct airo_info {int wep_capable;int max_wep_idx; +int last_auth;/* WPA-related stuff */ unsigned int bssListFirst;
@@ -3863,6 +3864,7 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock) } ai->config.opmode = adhoc ?MODE_STA_IBSS :MODE_STA_ESS ; ai->config.authType =AUTH_OPEN ; + ai->last_auth =AUTH_OPEN ; ai->config.modulation =MOD_CCK ; if (le16_to_cpu(cap_rid.len) >= sizeof(cap_rid) &&
@@ -6370,6 +6372,7 @@ static int airo_set_encode(struct net_device *dev,if ((index == current_index) && (key.len >0 ) && (local->config.authType ==AUTH_OPEN )) { local->config.authType =AUTH_ENCRYPT ; + local->last_auth =AUTH_ENCRYPT ; } }else {/* Do we want to just set the transmit key index ? */
@@ -6389,12 +6392,16 @@ static int airo_set_encode(struct net_device *dev, } }/* Read the flags */ -if (dwrq->flags &IW_ENCODE_DISABLED ) +if (dwrq->flags &IW_ENCODE_DISABLED ) { local->config.authType =AUTH_OPEN ;// disable encryption + local->last_auth =AUTH_OPEN ; + }if (dwrq->flags &IW_ENCODE_RESTRICTED ) local->config.authType =AUTH_SHAREDKEY ;// Only Both -if (dwrq->flags &IW_ENCODE_OPEN ) +if (dwrq->flags &IW_ENCODE_OPEN ) { local->config.authType =AUTH_ENCRYPT ;// Only Wep + local->last_auth =AUTH_ENCRYPT ; + }/* Commit the changes to flags if needed */ if (local->config.authType != currentAuthType)set_bit (FLAG_COMMIT , &local->flags);
@@ -6549,12 +6556,16 @@ static int airo_set_encodeext(struct net_device *dev, }/* Read the flags */ -if (encoding->flags &IW_ENCODE_DISABLED ) +if (encoding->flags &IW_ENCODE_DISABLED ) { local->config.authType =AUTH_OPEN ;// disable encryption + local->last_auth =AUTH_OPEN ; + }if (encoding->flags &IW_ENCODE_RESTRICTED ) local->config.authType =AUTH_SHAREDKEY ;// Only Both -if (encoding->flags &IW_ENCODE_OPEN ) +if (encoding->flags &IW_ENCODE_OPEN ) { local->config.authType =AUTH_ENCRYPT ;// Only Wep + local->last_auth =AUTH_ENCRYPT ; + }/* Commit the changes to flags if needed */ if (local->config.authType != currentAuthType)set_bit (FLAG_COMMIT , &local->flags);
@@ -6658,10 +6669,13 @@ static int airo_set_auth(struct net_device *dev,case IW_AUTH_DROP_UNENCRYPTED :if (param->value) {/* Only change auth type if unencrypted */ -if (currentAuthType ==AUTH_OPEN ) +if (currentAuthType ==AUTH_OPEN ) { local->config.authType =AUTH_ENCRYPT ; + local->last_auth =AUTH_ENCRYPT ; + } }else { local->config.authType =AUTH_OPEN ; + local->last_auth =AUTH_OPEN ; }/* Commit the changes to flags if needed */
@@ -6670,13 +6684,14 @@ static int airo_set_auth(struct net_device *dev,break ;case IW_AUTH_80211_AUTH_ALG : { -/* FIXME: What about AUTH_OPEN? This API seems to -* disallow setting our auth to AUTH_OPEN. -*/ if (param->value &IW_AUTH_ALG_SHARED_KEY ) { local->config.authType =AUTH_SHAREDKEY ; }else if (param->value &IW_AUTH_ALG_OPEN_SYSTEM ) { - local->config.authType =AUTH_ENCRYPT ; +/* We don't know here if WEP open system or +* unencrypted mode was requested - so use the +* last mode (of these two) used last time +*/ + local->config.authType = local->last_auth; }else return -EINVAL ;
Signature · 1 line
Ondrej Zary
PATCH 2/2 airo: Implement netif_carrier_on/off
Add calls to netif_carrier_on and netif_carrier_off
--- drivers/net/wireless/airo.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/wireless/airo.c +5 -1
@@ -3267,6 +3267,7 @@ static void airo_handle_link(struct airo_info *ai)wake_up_interruptible (&ai->thr_wait); }else airo_send_event (ai->dev); +netif_carrier_on (ai->dev); }else if (!scan_forceloss) {if (auto_wep && !ai->expires) { ai->expires =RUN_AT (3 *HZ );
@@ -3277,7 +3278,9 @@ static void airo_handle_link(struct airo_info *ai)eth_zero_addr (wrqu.ap_addr.sa_data); wrqu.ap_addr.sa_family =ARPHRD_ETHER ;wireless_send_event (ai->dev,SIOCGIWAP , &wrqu,NULL ); - } +netif_carrier_off (ai->dev); + }else +netif_carrier_off (ai->dev); }static void airo_handle_rx (struct airo_info *ai)
@@ -3613,6 +3616,7 @@ static void disable_MAC( struct airo_info *ai, int lock ) {return ;if (test_bit (FLAG_ENABLED , &ai->flags)) { +netif_carrier_off (ai->dev);memset (&cmd,0 ,sizeof (cmd)); cmd.cmd =MAC_DISABLE ;// disable in case already enabled issuecommand (ai, &cmd, &rsp);
Signature · 1 line
Ondrej Zary
Re: [PATCH 2/2] airo: Implement netif_carrier_on/off
Hello.
Quoted 11 lines · Ondrej Zary
Add calls to
netif_carrier_onandnetif_carrier_offSigned-off-by Ondrej Zary <[email protected]>--- drivers/net/wireless/airo.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/net/wireless/airo.c +0
-0
[...]
drivers/net/wireless/airo.c static void airo_handle_link(struct airo_info *ai) · line 3283
Quoted 8 lines
drivers/net/wireless/airo.c +3
-1@@ -3277,7 +3278,9 @@ static void airo_handle_link(struct airo_info *ai)eth_zero_addr (wrqu.ap_addr.sa_data); wrqu.ap_addr.sa_family =ARPHRD_ETHER ;wireless_send_event (ai->dev,SIOCGIWAP , &wrqu,NULL ); - } +netif_carrier_off (ai->dev); + }else +netif_carrier_off (ai->dev);
Need {} in all branches, according the the Documentation/CodingStyle.
drivers/net/wireless/airo.c static void airo_handle_link(struct airo_info *ai) · line 3286
Quoted 3 lines
drivers/net/wireless/airo.c +0
-0}static void airo_handle_rx (struct airo_info *ai)
[...]
MBR, Sergei
Quoted 5 lines · Ondrej Zary
IW_AUTH_ALG_OPEN_SYSTEMis ambiguous inset_authfor WEP aswpa_supplicantuses it for both no encryption and WEP open system. Cache the last mode set (only of these two) and use it here.This allows
wpa_supplicantto work with unencrypted APs.
It seems like this will work; but to make the code clearer, define a small static function like:
static inline void set_auth_type(struct airo_info *local, int auth_type)
{
local->config.authType = local->last_auth = auth_type;
}and call that from everywhere that you're currently setting authType and last_auth, except for airo_set_auth(). Less code and less probability to forget to set last_auth in the future.
Dan
Quoted 105 lines
Signed-off-by Ondrej Zary <[email protected]>--- drivers/net/wireless/airo.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-)drivers/net/wireless/airo.c +24
-9@@ -1237,6 +1237,7 @@ struct airo_info {int wep_capable;int max_wep_idx; +int last_auth;/* WPA-related stuff */ unsigned int bssListFirst;@@ -3863,6 +3864,7 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock) } ai->config.opmode = adhoc ?MODE_STA_IBSS :MODE_STA_ESS ; ai->config.authType =AUTH_OPEN ; + ai->last_auth =AUTH_OPEN ; ai->config.modulation =MOD_CCK ; if (le16_to_cpu(cap_rid.len) >= sizeof(cap_rid) &&@@ -6370,6 +6372,7 @@ static int airo_set_encode(struct net_device *dev,if ((index == current_index) && (key.len >0 ) && (local->config.authType ==AUTH_OPEN )) { local->config.authType =AUTH_ENCRYPT ; + local->last_auth =AUTH_ENCRYPT ; } }else {/* Do we want to just set the transmit key index ? */ @@ -6389,12 +6392,16 @@ static int airo_set_encode(struct net_device *dev, } }/* Read the flags */ -if (dwrq->flags &IW_ENCODE_DISABLED ) +if (dwrq->flags &IW_ENCODE_DISABLED ) { local->config.authType =AUTH_OPEN ;// disable encryption + local->last_auth =AUTH_OPEN ; + }if (dwrq->flags &IW_ENCODE_RESTRICTED ) local->config.authType =AUTH_SHAREDKEY ;// Only Both -if (dwrq->flags &IW_ENCODE_OPEN ) +if (dwrq->flags &IW_ENCODE_OPEN ) { local->config.authType =AUTH_ENCRYPT ;// Only Wep + local->last_auth =AUTH_ENCRYPT ; + }/* Commit the changes to flags if needed */ if (local->config.authType != currentAuthType)set_bit (FLAG_COMMIT , &local->flags);@@ -6549,12 +6556,16 @@ static int airo_set_encodeext(struct net_device *dev, }/* Read the flags */ -if (encoding->flags &IW_ENCODE_DISABLED ) +if (encoding->flags &IW_ENCODE_DISABLED ) { local->config.authType =AUTH_OPEN ;// disable encryption + local->last_auth =AUTH_OPEN ; + }if (encoding->flags &IW_ENCODE_RESTRICTED ) local->config.authType =AUTH_SHAREDKEY ;// Only Both -if (encoding->flags &IW_ENCODE_OPEN ) +if (encoding->flags &IW_ENCODE_OPEN ) { local->config.authType =AUTH_ENCRYPT ;// Only Wep + local->last_auth =AUTH_ENCRYPT ; + }/* Commit the changes to flags if needed */ if (local->config.authType != currentAuthType)set_bit (FLAG_COMMIT , &local->flags);@@ -6658,10 +6669,13 @@ static int airo_set_auth(struct net_device *dev,case IW_AUTH_DROP_UNENCRYPTED :if (param->value) {/* Only change auth type if unencrypted */ -if (currentAuthType ==AUTH_OPEN ) +if (currentAuthType ==AUTH_OPEN ) { local->config.authType =AUTH_ENCRYPT ; + local->last_auth =AUTH_ENCRYPT ; + } }else { local->config.authType =AUTH_OPEN ; + local->last_auth =AUTH_OPEN ; }/* Commit the changes to flags if needed */ @@ -6670,13 +6684,14 @@ static int airo_set_auth(struct net_device *dev,break ;case IW_AUTH_80211_AUTH_ALG : { -/* FIXME: What about AUTH_OPEN? This API seems to -* disallow setting our auth to AUTH_OPEN. -*/ if (param->value &IW_AUTH_ALG_SHARED_KEY ) { local->config.authType =AUTH_SHAREDKEY ; }else if (param->value &IW_AUTH_ALG_OPEN_SYSTEM ) { - local->config.authType =AUTH_ENCRYPT ; +/* We don't know here if WEP open system or +* unencrypted mode was requested - so use the +* last mode (of these two) used last time +*/ + local->config.authType = local->last_auth; }else return -EINVAL ;
Quoted 10 lines · On Friday 18 September 2015 18:54:35 Dan Williams wrote:
Quoted 5 lines · Ondrej Zary
IW_AUTH_ALG_OPEN_SYSTEMis ambiguous inset_authfor WEP aswpa_supplicantuses it for both no encryption and WEP open system. Cache the last mode set (only of these two) and use it here.This allows
wpa_supplicantto work with unencrypted APs.It seems like this will work; but to make the code clearer, define a small static function like:
Quoted 8 lines
static inline void
set_auth_type(struct airo_info *local, int auth_type){ local->config.authType = local->last_auth = auth_type; }and call that from everywhere that you're currently setting authType and
last_auth, except forairo_set_auth(). Less code and less probability to forget to setlast_authin the future.
Good idea, thanks.
BTW. What about WPA? Found some old patches adding WPA support to the airo driver. Something on your web: http://people.redhat.com/dcbw/airo-wpa/ and a "recent" (4 years) version at
http://svn.gna.org/viewcvs/airo-wpa/branches/kernel/
It looks ugly (wpa_enabled module parameter) but seems to work with WPA-PSK. Do you remember what's the problem with switching between WPA and WEP? I'm going to remove the wpa_enabled module parameter and allow run-time switching between WPA and WEP to see what breaks.
Signature · 1 line
Ondrej Zary
Quoted 27 lines · Ondrej Zary
Quoted 10 lines · On Friday 18 September 2015 18:54:35 Dan Williams wrote:
Quoted 5 lines · Ondrej Zary
IW_AUTH_ALG_OPEN_SYSTEMis ambiguous inset_authfor WEP aswpa_supplicantuses it for both no encryption and WEP open system. Cache the last mode set (only of these two) and use it here.This allows
wpa_supplicantto work with unencrypted APs.It seems like this will work; but to make the code clearer, define a small static function like:
Quoted 8 lines
static inline void
set_auth_type(struct airo_info *local, int auth_type){ local->config.authType = local->last_auth = auth_type; }and call that from everywhere that you're currently setting authType and
last_auth, except forairo_set_auth(). Less code and less probability to forget to setlast_authin the future.Good idea, thanks.
BTW. What about WPA? Found some old patches adding WPA support to the airo driver. Something on your web: http://people.redhat.com/dcbw/airo-wpa/ and a "recent" (4 years) version at
http://svn.gna.org/viewcvs/airo-wpa/branches/kernel/
Quoted 4 lines
It looks ugly (
wpa_enabledmodule parameter) but seems to work with WPA-PSK. Do you remember what's the problem with switching between WPA and WEP? I'm going to remove thewpa_enabledmodule parameter and allow run-time switching between WPA and WEP to see what breaks.
I think the module parameter was the deal-breaker. If you can get it working reliably with runtime switching based on the supplicant's requested config, that would be great. One problem was that you cannot require the WPA-enabled firmware, so you'll have to make sure that anything that does WPA-type stuff is protected by the "wpa_capable" flag or whatever it was.
Dan
Quoted 10 lines · Ondrej Zary
IW_AUTH_ALG_OPEN_SYSTEMis ambiguous inset_authfor WEP aswpa_supplicantuses it for both no encryption and WEP open system. Cache the last mode set (only of these two) and use it here.This allows
wpa_supplicantto work with unencrypted APs.Signed-off-by Ondrej Zary <[email protected]>--- drivers/net/wireless/airo.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-)
You should CC linux-wireless mailing list, otherwise patchwork won't see it and I will miss your patch:
https://patchwork.kernel.org/project/linux-wireless/list/
Signature · 1 line
Kalle Valo