From dagu@methyltheobro.mine.nu  Thu Mar 21 09:37:41 2002
Return-Path: <dagu@methyltheobro.mine.nu>
Received: from mailout11.sul.t-online.com (mailout11.sul.t-online.com [194.25.134.85])
	by hub.freebsd.org (Postfix) with ESMTP id D65BF37B400
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 21 Mar 2002 09:37:40 -0800 (PST)
Received: from fwd09.sul.t-online.de 
	by mailout11.sul.t-online.com with smtp 
	id 16o6VP-0007BR-0C; Thu, 21 Mar 2002 18:37:39 +0100
Received: from idefix.methyltheobro.mine.nu (520081541377-0001@[217.235.54.207]) by fmrl09.sul.t-online.com
	with esmtp id 16o6VN-1GkJLkC; Thu, 21 Mar 2002 18:37:37 +0100
Received: by idefix.methyltheobro.mine.nu (Postfix, from userid 1000)
	id 78330F01C; Thu, 21 Mar 2002 18:37:36 +0100 (CET)
Message-Id: <20020321183736.A22647@idefix.methyltheobro.mine.nu>
Date: Thu, 21 Mar 2002 18:37:36 +0100
From: David Gullasch <xonox@web.de>
To: FreeBSD-gnats-submit@freebsd.org
Subject: an(4) does an_init() even if interface is down
X-Send-Pr-Version: 3.113

>Number:         36170
>Category:       kern
>Synopsis:       [an] [patch] an(4) does an_init() even if interface is down
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Mar 21 09:40:01 PST 2002
>Closed-Date:    
>Last-Modified:  Sun Oct 23 21:08:44 GMT 2005
>Originator:     David Gullasch <xonox@web.de>
>Release:        FreeBSD 4.5-STABLE i386
>Organization:
-
>Environment:
System: FreeBSD illuminatix.methyltheobro.mine.nu 4.5-STABLE FreeBSD 4.5-STABLE #12: Thu Mar 21 00:09:08 CET 2002 root@illuminatix.methyltheobro.mine.nu:/usr/obj/usr/src/sys/ILLUMINATIX i386

Hardware: Toshiba Satellite 3000-400 and Cisco Aironet AIR-PCM350

>Description:
	I am currently writing a wireless network auditing tool
	where i need to reconfigure my Aironet NIC while keeping
	it silent. This is not possible with the current an(4)
	because it will switch the NIC on via an_init() everytime
	when one does a SIOCSAIRONET.

>How-To-Repeat:

	,----
	| # ifconfig an0 down
	| # ifconfig an0
	| an0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
	| 	ether 00:12:34:56:78:90 
	| 	media: IEEE 802.11 Wireless Ethernet autoselect (DS/11Mbps)
	| 	status: no carrier
	| 	ssid ""
	| 	stationname ""
	| 	channel 7 authmode OPEN powersavemode OFF powersavesleep 200
	| 	wepmode OFF weptxkey 1
	| 	wepkey 5:128-bit
	| # ancontrol -m 00:09:87:65:43:21 
	| # ifconfig an0
	| an0: flags=8842<BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	| 	ether 00:09:87:65:43:21 
	| 	media: IEEE 802.11 Wireless Ethernet autoselect (DS/11Mbps)
	| 	status: no carrier
	| 	ssid ""
	| 	stationname ""
	| 	channel 7 authmode OPEN powersavemode OFF powersavesleep 200
	| 	wepmode OFF weptxkey 1
	| 	wepkey 5:128-bit
	`----

	btw: it does not really make sense to have IFF_RUNNING=1
	and IFF_UP=0 here because the SIOCSIFFLAGS semantics are
	that the driver shuts the interface down (IFF_RUNNING=0)
	when the user requests IFF_UP=0 and starts the interface
	(IFF_RUNNING=1) when the user requests IFF_UP=1.

>Fix:

Index: if_an.c
===================================================================
RCS file: /usr/cvs/src/sys/dev/an/if_an.c,v
retrieving revision 1.2.2.11
diff -u -r1.2.2.11 if_an.c
--- if_an.c	18 Mar 2002 14:56:35 -0000	1.2.2.11
+++ if_an.c	21 Mar 2002 16:56:00 -0000
@@ -1212,7 +1212,7 @@
 
 
 	/* Reinitialize the card. */
-	if (ifp->if_flags)
+	if (ifp->if_flags & IFF_RUNNING)
 		an_init(sc);
 
 	return;

>Release-Note:
>Audit-Trail:
>Unformatted:
