[PATCH] Runt frames dropped under RX checksum in hamachi.c

Pete Wyckoff wyckoff@ca.sandia.gov
Fri Mar 10 17:49:51 2000


Tony Caola brought to my attention the fact that my receive checksum
enabling changes to the hamachi driver cause some packets to be dropped
due to invalid checksum.  The problem was that I failed to notice that
runt frames (< 64 bytes or so) are padded according to the ethernet spec
up to the minimum, even on fancy full-duplex hardware like we've got.

Since there hasn't been a patch to Eric's version of Becker's driver
for almost exactly a year, it seems due time for a version upgrade.  I
submit a patch below.

Sorry for not replying properly.  I seem to have been removed from the
list and did not notice.

		-- Pete



--- hamachi-old.c	Thu Mar 11 06:50:04 1999
+++ hamachi.c	Fri Mar 10 14:38:56 2000
@@ -1394,9 +1394,14 @@
 			/* TCP or UDP on ipv4, DIX encoding */
 			if (pfck>>24 == 0x91 || pfck>>24 == 0x51) {
 			    struct iphdr *ih = (struct iphdr *) skb->data;
-			    /* don't worry about frags */
+			    /* Don't worry about frags, and packets smaller
+			     * than 46 bytes of IP will be padded to avoid
+			     * runt frames, so punt if it's padded else
+			     * checksum includes bogus pad bytes.
+			     */
 			    if (!(ih->frag_off
-			      & __constant_htons(IP_MF|IP_OFFSET))) {
+			      & __constant_htons(IP_MF|IP_OFFSET))
+			      && ntohs(ih->tot_len) == pkt_len-14) {
 				u32 inv = *(u32 *) &buf_addr[data_size - 16];
 				u32 *p = (u32 *) &buf_addr[data_size - 20];
 				u32 crc;


 | To unsubscribe, send mail to Majordomo@cesdis.gsfc.nasa.gov, and within the
 |  body of the mail, include only the text:
 |   unsubscribe this-list-name youraddress@wherever.org
 | You will be unsubscribed as speedily as possible.