Subject: kern/9548: fxp0 can get all 1's mac address
To: None <gnats-bugs@gnats.netbsd.org>
From: John Hawkinson <jhawk@mit.edu>
List: netbsd-bugs
Date: 03/05/2000 14:33:39
>Number:         9548
>Category:       kern
>Synopsis:       fxp0 can get all 1's mac address
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Mar  5 14:33:01 2000
>Last-Modified:
>Originator:     John Hawkinson
>Organization:
MIT
>Release:        NetBSD 1.4.1
>Environment:
	
System: NetBSD zorkmid.mit.edu 1.4.1 NetBSD 1.4.1 (ZORKMID) #9: Sun Mar 5 15:44:11 EST 2000 jhawk@zorkmid.mit.edu:/usr/src/sys/arch/i386/compile/ZORKMID i386


>Description:
	This problem ocurrs under 1.4.1, 1.4.2, as well as the 2/26/2000
	snapshots of -current.

	Booting NetBSD via a warm boot from Win98 on a Sony VAIO
	PCB-Z505HE with a built-in Intel 82555-based ethernet (fxp),
	NetBSD probes the ethernet's MAC address as ff:ff:ff:ff:ff:ff (the
	ethernet broadcast address). Needless to say, actually trying
	to use this MAC address would cause serious problems.

	In point of fact, though, actually attempting to use the card
	in this state causes the kernel to printf fxp0: WARNING: SCB timed
	out! And then the machine hangs.

>How-To-Repeat:

	Boot Win98, select Shutdown, Restart, and boot NetBSD.

>Fix:
	The kernel should check to see if the MAC address is sane before
	attaching it. I offer the following patch; presumably if this
	were against -current it would use if_detach(), but I don't
	have the resources to deal with -current right now.

===================================================================
RCS file: net/RCS/if_ethersubr.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -c -r1.1 -r1.2
*** net/if_ethersubr.c	2000/03/05 10:20:49	1.1
--- net/if_ethersubr.c	2000/03/05 22:14:02	1.2
***************
*** 679,684 ****
--- 679,685 ----
  	return (etherbuf);
  }
  
+ u_char ether_zeroaddr[6] = {0, 0, 0, 0, 0, 0};
  /*
   * Perform common duties while attaching to interface list
   */
***************
*** 689,694 ****
--- 690,710 ----
  {
  	struct sockaddr_dl *sdl;
  
+ 	/*
+ 	 * Some drivers, particularly with newer ethernet cards and
+ 	 * pcmcia cards, screw up occasionally and get
+ 	 * ff:ff:ff:ff:ff:ff as a MAC address; use of such a MAC
+ 	 * address (the ethernet bcast) can cause real trouble.  So do
+ 	 * a few checks to validate the addr.
+ 	 */
+ 	if (ETHER_IS_MULTICAST(lla) || !bcmp(lla, ether_zeroaddr,
+ 	    sizeof(ether_zeroaddr))) {
+ 	      printf("%s: ether_ifattach() detected illegal MAC %s;"
+ 	          " removing interface.\n", ifp->if_xname, ether_sprintf(lla));
+ 	  TAILQ_REMOVE(&ifnet, ifp, if_list);
+ 	  return;
+ 	}
+ 	    
  	ifp->if_type = IFT_ETHER;
  	ifp->if_addrlen = 6;
  	ifp->if_hdrlen = 14;


Despite this patch, the fxp driver still needs to be fixed to get
this to work. I'm not sure how to go about doing it. mycroft and
I spent some time last night futzing around with it and didn't
reach any conclusion. But I suppose we're available to work on it
at some point in the future, when I finish settling in with my
new laptop.
>Audit-Trail:
>Unformatted: