linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libertas: automatically re-associate
@ 2007-10-09 12:04 Holger Schurig
  2007-10-09 14:19 ` Dan Williams
  0 siblings, 1 reply; 9+ messages in thread
From: Holger Schurig @ 2007-10-09 12:04 UTC (permalink / raw)
  To: linux-wireless, libertas-dev, Dan Williams

Automatically re-association to an access point when we get de-associated.
This is especially helpful if an AP de-associates us because scanning took
to long (remember, the my firmware can't send 802.11 powersafe null packets).

* don't free pending_assoc_req in the association worker, keep it as is.
* free pending_assoc_req at adapter removal time.
* when we get a MAC level event saying that we've been de-associated, use
  the alredy filled in association record to make a new scan and
  re-associate.
* also moved wlan_postpone_association_work() and
  wlan_cancel_association_work() from a *.h file to the sole user, into
  wext.h. Renamed them to libertas_XXX as well.

Signed-off-by: Holger Schurig <hs4233@mail.mn-solutions.de>

---

BTW, I've done a little bit of research (err, trying out). At least
orinoco_cs, ipw2200 and bcm43xx all automatically re-associate.

Months ago Dan once said that I should add some logic to not re-associate
more than X times to an AP. So far I don't know of any fullmac driver that
does is. Also I think that this makes things needlessly complicated. And it
buys us nothing. If an AP really doesn't want to have a client not associated
to itself, it should apply better means, e.g. WPA/WPA2 ...

Index: libertas-2.6/drivers/net/wireless/libertas/assoc.c
===================================================================
--- libertas-2.6.orig/drivers/net/wireless/libertas/assoc.c	2007-10-09 14:39:30.000000000 +0200
+++ libertas-2.6/drivers/net/wireless/libertas/assoc.c	2007-10-09 14:48:49.000000000 +0200
@@ -506,7 +506,6 @@ void libertas_association_worker(struct 
 
 	mutex_lock(&adapter->lock);
 	assoc_req = adapter->pending_assoc_req;
-	adapter->pending_assoc_req = NULL;
 	adapter->in_progress_assoc_req = assoc_req;
 	mutex_unlock(&adapter->lock);
 
@@ -675,7 +674,6 @@ out:
 	mutex_lock(&adapter->lock);
 	adapter->in_progress_assoc_req = NULL;
 	mutex_unlock(&adapter->lock);
-	kfree(assoc_req);
 
 done:
 	lbs_deb_leave(LBS_DEB_ASSOC);
Index: libertas-2.6/drivers/net/wireless/libertas/assoc.h
===================================================================
--- libertas-2.6.orig/drivers/net/wireless/libertas/assoc.h	2007-10-09 14:38:33.000000000 +0200
+++ libertas-2.6/drivers/net/wireless/libertas/assoc.h	2007-10-09 14:48:49.000000000 +0200
@@ -11,22 +11,4 @@ struct assoc_request * wlan_get_associat
 
 void libertas_sync_channel(struct work_struct *work);
 
-#define ASSOC_DELAY (HZ / 2)
-static inline void wlan_postpone_association_work(wlan_private *priv)
-{
-	if (priv->adapter->surpriseremoved)
-		return;
-	cancel_delayed_work(&priv->assoc_work);
-	queue_delayed_work(priv->work_thread, &priv->assoc_work, ASSOC_DELAY);
-}
-
-static inline void wlan_cancel_association_work(wlan_private *priv)
-{
-	cancel_delayed_work(&priv->assoc_work);
-	if (priv->adapter->pending_assoc_req) {
-		kfree(priv->adapter->pending_assoc_req);
-		priv->adapter->pending_assoc_req = NULL;
-	}
-}
-
 #endif /* _WLAN_ASSOC_H */
Index: libertas-2.6/drivers/net/wireless/libertas/cmdresp.c
===================================================================
--- libertas-2.6.orig/drivers/net/wireless/libertas/cmdresp.c	2007-10-09 14:38:33.000000000 +0200
+++ libertas-2.6/drivers/net/wireless/libertas/cmdresp.c	2007-10-09 14:49:05.000000000 +0200
@@ -79,6 +79,13 @@ void libertas_mac_event_disconnected(wla
 		lbs_deb_cmd("disconnected, so exit PS mode\n");
 		libertas_ps_wakeup(priv, 0);
 	}
+
+	if (adapter->pending_assoc_req) {
+		cancel_delayed_work(&priv->assoc_work);
+		queue_delayed_work(priv->work_thread,
+			&priv->assoc_work, HZ / 4);
+	}
+
 	lbs_deb_leave(LBS_DEB_CMD);
 }
 
Index: libertas-2.6/drivers/net/wireless/libertas/main.c
===================================================================
--- libertas-2.6.orig/drivers/net/wireless/libertas/main.c	2007-10-09 14:38:33.000000000 +0200
+++ libertas-2.6/drivers/net/wireless/libertas/main.c	2007-10-09 14:48:49.000000000 +0200
@@ -460,11 +460,17 @@ static int libertas_open(struct net_devi
 static int libertas_dev_close(struct net_device *dev)
 {
 	wlan_private *priv = dev->priv;
+	wlan_adapter *adapter = priv->adapter;
 
 	lbs_deb_enter(LBS_DEB_NET);
 
-	netif_carrier_off(priv->dev);
+	mutex_lock(&adapter->lock);
 	priv->open = 0;
+	adapter->connect_status = LIBERTAS_DISCONNECTED;
+	kfree(adapter->pending_assoc_req);
+	adapter->pending_assoc_req = NULL;
+	mutex_unlock(&adapter->lock);
+	netif_carrier_off(priv->dev);
 
 	lbs_deb_leave(LBS_DEB_NET);
 	return 0;
@@ -1103,15 +1109,10 @@ static void libertas_free_adapter(wlan_p
 		return;
 	}
 
-	lbs_deb_fw("free command buffer\n");
 	libertas_free_cmd_buffer(priv);
-
-	lbs_deb_fw("free command_timer\n");
 	del_timer(&adapter->command_timer);
-
-	lbs_deb_fw("free scan results table\n");
 	kfree(adapter->networks);
-	adapter->networks = NULL;
+	kfree(adapter->pending_assoc_req);
 
 	/* Free the adapter object itself */
 	lbs_deb_fw("free adapter\n");
Index: libertas-2.6/drivers/net/wireless/libertas/wext.c
===================================================================
--- libertas-2.6.orig/drivers/net/wireless/libertas/wext.c	2007-10-09 14:38:33.000000000 +0200
+++ libertas-2.6/drivers/net/wireless/libertas/wext.c	2007-10-09 14:48:49.000000000 +0200
@@ -21,6 +21,20 @@
 #include "assoc.h"
 
 
+static inline void libertas_postpone_association_work(wlan_private *priv)
+{
+	if (priv->adapter->surpriseremoved)
+		return;
+	cancel_delayed_work(&priv->assoc_work);
+	queue_delayed_work(priv->work_thread, &priv->assoc_work, HZ / 2);
+}
+
+static inline void libertas_cancel_association_work(wlan_private *priv)
+{
+	cancel_delayed_work(&priv->assoc_work);
+}
+
+
 /**
  *  @brief Find the channel frequency power info with specific channel
  *
@@ -969,9 +983,9 @@ static int wlan_set_freq(struct net_devi
 out:
 	if (ret == 0) {
 		set_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags);
-		wlan_postpone_association_work(priv);
+		libertas_postpone_association_work(priv);
 	} else {
-		wlan_cancel_association_work(priv);
+		libertas_cancel_association_work(priv);
 	}
 	mutex_unlock(&adapter->lock);
 
@@ -1070,11 +1084,11 @@ static int wlan_set_mode(struct net_devi
 	assoc_req = wlan_get_association_request(adapter);
 	if (!assoc_req) {
 		ret = -ENOMEM;
-		wlan_cancel_association_work(priv);
+		libertas_cancel_association_work(priv);
 	} else {
 		assoc_req->mode = *uwrq;
 		set_bit(ASSOC_FLAG_MODE, &assoc_req->flags);
-		wlan_postpone_association_work(priv);
+		libertas_postpone_association_work(priv);
 		lbs_deb_wext("Switching to mode: 0x%x\n", *uwrq);
 	}
 	mutex_unlock(&adapter->lock);
@@ -1355,9 +1369,9 @@ static int wlan_set_encode(struct net_de
 out:
 	if (ret == 0) {
 		set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
-		wlan_postpone_association_work(priv);
+		libertas_postpone_association_work(priv);
 	} else {
-		wlan_cancel_association_work(priv);
+		libertas_cancel_association_work(priv);
 	}
 	mutex_unlock(&adapter->lock);
 
@@ -1596,9 +1610,9 @@ static int wlan_set_encodeext(struct net
 
 out:
 	if (ret == 0) {
-		wlan_postpone_association_work(priv);
+		libertas_postpone_association_work(priv);
 	} else {
-		wlan_cancel_association_work(priv);
+		libertas_cancel_association_work(priv);
 	}
 	mutex_unlock(&adapter->lock);
 
@@ -1643,9 +1657,9 @@ static int wlan_set_genie(struct net_dev
 out:
 	if (ret == 0) {
 		set_bit(ASSOC_FLAG_WPA_IE, &assoc_req->flags);
-		wlan_postpone_association_work(priv);
+		libertas_postpone_association_work(priv);
 	} else {
-		wlan_cancel_association_work(priv);
+		libertas_cancel_association_work(priv);
 	}
 	mutex_unlock(&adapter->lock);
 
@@ -1772,9 +1786,9 @@ out:
 	if (ret == 0) {
 		if (updated)
 			set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
-		wlan_postpone_association_work(priv);
+		libertas_postpone_association_work(priv);
 	} else if (ret != -EOPNOTSUPP) {
-		wlan_cancel_association_work(priv);
+		libertas_cancel_association_work(priv);
 	}
 	mutex_unlock(&adapter->lock);
 
@@ -1949,13 +1963,13 @@ out:
 			memcpy(&assoc_req->ssid, &ssid, IW_ESSID_MAX_SIZE);
 			assoc_req->ssid_len = ssid_len;
 			set_bit(ASSOC_FLAG_SSID, &assoc_req->flags);
-			wlan_postpone_association_work(priv);
+			libertas_postpone_association_work(priv);
 		}
 	}
 
 	/* Cancel the association request if there was an error */
 	if (ret != 0) {
-		wlan_cancel_association_work(priv);
+		libertas_cancel_association_work(priv);
 	}
 
 	mutex_unlock(&adapter->lock);
@@ -1993,13 +2007,13 @@ static int wlan_set_wap(struct net_devic
 	/* Get or create the current association request */
 	assoc_req = wlan_get_association_request(adapter);
 	if (!assoc_req) {
-		wlan_cancel_association_work(priv);
+		libertas_cancel_association_work(priv);
 		ret = -ENOMEM;
 	} else {
 		/* Copy the BSSID to the association request */
 		memcpy(&assoc_req->bssid, awrq->sa_data, ETH_ALEN);
 		set_bit(ASSOC_FLAG_BSSID, &assoc_req->flags);
-		wlan_postpone_association_work(priv);
+		libertas_postpone_association_work(priv);
 	}
 
 	mutex_unlock(&adapter->lock);

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] libertas: automatically re-associate
  2007-10-09 12:04 [PATCH] libertas: automatically re-associate Holger Schurig
@ 2007-10-09 14:19 ` Dan Williams
  2007-10-09 15:13   ` Holger Schurig
  0 siblings, 1 reply; 9+ messages in thread
From: Dan Williams @ 2007-10-09 14:19 UTC (permalink / raw)
  To: Holger Schurig; +Cc: linux-wireless, libertas-dev

On Tue, 2007-10-09 at 14:04 +0200, Holger Schurig wrote:
> Automatically re-association to an access point when we get de-associated.
> This is especially helpful if an AP de-associates us because scanning took
> to long (remember, the my firmware can't send 802.11 powersafe null packets).
> 
> * don't free pending_assoc_req in the association worker, keep it as is.
> * free pending_assoc_req at adapter removal time.
> * when we get a MAC level event saying that we've been de-associated, use
>   the alredy filled in association record to make a new scan and
>   re-associate.
> * also moved wlan_postpone_association_work() and
>   wlan_cancel_association_work() from a *.h file to the sole user, into
>   wext.h. Renamed them to libertas_XXX as well.
> 
> Signed-off-by: Holger Schurig <hs4233@mail.mn-solutions.de>
> 
> ---
> 
> BTW, I've done a little bit of research (err, trying out). At least
> orinoco_cs, ipw2200 and bcm43xx all automatically re-associate.
> 
> Months ago Dan once said that I should add some logic to not re-associate
> more than X times to an AP. So far I don't know of any fullmac driver that
> does is. Also I think that this makes things needlessly complicated. And it
> buys us nothing. If an AP really doesn't want to have a client not associated
> to itself, it should apply better means, e.g. WPA/WPA2 ...

Seriously though, even if other drivers don't do it, that doesn't mean
libertas shouldn't do it.  If the association fails, doesn't this mean
the card just keeps working and keeps trying to associate forever?  I
think that's just plain wrong.  It's not that much more complicated to
add an item to the association structure for 'count' and to check that
from the disassociation event code, and just not reschedule association
if that's > 4.

Dan

> Index: libertas-2.6/drivers/net/wireless/libertas/assoc.c
> ===================================================================
> --- libertas-2.6.orig/drivers/net/wireless/libertas/assoc.c	2007-10-09 14:39:30.000000000 +0200
> +++ libertas-2.6/drivers/net/wireless/libertas/assoc.c	2007-10-09 14:48:49.000000000 +0200
> @@ -506,7 +506,6 @@ void libertas_association_worker(struct 
>  
>  	mutex_lock(&adapter->lock);
>  	assoc_req = adapter->pending_assoc_req;
> -	adapter->pending_assoc_req = NULL;
>  	adapter->in_progress_assoc_req = assoc_req;
>  	mutex_unlock(&adapter->lock);
>  
> @@ -675,7 +674,6 @@ out:
>  	mutex_lock(&adapter->lock);
>  	adapter->in_progress_assoc_req = NULL;
>  	mutex_unlock(&adapter->lock);
> -	kfree(assoc_req);
>  
>  done:
>  	lbs_deb_leave(LBS_DEB_ASSOC);
> Index: libertas-2.6/drivers/net/wireless/libertas/assoc.h
> ===================================================================
> --- libertas-2.6.orig/drivers/net/wireless/libertas/assoc.h	2007-10-09 14:38:33.000000000 +0200
> +++ libertas-2.6/drivers/net/wireless/libertas/assoc.h	2007-10-09 14:48:49.000000000 +0200
> @@ -11,22 +11,4 @@ struct assoc_request * wlan_get_associat
>  
>  void libertas_sync_channel(struct work_struct *work);
>  
> -#define ASSOC_DELAY (HZ / 2)
> -static inline void wlan_postpone_association_work(wlan_private *priv)
> -{
> -	if (priv->adapter->surpriseremoved)
> -		return;
> -	cancel_delayed_work(&priv->assoc_work);
> -	queue_delayed_work(priv->work_thread, &priv->assoc_work, ASSOC_DELAY);
> -}
> -
> -static inline void wlan_cancel_association_work(wlan_private *priv)
> -{
> -	cancel_delayed_work(&priv->assoc_work);
> -	if (priv->adapter->pending_assoc_req) {
> -		kfree(priv->adapter->pending_assoc_req);
> -		priv->adapter->pending_assoc_req = NULL;
> -	}
> -}
> -
>  #endif /* _WLAN_ASSOC_H */
> Index: libertas-2.6/drivers/net/wireless/libertas/cmdresp.c
> ===================================================================
> --- libertas-2.6.orig/drivers/net/wireless/libertas/cmdresp.c	2007-10-09 14:38:33.000000000 +0200
> +++ libertas-2.6/drivers/net/wireless/libertas/cmdresp.c	2007-10-09 14:49:05.000000000 +0200
> @@ -79,6 +79,13 @@ void libertas_mac_event_disconnected(wla
>  		lbs_deb_cmd("disconnected, so exit PS mode\n");
>  		libertas_ps_wakeup(priv, 0);
>  	}
> +
> +	if (adapter->pending_assoc_req) {
> +		cancel_delayed_work(&priv->assoc_work);
> +		queue_delayed_work(priv->work_thread,
> +			&priv->assoc_work, HZ / 4);
> +	}
> +
>  	lbs_deb_leave(LBS_DEB_CMD);
>  }
>  
> Index: libertas-2.6/drivers/net/wireless/libertas/main.c
> ===================================================================
> --- libertas-2.6.orig/drivers/net/wireless/libertas/main.c	2007-10-09 14:38:33.000000000 +0200
> +++ libertas-2.6/drivers/net/wireless/libertas/main.c	2007-10-09 14:48:49.000000000 +0200
> @@ -460,11 +460,17 @@ static int libertas_open(struct net_devi
>  static int libertas_dev_close(struct net_device *dev)
>  {
>  	wlan_private *priv = dev->priv;
> +	wlan_adapter *adapter = priv->adapter;
>  
>  	lbs_deb_enter(LBS_DEB_NET);
>  
> -	netif_carrier_off(priv->dev);
> +	mutex_lock(&adapter->lock);
>  	priv->open = 0;
> +	adapter->connect_status = LIBERTAS_DISCONNECTED;
> +	kfree(adapter->pending_assoc_req);
> +	adapter->pending_assoc_req = NULL;
> +	mutex_unlock(&adapter->lock);
> +	netif_carrier_off(priv->dev);
>  
>  	lbs_deb_leave(LBS_DEB_NET);
>  	return 0;
> @@ -1103,15 +1109,10 @@ static void libertas_free_adapter(wlan_p
>  		return;
>  	}
>  
> -	lbs_deb_fw("free command buffer\n");
>  	libertas_free_cmd_buffer(priv);
> -
> -	lbs_deb_fw("free command_timer\n");
>  	del_timer(&adapter->command_timer);
> -
> -	lbs_deb_fw("free scan results table\n");
>  	kfree(adapter->networks);
> -	adapter->networks = NULL;
> +	kfree(adapter->pending_assoc_req);
>  
>  	/* Free the adapter object itself */
>  	lbs_deb_fw("free adapter\n");
> Index: libertas-2.6/drivers/net/wireless/libertas/wext.c
> ===================================================================
> --- libertas-2.6.orig/drivers/net/wireless/libertas/wext.c	2007-10-09 14:38:33.000000000 +0200
> +++ libertas-2.6/drivers/net/wireless/libertas/wext.c	2007-10-09 14:48:49.000000000 +0200
> @@ -21,6 +21,20 @@
>  #include "assoc.h"
>  
> 
> +static inline void libertas_postpone_association_work(wlan_private *priv)
> +{
> +	if (priv->adapter->surpriseremoved)
> +		return;
> +	cancel_delayed_work(&priv->assoc_work);
> +	queue_delayed_work(priv->work_thread, &priv->assoc_work, HZ / 2);
> +}
> +
> +static inline void libertas_cancel_association_work(wlan_private *priv)
> +{
> +	cancel_delayed_work(&priv->assoc_work);
> +}
> +
> +
>  /**
>   *  @brief Find the channel frequency power info with specific channel
>   *
> @@ -969,9 +983,9 @@ static int wlan_set_freq(struct net_devi
>  out:
>  	if (ret == 0) {
>  		set_bit(ASSOC_FLAG_CHANNEL, &assoc_req->flags);
> -		wlan_postpone_association_work(priv);
> +		libertas_postpone_association_work(priv);
>  	} else {
> -		wlan_cancel_association_work(priv);
> +		libertas_cancel_association_work(priv);
>  	}
>  	mutex_unlock(&adapter->lock);
>  
> @@ -1070,11 +1084,11 @@ static int wlan_set_mode(struct net_devi
>  	assoc_req = wlan_get_association_request(adapter);
>  	if (!assoc_req) {
>  		ret = -ENOMEM;
> -		wlan_cancel_association_work(priv);
> +		libertas_cancel_association_work(priv);
>  	} else {
>  		assoc_req->mode = *uwrq;
>  		set_bit(ASSOC_FLAG_MODE, &assoc_req->flags);
> -		wlan_postpone_association_work(priv);
> +		libertas_postpone_association_work(priv);
>  		lbs_deb_wext("Switching to mode: 0x%x\n", *uwrq);
>  	}
>  	mutex_unlock(&adapter->lock);
> @@ -1355,9 +1369,9 @@ static int wlan_set_encode(struct net_de
>  out:
>  	if (ret == 0) {
>  		set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
> -		wlan_postpone_association_work(priv);
> +		libertas_postpone_association_work(priv);
>  	} else {
> -		wlan_cancel_association_work(priv);
> +		libertas_cancel_association_work(priv);
>  	}
>  	mutex_unlock(&adapter->lock);
>  
> @@ -1596,9 +1610,9 @@ static int wlan_set_encodeext(struct net
>  
>  out:
>  	if (ret == 0) {
> -		wlan_postpone_association_work(priv);
> +		libertas_postpone_association_work(priv);
>  	} else {
> -		wlan_cancel_association_work(priv);
> +		libertas_cancel_association_work(priv);
>  	}
>  	mutex_unlock(&adapter->lock);
>  
> @@ -1643,9 +1657,9 @@ static int wlan_set_genie(struct net_dev
>  out:
>  	if (ret == 0) {
>  		set_bit(ASSOC_FLAG_WPA_IE, &assoc_req->flags);
> -		wlan_postpone_association_work(priv);
> +		libertas_postpone_association_work(priv);
>  	} else {
> -		wlan_cancel_association_work(priv);
> +		libertas_cancel_association_work(priv);
>  	}
>  	mutex_unlock(&adapter->lock);
>  
> @@ -1772,9 +1786,9 @@ out:
>  	if (ret == 0) {
>  		if (updated)
>  			set_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags);
> -		wlan_postpone_association_work(priv);
> +		libertas_postpone_association_work(priv);
>  	} else if (ret != -EOPNOTSUPP) {
> -		wlan_cancel_association_work(priv);
> +		libertas_cancel_association_work(priv);
>  	}
>  	mutex_unlock(&adapter->lock);
>  
> @@ -1949,13 +1963,13 @@ out:
>  			memcpy(&assoc_req->ssid, &ssid, IW_ESSID_MAX_SIZE);
>  			assoc_req->ssid_len = ssid_len;
>  			set_bit(ASSOC_FLAG_SSID, &assoc_req->flags);
> -			wlan_postpone_association_work(priv);
> +			libertas_postpone_association_work(priv);
>  		}
>  	}
>  
>  	/* Cancel the association request if there was an error */
>  	if (ret != 0) {
> -		wlan_cancel_association_work(priv);
> +		libertas_cancel_association_work(priv);
>  	}
>  
>  	mutex_unlock(&adapter->lock);
> @@ -1993,13 +2007,13 @@ static int wlan_set_wap(struct net_devic
>  	/* Get or create the current association request */
>  	assoc_req = wlan_get_association_request(adapter);
>  	if (!assoc_req) {
> -		wlan_cancel_association_work(priv);
> +		libertas_cancel_association_work(priv);
>  		ret = -ENOMEM;
>  	} else {
>  		/* Copy the BSSID to the association request */
>  		memcpy(&assoc_req->bssid, awrq->sa_data, ETH_ALEN);
>  		set_bit(ASSOC_FLAG_BSSID, &assoc_req->flags);
> -		wlan_postpone_association_work(priv);
> +		libertas_postpone_association_work(priv);
>  	}
>  
>  	mutex_unlock(&adapter->lock);


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] libertas: automatically re-associate
  2007-10-09 14:19 ` Dan Williams
