Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/mips/mips Fix for single-byte mbufs.



details:   https://anonhg.NetBSD.org/src/rev/93c9be66a54c
branches:  trunk
changeset: 513913:93c9be66a54c
user:      simonb <simonb%NetBSD.org@localhost>
date:      Fri Aug 17 07:21:07 2001 +0000

description:
Fix for single-byte mbufs.

diffstat:

 sys/arch/mips/mips/in_cksum.c |  12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diffs (38 lines):

diff -r 5d5e6ca787e0 -r 93c9be66a54c sys/arch/mips/mips/in_cksum.c
--- a/sys/arch/mips/mips/in_cksum.c     Fri Aug 17 07:16:18 2001 +0000
+++ b/sys/arch/mips/mips/in_cksum.c     Fri Aug 17 07:21:07 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in_cksum.c,v 1.5 1999/04/24 08:10:39 simonb Exp $      */
+/*     $NetBSD: in_cksum.c,v 1.6 2001/08/17 07:21:07 simonb Exp $      */
 
 /*
  * Copyright (c) 1993 Regents of the University of California.
@@ -80,6 +80,10 @@
 
        /* Align to 32 bits. */
        if (buf.u & 0x3) {
+               /* Skip to the end for very small mbufs */
+               if (n < 3)
+                       goto verylittleleft;
+
                /*
                 * 16-bit-align.
                 * If buf is odd-byte-aligned, add the byte and toggle
@@ -206,13 +210,15 @@
                sum += *(buf.s++);
        }
 
-       /* handle trailing byte */
-       if (n > 0)
+ verylittleleft:
+       /* handle trailing byte and short (possibly) unaligned payloads */
+       while (n-- > 0) {
 #if BYTE_ORDER == BIG_ENDIAN
                sum += *buf.c << 8;
 #else
                sum += *buf.c;
 #endif
+       }
 
        /*
         * compensate for a trailing byte in previous mbuf



Home | Main Index | Thread Index | Old Index