netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] softmac: Fix handling of authentication failure
@ 2006-06-01 14:37 Daniel Drake
  2006-06-02  2:43 ` Larry Finger
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Drake @ 2006-06-01 14:37 UTC (permalink / raw)
  To: linville; +Cc: netdev, johannes

My router blew up earlier, but exhibited some interesting behaviour during
its dying moments. It was broadcasting beacons but wouldn't respond to
any authentication requests.

I noticed that softmac wasn't playing nice with this, as I couldn't make it try
to connect to other networks after it had timed out authenticating to my ill
router.

To resolve this, I modified the softmac event/notify API to pass the event
code to the callback, so that callbacks being notified from
IEEE80211SOFTMAC_EVENT_ANY masks can make some judgement. In this case, the
ieee80211softmac_assoc callback needs to make a decision based upon whether
the association passed or failed.

Signed-off-by: Daniel Drake <dsd@gentoo.org>
Acked-by: Johannes Berg <johannes@sipsolutions.net>

---

This may be worth considering for 2.6.17. The current code does not check the
response to an authentication request before associating, it just assumes it 
was successful. This patch adds validation on that.

Index: linux/include/net/ieee80211softmac.h
===================================================================
--- linux.orig/include/net/ieee80211softmac.h
+++ linux/include/net/ieee80211softmac.h
@@ -359,7 +359,7 @@ extern void ieee80211softmac_stop(struct
  *	- context set to the context data you want passed
  * The return value is 0, or an error.
  */
-typedef void (*notify_function_ptr)(struct net_device *dev, void *context);
+typedef void (*notify_function_ptr)(struct net_device *dev, int event_type, void *context);
 
 #define ieee80211softmac_notify(dev, event, fun, context) ieee80211softmac_notify_gfp(dev, event, fun, context, GFP_KERNEL);
 #define ieee80211softmac_notify_atomic(dev, event, fun, context) ieee80211softmac_notify_gfp(dev, event, fun, context, GFP_ATOMIC);
Index: linux/net/ieee80211/softmac/ieee80211softmac_assoc.c
===================================================================
--- linux.orig/net/ieee80211/softmac/ieee80211softmac_assoc.c
+++ linux/net/ieee80211/softmac/ieee80211softmac_assoc.c
@@ -164,12 +164,28 @@ network_matches_request(struct ieee80211
 }
 
 static void
-ieee80211softmac_assoc_notify(struct net_device *dev, void *context)
+ieee80211softmac_assoc_notify_scan(struct net_device *dev, int event_type, void *context)
 {
 	struct ieee80211softmac_device *mac = ieee80211_priv(dev);
 	ieee80211softmac_assoc_work((void*)mac);
 }
 
+static void
+ieee80211softmac_assoc_notify_auth(struct net_device *dev, int event_type, void *context)
+{
+	struct ieee80211softmac_device *mac = ieee80211_priv(dev);
+
+	switch (event_type) {
+	case IEEE80211SOFTMAC_EVENT_AUTHENTICATED:
+		ieee80211softmac_assoc_work((void*)mac);
+		break;
+	case IEEE80211SOFTMAC_EVENT_AUTH_FAILED:
+	case IEEE80211SOFTMAC_EVENT_AUTH_TIMEOUT:
+		ieee80211softmac_disassoc(mac);
+		break;
+	}
+}
+
 /* This function is called to handle userspace requests (asynchronously) */
 void
 ieee80211softmac_assoc_work(void *d)
@@ -249,7 +265,7 @@ ieee80211softmac_assoc_work(void *d)
 			 * Maybe we can hope to have more memory after scanning finishes ;)
 			 */
 			dprintk(KERN_INFO PFX "Associate: Scanning for networks first.\n");
-			ieee80211softmac_notify(mac->dev, IEEE80211SOFTMAC_EVENT_SCAN_FINISHED, ieee80211softmac_assoc_notify, NULL);
+			ieee80211softmac_notify(mac->dev, IEEE80211SOFTMAC_EVENT_SCAN_FINISHED, ieee80211softmac_assoc_notify_scan, NULL);
 			if (ieee80211softmac_start_scan(mac))
 				dprintk(KERN_INFO PFX "Associate: failed to initiate scan. Is device up?\n");
 			return;
@@ -284,7 +300,7 @@ ieee80211softmac_assoc_work(void *d)
 		 * otherwise adding the notification would be racy. */
 		if (!ieee80211softmac_auth_req(mac, found)) {
 			dprintk(KERN_INFO PFX "cannot associate without being authenticated, requested authentication\n");
-			ieee80211softmac_notify_internal(mac, IEEE80211SOFTMAC_EVENT_ANY, found, ieee80211softmac_assoc_notify, NULL, GFP_KERNEL);
+			ieee80211softmac_notify_internal(mac, IEEE80211SOFTMAC_EVENT_ANY, found, ieee80211softmac_assoc_notify_auth, NULL, GFP_KERNEL);
 		} else {
 			printkl(KERN_WARNING PFX "Not authenticated, but requesting authentication failed. Giving up to associate\n");
 			ieee80211softmac_call_events(mac, IEEE80211SOFTMAC_EVENT_ASSOCIATE_FAILED, found);
Index: linux/net/ieee80211/softmac/ieee80211softmac_event.c
===================================================================
--- linux.orig/net/ieee80211/softmac/ieee80211softmac_event.c
+++ linux/net/ieee80211/softmac/ieee80211softmac_event.c
@@ -77,7 +77,7 @@ ieee80211softmac_notify_callback(void *d
 	struct ieee80211softmac_event event = *(struct ieee80211softmac_event*) d;
 	kfree(d);
 	
-	event.fun(event.mac->dev, event.context);
+	event.fun(event.mac->dev, event.event_type, event.context);
 }
 
 int
@@ -172,6 +172,9 @@ ieee80211softmac_call_events_locked(stru
 			if ((eventptr->event_type == event || eventptr->event_type == -1)
 				&& (eventptr->event_context == NULL || eventptr->event_context == event_ctx)) {
 				list_del(&eventptr->list);
+				/* User may have subscribed to ANY event, so
+				 * we tell them which event triggered it. */
+				eventptr->event_type = event;
 				schedule_work(&eventptr->work);
 			}
 		}

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

* Re: [PATCH] softmac: Fix handling of authentication failure
  2006-06-01 14:37 [PATCH] softmac: Fix handling of authentication failure Daniel Drake
@ 2006-06-02  2:43 ` Larry Finger
  2006-06-02 10:09   ` Daniel Drake
  0 siblings, 1 reply; 5+ messages in thread
From: Larry Finger @ 2006-06-02  2:43 UTC (permalink / raw)
  To: Daniel Drake; +Cc: linville, netdev, johannes

Daniel Drake wrote:
> My router blew up earlier, but exhibited some interesting behaviour during
> its dying moments. It was broadcasting beacons but wouldn't respond to
> any authentication requests.
>
> I noticed that softmac wasn't playing nice with this, as I couldn't make it try
> to connect to other networks after it had timed out authenticating to my ill
> router.
>
> To resolve this, I modified the softmac event/notify API to pass the event
> code to the callback, so that callbacks being notified from
> IEEE80211SOFTMAC_EVENT_ANY masks can make some judgement. In this case, the
> ieee80211softmac_assoc callback needs to make a decision based upon whether
> the association passed or failed.
>
> Signed-off-by: Daniel Drake <dsd@gentoo.org>
> Acked-by: Johannes Berg <johannes@sipsolutions.net>
--snip--

> Index: linux/net/ieee80211/softmac/ieee80211softmac_assoc.c
> ===================================================================
> --- linux.orig/net/ieee80211/softmac/ieee80211softmac_assoc.c
> +++ linux/net/ieee80211/softmac/ieee80211softmac_assoc.c
> @@ -164,12 +164,28 @@ network_matches_request(struct ieee80211
>  }
>  
>  static void
> -ieee80211softmac_assoc_notify(struct net_device *dev, void *context)
> +ieee80211softmac_assoc_notify_scan(struct net_device *dev, int event_type, void *context)
>  {
>  	struct ieee80211softmac_device *mac = ieee80211_priv(dev);
>  	ieee80211softmac_assoc_work((void*)mac);
>  }
>  
> +static void
> +ieee80211softmac_assoc_notify_auth(struct net_device *dev, int event_type, void *context)
> +{
> +	struct ieee80211softmac_device *mac = ieee80211_priv(dev);
> +
> +	switch (event_type) {
> +	case IEEE80211SOFTMAC_EVENT_AUTHENTICATED:
> +		ieee80211softmac_assoc_work((void*)mac);
> +		break;
> +	case IEEE80211SOFTMAC_EVENT_AUTH_FAILED:
> +	case IEEE80211SOFTMAC_EVENT_AUTH_TIMEOUT:
> +		ieee80211softmac_disassoc(mac);
>   
This statement fails to compile on my system using Linus' tree, because 
ieee80211softmac_disassoc needs a second argument - the reason. It seems 
as if WLAN_REASON_PREV_AUTH_NOT_VALID would be appropriate.

Larry


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

* Re: [PATCH] softmac: Fix handling of authentication failure
  2006-06-02  2:43 ` Larry Finger