@ 2007-10-09 15:13   ` Holger Schurig
  2007-10-09 15:37     ` Dan Williams
  0 siblings, 1 reply; 9+ messages in thread
From: Holger Schurig @ 2007-10-09 15:13 UTC (permalink / raw)
  To: linux-wireless; +Cc: Dan Williams, libertas-dev

> Seriously though, even if other drivers don't do it, that
> doesn't mean libertas shouldn't do it.  If the association
> fails, doesn't this mean the card just keeps working and keeps
> trying to associate forever?

Yes, with a HZ/4 rate.

Maybe in the meantime the user is configuring the right WEP key 
into his AP?



> It's not that much more complicated to add an item to the
> association structure for 'count' and to check that from the
> disassociation event code, and just not reschedule association
> if that's > 4.

And after this 4 tries the device is again stuck?  That's not 
nice.

Therefore you need some heuristic (I don't dare to name this 
logic) to reset this counter again. But when do you do it?  If 
you say "5 Minutes", then I simply change my HZ/4 into HZ*60*5 
and have the same effect.

So I see that my HZ/4 is as arbitrary as your 4, but my version 
is fail-safe, because when you move away from a mis-configured 
AP to a right on, the device will automatically re-associate. 
You see, I aim for a roaming client, not for a device that stays 
put at some office desktop.


