cvs commit: src/sys/i386/include in_cksum.h
David E. O'Brien
obrien at FreeBSD.org
Wed Aug 25 11:28:15 PDT 2004
obrien 2004-08-25 18:28:15 UTC
FreeBSD src repository
Fix a bug in in_cksum_hdr w/o -O.
The C code assumes that the carry bit is always kept from the previous
operation. However, the pointer indexing requires another add operation.
Thus, the carry bit from the first operation is tromped over by the
"addl" operation that ends up following it, so the "adcl" that follows
that has no effect because the carry bit is cleared before it.
The result is checksum failure on received packets.
The larger issue is that there isn't any other way of preventing the compiler
inserting arbitrary instructions between different __asm statements (and
that the commit message in revision 1.13 of in_cksum.h is wrong on
this point). From
You can't expect a sequence of volatile asm instructions to remain
perfectly consecutive. If you want consecutive output, use a single
asm. Also, GCC will perform some optimizations across a volatile
asm instruction; GCC does not "forget everything" when it encounters
a volatile asm instruction the way some other compilers do.
Also, this change also makes the ASM code much easier to read.
Submitted by: Mike Bristow <mike at urgle.com>, Qing Li <qing.li at bluecoat.com>
Revision Changes Path
1.16 +14 -16 src/sys/i386/include/in_cksum.h
More information about the cvs-src