@ 2006-06-02 10:09   ` Daniel Drake
  2006-06-02 12:04     ` John W. Linville
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Drake @ 2006-06-02 10:09 UTC (permalink / raw)
  To: Larry Finger; +Cc: linville, netdev, johannes

Larry Finger wrote:
> This statement fails to compile on my system using Linus' tree, because 
> ieee80211softmac_disassoc needs a second argument - the reason. It seems 
> as if WLAN_REASON_PREV_AUTH_NOT_VALID would be appropriate.

Thanks for pointing that out. This patch depends on a patch titled 
"softmac: deauthentication implies deassociation" which is apparently 
not present in Linus' tree.

Daniel

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

* Re: [PATCH] softmac: Fix handling of authentication failure
  2006-06-02 10:09   ` Daniel Drake
@ 2006-06-02 12:04     ` John W. Linville
  2006-06-02 14:55       ` Larry Finger
  0 siblings, 1 reply; 5+ messages in thread
From: John W. Linville @ 2006-06-02 12:04 UTC (permalink / raw)
  To: Daniel Drake; +Cc: Larry Finger, netdev, johannes

On Fri, Jun 02, 2006 at 11:09:56AM +0100, Daniel Drake wrote:
> Larry Finger wrote:
> >This statement fails to compile on my system using Linus' tree, because 
> >ieee80211softmac_disassoc needs a second argument - the reason. It seems 
> >as if WLAN_REASON_PREV_AUTH_NOT_VALID would be appropriate.
> 
> Thanks for pointing that out. This patch depends on a patch titled 
> "softmac: deauthentication implies deassociation" which is apparently 
> not present in Linus' tree.

That patch is in the upstream branch (also available in the master
branch) of wireless-2.6, which is probably what anyone doing wireless
patches should(*) be using.

The approved release process only allows for non-bugfix patches
in the first two weeks after a Linus blesses a new kernel release.
After that only bugfixes are allowed, with non-bugfix patches getting
queued for the next merge window.  The upstream branch represents
that queue of patches.

Hth!

John

(*) The exception being those workign on Devicescape-related patches,
who should be working off the master branch of wireless-dev.
-- 
John W. Linville
linville@tuxdriver.com

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

* Re: [PATCH] softmac: Fix handling of authentication failure
  2006-06-02 12:04     ` John W. Linville