We also get disassociated from an AP when we're away from the 
channel for too long, busy scanning for a better AP. The case 
where someone clicks on a "Deassociate Client") is neglibibly. 

But even when I want to have it work automatically, and without 
any manual user interaction at the WLAN client.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] libertas: automatically re-associate
  2007-10-09 15:13   ` Holger Schurig
@ 2007-10-09 15:37     ` Dan Williams
  2007-10-10  7:43       ` Holger Schurig
  0 siblings, 1 reply; 9+ messages in thread
From: Dan Williams @ 2007-10-09 15:37 UTC (permalink / raw)
  To: Holger Schurig; +Cc: linux-wireless, libertas-dev

On Tue, 2007-10-09 at 17:13 +0200, Holger Schurig wrote:
> > Seriously though, even if other drivers don't do it, that
> > doesn't mean libertas shouldn't do it.  If the association
> > fails, doesn't this mean the card just keeps working and keeps
> > trying to associate forever?
> 
> Yes, with a HZ/4 rate.

I don't care how _fast_ it tries to reassociate.  I care that it doesn't
give up after some amount of time.

> Maybe in the meantime the user is configuring the right WEP key 
> into his AP?
> 
> 
> 
> > It's not that much more complicated to add an item to the
> > association structure for 'count' and to check that from the
> > disassociation event code, and just not reschedule association
> > if that's > 4.
> 
> And after this 4 tries the device is again stuck?  That's not 
> nice.
> 
> Therefore you need some heuristic (I don't dare to name this 
> logic) to reset this counter again. But when do you do it?  If 
> you say "5 Minutes", then I simply change my HZ/4 into HZ*60*5 
> and have the same effect.
> 
> So I see that my HZ/4 is as arbitrary as your 4, but my version 
> is fail-safe, because when you move away from a mis-configured 
> AP to a right on, the device will automatically re-associate. 
> You see, I aim for a roaming client, not for a device that stays 
> put at some office desktop.

That's fine.  The drivers should _not_ be trying to handle all roaming
cornercases themselves.  And I believe that includes forever trying
reassociating.  Userspace must come into the equation at some point,
especially with WPA!!  This reassociation trick _only_ works for WEP.
And that immediately makes it less useful.

My point is that the _driver_ should only go so far in trying to guess
the intentions of the user and userspace itself.  It's not the drivers
job to cover every conceivable use-case, especially where the heuristics
are quite fuzzy.  That sort of thing just doesn't belong in drivers.

Dan

> 
> We also get disassociated from an AP when we're away from the 
> channel for too long, busy scanning for a better AP. The case 
> where someone clicks on a "Deassociate Client") is neglibibly. 
> 
> But even when I want to have it work automatically, and without 
> any manual user interaction at the WLAN client.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] libertas: automatically re-associate
  2007-10-09 15:37     ` Dan Williams
@ 2007-10-10  7:43       ` Holger Schurig
  2007-10-10 14:58         ` Dan Williams
  0 siblings, 1 reply; 9+ messages in thread
From: Holger Schurig @ 2007-10-10  7:43 UTC (permalink / raw)
  To: libertas-dev, linux-wireless, Dan Williams

> > Yes, with a HZ/4 rate.
>
> I don't care how _fast_ it tries to reassociate.  I care that
> it doesn't give up after some amount of time.

And I don't want that the driver get's stuck after some arbitrary 
time. *NO OTHER DRIVER* that I know of get's stuck. The current 
libertas code has actually a built-in denial of service attack.

Libertas isn't just used in the OLPC, where can make sure some 
userspace tools does the job. I'll using libertas in PDA like 
devices, which used to have some HERMES I or HERMES II chips and 
have to switch to some other CF card because you can't buy CF 
cards with those chips any more. And on those device you can't 
just arbitrarily change the rest of the firmware.

So, at least in the no encryption & WEP obfuscation mode a WLAN 
driver should work without special user space software, because 
that's how real-life dictates the operation.

And, as said, otherwise you have a denial of service scenario.


> That's fine.  The drivers should _not_ be trying to handle all
> roaming cornercases themselves.

Either the driver or the firmware should handle all corner cases. 
With a HERMES II chip and a wlags49_h2_cs.ko driver, I can 
nicely roam with WPA+wpa_supplicant, and also with plain WEP 
(and no wpa_supplicant).

