From vk@hvv.svzserv.kemerovo.su  Sat Mar 10 04:31:18 2001
Return-Path: <vk@hvv.svzserv.kemerovo.su>
Received: from hvv.svzserv.kemerovo.su (hvv.svzserv.kemerovo.su [213.184.65.67])
	by hub.freebsd.org (Postfix) with ESMTP id C485637B718
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 10 Mar 2001 04:31:16 -0800 (PST)
	(envelope-from vk@hvv.svzserv.kemerovo.su)
Received: (from vk@localhost)
	by hvv.svzserv.kemerovo.su (8.9.3/8.9.3) id TAA13727;
	Sat, 10 Mar 2001 19:31:22 +0700 (NKZ)
	(envelope-from vk)
Message-Id: <200103101231.TAA13727@hvv.svzserv.kemerovo.su>
Date: Sat, 10 Mar 2001 19:31:22 +0700 (NKZ)
From: Vladimir Kurtukov <vk@hvv.svzserv.kemerovo.su>
Reply-To: vk@hvv.svzserv.kemerovo.su
To: FreeBSD-gnats-submit@freebsd.org
Subject: le nic driver causes kernel panic
X-Send-Pr-Version: 3.2

>Number:         25650
>Category:       kern
>Synopsis:       le nic driver causes kernel panic
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Mar 10 04:40:02 PST 2001
>Closed-Date:    Fri Nov 2 10:19:30 PST 2001
>Last-Modified:  Mon Mar 25 07:30:01 PST 2002
>Originator:     Vladimir Kurtukov <vk@hvv.svzserv.kemerovo.su>
>Release:        FreeBSD 4.2-STABLE i386
>Organization:
JSC SvzServ
>Environment:

	FreeBSD p200.trust.kemerovo.su 4.2-STABLE FreeBSD 
	4.2-STABLE #11: Sat Mar 10 18:25:29 KRAT 2001     
	root@p200.trust.kemerovo.su:/usr/src/sys/compile/TRUST  i386

        This bug is in all 4.x versions

>Description:
	
 	le nic driver is broken: driver interface was changed but
	driver was incorrectly updated to new interface.

	Generic ether_ioctl from if_ethersubr.c make nic initialization
	in a way like this:

		ifp->if_init(ifp->if_softc);

	But lemac_init or lance_init functions from if_le.c have 
	another syntax, they need unit number as an argument. Correct 
	way for le driver is:

		(*sc->if_init)(ifp->if_unit);

>How-To-Repeat:

	Compile in le driver into kernel and try to assign an
	IP address for it - result will be immediate kernel panic
	
>Fix:

	Here is my patch (code taken from 3.5-STABLE):

	--- if_le.std	Tue Jul 18 05:24:30 2000
	+++ if_le.new	Sat Mar 10 17:05:01 2001
	@@ -441,7 +441,66 @@
	     s = splimp();
	 
	     switch (cmd) {
	-        case SIOCSIFADDR:
	+    	case SIOCSIFADDR: {
	+	    struct ifaddr *ifa = (struct ifaddr *)data;
	+
	+	    ifp->if_flags |= IFF_UP;
	+	    switch(ifa->ifa_addr->sa_family) {
	+#ifdef INET
	+		case AF_INET: {
	+		    (*sc->if_init)(ifp->if_unit);
	+		    arp_ifinit((struct arpcom *)ifp, ifa);
	+		    break;
	+		}
	+#endif /* INET */
	+#ifdef IPX
	+		/* This magic copied from if_is.c; I don't use XNS,
	+		 * so I have no way of telling if this actually
	+		 * works or not.
	+		 */
	+		case AF_IPX: {
	+		    struct ipx_addr *ina = &(IA_SIPX(ifa)->sipx_addr);
	+		    if (ipx_nullhost(*ina)) {
	+			ina->x_host = *(union ipx_host *)(sc->le_ac.ac_enaddr);
	+		    } else {
	+			ifp->if_flags &= ~IFF_RUNNING;
	+			bcopy((caddr_t)ina->x_host.c_host,
	+			      (caddr_t)sc->le_ac.ac_enaddr,
	+			      sizeof sc->le_ac.ac_enaddr);
	+		    }
	+
	+		    (*sc->if_init)(ifp->if_unit);
	+		    break;
	+		}
	+#endif /* IPX */
	+#ifdef NS
	+		/* This magic copied from if_is.c; I don't use XNS,
	+		 * so I have no way of telling if this actually
	+		 * works or not.
	+		 */
	+		case AF_NS: {
	+		    struct ns_addr *ina = &(IA_SNS(ifa)->sns_addr);
	+		    if (ns_nullhost(*ina)) {
	+			ina->x_host = *(union ns_host *)(sc->le_ac.ac_enaddr);
	+		    } else {
	+			ifp->if_flags &= ~IFF_RUNNING;
	+			bcopy((caddr_t)ina->x_host.c_host,
	+			      (caddr_t)sc->le_ac.ac_enaddr,
	+			      sizeof sc->le_ac.ac_enaddr);
	+		    }
	+
	+		    (*sc->if_init)(ifp->if_unit);
	+		    break;
	+		}
	+#endif /* NS */
	+		default: {
	+		    (*sc->if_init)(ifp->if_unit);
	+		    break;
	+		}
	+	    }
	+	    break;
	+	}
	+
         case SIOCGIFADDR:
         case SIOCSIFMTU:
                 error = ether_ioctl(ifp, cmd, data);


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: jlemon 
State-Changed-When: Fri Nov 2 10:19:30 PST 2001 
State-Changed-Why:  
Fixed. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=25650 

From: Andrew Heybey <ath@niksun.com>
To: freebsd-gnats-submit@FreeBSD.org, vk@hvv.svzserv.kemerovo.su
Cc:  
Subject: Re: kern/25650: le nic driver causes kernel panic
Date: Mon, 25 Mar 2002 10:21:31 -0500

 Not actually fixed.  ifconfig'ing an address on an le NIC card still
 causes a panic in 4.5.
 
 See the patch I submitted in a followup to a related older PR, PR18641.
 The patch fixes the problem for me in 4.5.
 
 http://www.freebsd.org/cgi/query-pr.cgi?pr=18641 
 
 andrew
>Unformatted:
