Subject: Re: port-mac68k/32583: mac68k netbsd-2 panics during rcp(1)
To: None <port-mac68k-maintainer@netbsd.org, gnats-admin@netbsd.org,>
From: Scott Reynolds <scottr@clank.org>
List: netbsd-bugs
Date: 01/26/2006 08:20:02
The following reply was made to PR port-mac68k/32583; it has been noted by GNATS.

From: Scott Reynolds <scottr@clank.org>
To: Hauke Fath <hauke@Espresso.Rhein-Neckar.DE>,
	gnats-bugs@netbsd.org
Cc: port-mac68k-maintainer@netbsd.org,
	Dave Huang <khym@azeotrope.org>
Subject: Re: port-mac68k/32583: mac68k netbsd-2 panics during rcp(1)
Date: Thu, 26 Jan 2006 01:18:00 -0600 (CST)

 I figured out what was bugging me; there's another bug in if_ae.c besides 
 the one Dave patched. Basically, the problem is coming in when we try to 
 pad out the frame to the minimum length. I originally thought the driver 
 was failing to pad the last byte whenever the shortfall was an odd number 
 of bytes. However, that's not the case. All we -really- need to do is 
 account for when wantbyte is set after the loop terminates and adjust the 
 pad count appropriately.
 
 The appended patch should do the trick. Please try it out and let me know 
 the result.
 
 Thanks in advance!
 
 --scott
 
 PS -- you might notice that I don't add 1 before shifting. I'm taking 
 advantage of the fact that (ETHER_MIN_LEN - ETHER_CRC_LEN - totlen - 
 wantbyte) must always be an even number.
 
 
 Index: if_ae.c
 ===================================================================
 RCS file: /cvsroot/src/sys/arch/mac68k/dev/if_ae.c,v
 retrieving revision 1.75
 diff -c -r1.75 if_ae.c
 *** if_ae.c	15 Jul 2003 02:43:16 -0000	1.75
 --- if_ae.c	26 Jan 2006 07:12:41 -0000
 ***************
 *** 172,186 ****
    		}
    	}
 
    	if (wantbyte) {
    		savebyte[1] = 0;
    		bus_space_write_region_2(sc->sc_buft, sc->sc_bufh,
    		    buf, (u_int16_t *)savebyte, 1);
 ! 		    buf += 2;
    	}
 ! 	if (totlen < ETHER_MIN_LEN - ETHER_CRC_LEN) {
    		bus_space_set_region_2(sc->sc_buft, sc->sc_bufh, buf, 0,
 ! 		    (ETHER_MIN_LEN - ETHER_CRC_LEN - totlen) >> 1);
    		totlen = ETHER_MIN_LEN - ETHER_CRC_LEN;
    	}
    	return (totlen);
 --- 172,188 ----
    		}
    	}
 
 + 	len = ETHER_MIN_LEN - ETHER_CRC_LEN - totlen;
    	if (wantbyte) {
    		savebyte[1] = 0;
    		bus_space_write_region_2(sc->sc_buft, sc->sc_bufh,
    		    buf, (u_int16_t *)savebyte, 1);
 ! 		buf += 2;
 ! 		len--;
    	}
 ! 	if (len > 0) {
    		bus_space_set_region_2(sc->sc_buft, sc->sc_bufh, buf, 0,
 ! 		    len >> 1);
    		totlen = ETHER_MIN_LEN - ETHER_CRC_LEN;
    	}
    	return (totlen);