I see no technical reason why libertas shouldn't be able to do 
the same and behave like all other FULLMAC drivers.


> Userspace must come into the equation at some point, especially
> with WPA!!

I don't see that userspace *MUST* come into the equation at some 
point. If it *WISHES* to come into the equation: nothing hinders 
it. Running "iwevent" while killing the station at the AP yields 
these events:

10:38:43.139777   eth1     New Access Point/Cell 
address:Not-Associated
10:38:43.389217   eth1     Scan request completed
10:38:45.161671   eth1     New Access Point/Cell 
address:00:1B:53:11:E2:B0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] libertas: automatically re-associate
  2007-10-10  7:43       ` Holger Schurig
@ 2007-10-10 14:58         ` Dan Williams
  2007-10-10 16:59           ` John W. Linville
  2007-10-10 19:00           ` Holger Schurig
  0 siblings, 2 replies; 9+ messages in thread
From: Dan Williams @ 2007-10-10 14:58 UTC (permalink / raw)
  To: Holger Schurig; +Cc: libertas-dev, linux-wireless

On Wed, 2007-10-10 at 09:43 +0200, Holger Schurig wrote:
> > > Yes, with a HZ/4 rate.
> >
> > I don't care how _fast_ it tries to reassociate.  I care that
> > it doesn't give up after some amount of time.
> 
> And I don't want that the driver get's stuck after some arbitrary 
> time. *NO OTHER DRIVER* that I know of get's stuck. The current 
> libertas code has actually a built-in denial of service attack.
> 
> Libertas isn't just used in the OLPC, where can make sure some 
> userspace tools does the job. I'll using libertas in PDA like 

I have personally used it on platforms that are !OLPC.  Please don't
assume that I only care about libertas on OLPC.

> devices, which used to have some HERMES I or HERMES II chips and 
> have to switch to some other CF card because you can't buy CF 
> cards with those chips any more. And on those device you can't 
> just arbitrarily change the rest of the firmware.
> 
> So, at least in the no encryption & WEP obfuscation mode a WLAN 
> driver should work without special user space software, because 
> that's how real-life dictates the operation.

I won't throw a hissy fit over the reassociation patch as long as it
only tries this in open & WEP situations where a supplicant is not
necessary.  That means you cannot simply requeue an association in
libertas_mac_event_disconnected(), but you should check the association
request and not requeue if:

1) the assoc request's mode is ad-hoc (is there a point to retrying
assoc in adhoc?)
2) the assoc request has secinfo->WPAenabled || secinfo->WPA2enabled
3) the assoc request has WPA mcast or unicast keys set
4) the assoc request has a wpa_ie_len > 0

so in libertas_mac_event_disconnected() it should to be something like
the following:

if (adapter->pending_assoc_req) {
    if (test_bit(ASSOC_FLAG_MODE, &assoc_req->flags))
        if (assoc_req->mode != IW_MODE_INFRA)
            goto done;

    if (test_bit(ASSOC_FLAG_SECINFO, &assoc_req->flags))
        if (assoc_req->secinfo.WPAenabled ||assoc_req->secinfo.WPA2enabled)
            goto done;

    if (test_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags))
        if (assoc_req->wpa_mcast_key.len)
            goto done;

    if (test_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags))
        if (assoc_req->wpa_ucast_key.len)
            goto done;

    if (test_bit(ASSOC_FLAG_WPA_IE, &assoc_req->flags))
        if (assoc_req->wpa_ie_len > 0)
            goto done;

    cancel_delayed_work(&priv->assoc_work);
    queue_delayed_work(priv->work_thread,
            &priv->assoc_work, HZ / 4);

