Subject: if_le.c patch...
To: None <port-sun3@NetBSD.ORG>
From: Jason Thorpe <thorpej@SJ.Xenotropic.COM>
List: port-sun3
Date: 05/09/1995 00:43:53
I'm not entirely certain that the sun 3/60 I have has the Rev C bug, but 
I do know that the work-around in the tree kept ypbind from working.  So, 
I whipped this up in an attempt to make ypbind work and detect the bug.  
ypbind works, but I can't speak for the bug...

In any case...it's below.

Ciao.

------------------------------------------------------------------------------
Jason R. Thorpe                                         thorpej@Xenotropic.COM

-----cut here-----
*** if_le.c	1995/05/05 06:03:17	1.1.1.1
--- if_le.c	1995/05/09 07:38:11
***************
*** 665,701 ****
  	if (len <= 0)
  		return;
  
  #ifdef	LANCE_REVC_BUG
  	/*
  	 * Check for unreported packet errors.  Rev C of the LANCE chip
  	 * has a bug which can cause "random" bytes to be prepended to
  	 * the start of the packet.  The work-around is to make sure that
  	 * the Ethernet destination address in the packet matches our
! 	 * address (or the broadcast address).  XXX - Multicasts?
  	 */
! 	{
! 		register short *pp, *ea;
! 		pp = (short *) buf;
! 		ea = (short *) &sc->sc_enaddr;
! 		if (((pp[0] != ea[0]) || (pp[1] != ea[1]) || (pp[2] != ea[2])) &&
! 			((pp[0] != -1)    || (pp[1] != -1)    || (pp[2] != -1)   ))
! 		{
! 			sc->sc_if.if_ierrors++;
! 			printf("%s: LANCE Rev C Extra Byte(s) bug; Packet punted\n",
! 				   sc->sc_dev.dv_xname);
! 			return;
! 		}
! 	}
! #endif	/* LANCE_REVC_BUG */
! 
! 	/* Pull packet off interface. */
! 	ifp = &sc->sc_if;
! 	m = leget(buf, len, ifp);
! 	if (m == 0)
  		return;
  
! 	/* We assume that the header fit entirely in one mbuf. */
! 	eh = mtod(m, struct ether_header *);
  
  #if NBPFILTER > 0
  	/*
--- 665,698 ----
  	if (len <= 0)
  		return;
  
+ 	/* Pull packet off interface. */
+ 	ifp = &sc->sc_if;
+ 	m = leget(buf, len, ifp);
+ 	if (m == 0)
+ 		return;
+ 
+ 	/* We assume that the header fit entirely in one mbuf. */
+ 	eh = mtod(m, struct ether_header *);
+ 
  #ifdef	LANCE_REVC_BUG
  	/*
  	 * Check for unreported packet errors.  Rev C of the LANCE chip
  	 * has a bug which can cause "random" bytes to be prepended to
  	 * the start of the packet.  The work-around is to make sure that
  	 * the Ethernet destination address in the packet matches our
! 	 * address or could be a broadcast or multicast.
  	 */
! 	if ((eh->ether_dhost[0] & 1) == 0 && /* !mcast and !bcast */
! 	    bcmp(eh->ether_dhost, sc->sc_enaddr,
! 		    sizeof(eh->ether_dhost) / 2) != 0) {
! 		sc->sc_if.if_ierrors++;
! 		printf("%s: LANCE Rev C Extra Byte(s) bug; Packet punted\n",
! 		    sc->sc_dev.dv_xname);
! 		m_freem(m);
  		return;
+ 	}
  
! #endif	/* LANCE_REVC_BUG */
  
  #if NBPFILTER > 0
  	/*