@ 2006-06-02 14:55       ` Larry Finger
  0 siblings, 0 replies; 5+ messages in thread
From: Larry Finger @ 2006-06-02 14:55 UTC (permalink / raw)
  To: Daniel Drake, Larry Finger, netdev, johannes

John W. Linville wrote:
> On Fri, Jun 02, 2006 at 11:09:56AM +0100, Daniel Drake wrote:
>   
>> Larry Finger wrote:
>>     
>>> This statement fails to compile on my system using Linus' tree, because 
>>> ieee80211softmac_disassoc needs a second argument - the reason. It seems 
>>> as if WLAN_REASON_PREV_AUTH_NOT_VALID would be appropriate.
>>>       
>> Thanks for pointing that out. This patch depends on a patch titled 
>> "softmac: deauthentication implies deassociation" which is apparently 
>> not present in Linus' tree.
>>     
>
> That patch is in the upstream branch (also available in the master
> branch) of wireless-2.6, which is probably what anyone doing wireless
> patches should(*) be using.
>
> The approved release process only allows for non-bugfix patches
> in the first two weeks after a Linus blesses a new kernel release.
> After that only bugfixes are allowed, with non-bugfix patches getting
> queued for the next merge window.  The upstream branch represents
> that queue of patches.
>
> Hth!
>
> John
>
> (*) The exception being those workign on Devicescape-related patches,
> who should be working off the master branch of wireless-dev.
>   
Normally I use the master branch of wireless-2.6; however that code has 
something in it that kills interrupts from my bcm4306 card, but I 
haven't had time to chase down that problem. A second difficulty is that 
my Linksys WRT54G V1 died and the only replacement I could find on short 
notice was a V5 model, which is truly an abomination using VXWorks, not 
Linux. When the AP changed, my working system of bcm43xx-softmac with 
WPA authentication now refuses to authenticate, and I have to use a 
wired connection. Accordingly, I try every softmac patch that might 
solve my problem - thus I applied Daniels's patch to Linus's tree.

Larry



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

end of thread, other threads:[~2006-06-02 14:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-01 14:37 [PATCH] softmac: Fix handling of authentication failure Daniel Drake
2006-06-02  2:43 ` Larry Finger
2006-06-02 10:09   ` Daniel Drake
2006-06-02 12:04     ` John W. Linville
2006-06-02 14:55       ` Larry Finger

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).