done:
    ;
}

Dan

> And, as said, otherwise you have a denial of service scenario.
> 
> 
> > That's fine.  The drivers should _not_ be trying to handle all
> > roaming cornercases themselves.
> 
> Either the driver or the firmware should handle all corner cases. 
> With a HERMES II chip and a wlags49_h2_cs.ko driver, I can 
> nicely roam with WPA+wpa_supplicant, and also with plain WEP 
> (and no wpa_supplicant).
> 
> I see no technical reason why libertas shouldn't be able to do 
> the same and behave like all other FULLMAC drivers.
> 
> 
> > Userspace must come into the equation at some point, especially
> > with WPA!!
> 
> I don't see that userspace *MUST* come into the equation at some 
> point. If it *WISHES* to come into the equation: nothing hinders 
> it. Running "iwevent" while killing the station at the AP yields 
> these events:
> 
> 10:38:43.139777   eth1     New Access Point/Cell 
> address:Not-Associated
> 10:38:43.389217   eth1     Scan request completed
> 10:38:45.161671   eth1     New Access Point/Cell 
> address:00:1B:53:11:E2:B0
> 


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] libertas: automatically re-associate
  2007-10-10 14:58         ` Dan Williams
@ 2007-10-10 16:59           ` John W. Linville
  2007-10-11  4:00             ` Dan Williams
  2007-10-10 19:00           ` Holger Schurig
  1 sibling, 1 reply; 9+ messages in thread
