Subject: kern/14993: trying to change the media of a running tl interface causes a panic
To: None <gnats-bugs@gnats.netbsd.org>
From: None <dive@endersgame.net>
List: netbsd-bugs
Date: 12/18/2001 16:26:36
>Number:         14993
>Category:       kern
>Synopsis:       changing (with ifconfig) the media/mediaopt of a tl interface while the interface is running causes a panic
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Dec 18 08:27:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     dive-o
>Release:        NetBSD 1.5Z, current from 20011217
>Organization:
/~\ The ASCII                       Sean Davis
\ / Ribbon Campaign                 aka dive-o
 X  Against HTML
/ \ Email!                      dive@endersgame.net
>Environment:
nic:
tl0 at pci2 dev 0 function 0
tl0: Compaq Dual Port Netelligent 10/100 TX
tl0: Ethernet address 00:08:c7:a4:a9:40
tl0: interrupting at irq 9
tlphy0 at tl0 phy 31: ThunderLAN 10BASE-T media interface, rev. 5
tlphy0: 10base5
tl1 at pci2 dev 1 function 0
tl1: Compaq Dual Port Netelligent 10/100 TX
tl1: Ethernet address 00:08:c7:a4:a9:c0
tl1: interrupting at irq 7
tlphy1 at tl1 phy 31: ThunderLAN 10BASE-T media interface, rev. 5
tlphy1: 10base5

System: NetBSD eros.endersgame.net 1.5Z NetBSD 1.5Z (EROS) #213: Tue Dec 18 10:48:06 EST 2001 dive@eros.endersgame.net:/cvs/nblocal/sys/arch/i386/compile/EROS i386
Architecture: i386
Machine: i386
>Description:
	if you have a running tl interface, and try to change the media from
10 to 100, or mediaopt from full to half duplex (or both), it causes a
kernel panic. see how-to-repeat.
>How-To-Repeat:
	This is how I verified it multiple times on my system:
	(note: tl0 is connected to a 100mbit switch, tl1 to a cable modem)
	with both interfaces configured as they are normally (tl0 at
	100baseTX full-duplex, and tl1 at 10baseT), I ran:
	ifconfig tl0 media 10baseT
	*panic*
	it would happen if i tried to change the duplex mode, and on tl1 if
	i tried to change to 100 meg while its running.

	After over a day of debugging and reading through kernel source,
	I've created a patch that fixes the problem. You can now change the
	media/mediaopts while the interface is up.
>Fix:
--- sys.orig/dev/pci/if_tl.c	Tue Nov 13 02:48:45 2001
+++ sys/dev/pci/if_tl.c	Tue Dec 18 10:57:40 2001
@@ -1406,9 +1406,15 @@
 tl_mediachange(ifp)
 	struct ifnet *ifp;
 {
-
-	if (ifp->if_flags & IFF_UP)
-		tl_init(ifp->if_softc);
+	tl_softc_t *sc = ifp->if_softc;
+	/*
+	 * this should never be called with a null pointer arg
+	 */
+	if (ifp == NULL) {
+		printf("tl_mediachange: (struct ifnet *)ifp == NULL! (not changing media)\n");
+		return(0);
+	}
+	mii_mediachg(&sc->tl_mii);
 	return (0);
 }
 
>Release-Note:
>Audit-Trail:
>Unformatted:
 note: this only started happening a few days ago that i noticed, so maybe it
 was some recent change?