From: John W. Linville @ 2007-10-10 16:59 UTC (permalink / raw)
  To: Dan Williams; +Cc: Holger Schurig, libertas-dev, linux-wireless

On Wed, Oct 10, 2007 at 10:58:58AM -0400, Dan Williams wrote:

> I won't throw a hissy fit over the reassociation patch as long as it
> only tries this in open & WEP situations where a supplicant is not
> necessary.  That means you cannot simply requeue an association in
> libertas_mac_event_disconnected(), but you should check the association
> request and not requeue if:
> 
> 1) the assoc request's mode is ad-hoc (is there a point to retrying
> assoc in adhoc?)

I'm not sure I see why ad-hoc is a special case?

John
-- 
John W. Linville
linville@tuxdriver.com

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] libertas: automatically re-associate
  2007-10-10 14:58         ` Dan Williams
  2007-10-10 16:59           ` John W. Linville
@ 2007-10-10 19:00           ` Holger Schurig
  1 sibling, 0 replies; 9+ messages in thread
From: Holger Schurig @ 2007-10-10 19:00 UTC (permalink / raw)
  To: Dan Williams; +Cc: libertas-dev, linux-wireless

> so in libertas_mac_event_disconnected() it should to be something like
> the following:
...



I'll look in some of the next days again into this. Today and tomorrow 
I'm busy with other things.

Oh, and BTW, today I found by chance another reason why auto-reassoc is 
helpful and necessary :-)   On a Cisco 1231 AP I played a bit with the 
command interface. And there was a command to check how busy all the 
channels are. When I issued this command, I saw in the log of the Cisco 
(I'm sending it to the console) and also in the syslog of the machine 
running the libertas driver that the Cisco IOS sent an disassociation 
to all clients. Then it went checking for busy channels and gave me 
some output. After this, two client (one libertas, one other) 
automatically re-associated and things continued as if nothing would 
have happened.

Now, in a Cisco AP you can specify the channel for the AP. And you can 
also say "Use least congested Frequency". This makes the AP does this 
channel scanning --- that I issued manually --- do automatically. With 
the current current code, my libertas driven card would have been 
stuck ...



As for WPA driven environments: you can operate WPA supplicant in two 
modes. In one modes does WPA does the work of selecting which AP to 
use. It also sends the equivalent of "iwconfig ethX ap 
xx:XX:XX:XX:XX:XX" to the card.

In the other mode (I think it is "ap_scan=2"), wpa_supplicant just 
reacts to a re-association that the driver did without further fuzz.

I guess that your issues are with the first mode?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] libertas: automatically re-associate
  2007-10-10 16:59           ` John W. Linville
@ 2007-10-11  4:00             ` Dan Williams
  0 siblings, 0 replies; 9+ messages in thread
From: Dan Williams @ 2007-10-11  4:00 UTC (permalink / raw)
  To: John W. Linville; +Cc: Holger Schurig, libertas-dev, linux-wireless

On Wed, 2007-10-10 at 12:59 -0400, John W. Linville wrote:
> On Wed, Oct 10, 2007 at 10:58:58AM -0400, Dan Williams wrote:
> 
> > I won't throw a hissy fit over the reassociation patch as long as it
> > only tries this in open & WEP situations where a supplicant is not
> > necessary.  That means you cannot simply requeue an association in
> > libertas_mac_event_disconnected(), but you should check the association
> > request and not requeue if:
> > 
> > 1) the assoc request's mode is ad-hoc (is there a point to retrying
> > assoc in adhoc?)
> 
> I'm not sure I see why ad-hoc is a special case?

A STA can't ever get disassociation management frames in an IBSS, right?
I don't believe the firmware will ever disconnect you once you've
started an IBSS, but there may be a difference between the start-adhoc
and join-adhoc commands that get sent to firmware.  However, it's not
like loss of becaons in IBSS mode will cause a disconnection, because it
just looks like the network split and you are the only member of it, and
then your STA takes up beaconing responsibility by itself until the
world ends.  AFAIK.

Dan



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-10-11  4:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-09 12:04 [PATCH] libertas: automatically re-associate Holger Schurig
2007-10-09 14:19 ` Dan Williams
2007-10-09 15:13   ` Holger Schurig
2007-10-09 15:37     ` Dan Williams
2007-10-10  7:43       ` Holger Schurig
2007-10-10 14:58         ` Dan Williams
2007-10-10 16:59           ` John W. Linville
2007-10-11  4:00             ` Dan Williams
2007-10-10 19:00           ` Holger Schurig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).