From owner-cvs-src@FreeBSD.ORG Wed Aug 25 18:28:15 2004 Return-Path: Delivered-To: cvs-src@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9227F16A4CE; Wed, 25 Aug 2004 18:28:15 +0000 (GMT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8363743D82; Wed, 25 Aug 2004 18:28:15 +0000 (GMT) (envelope-from obrien@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.11/8.12.11) with ESMTP id i7PISFD6078797; Wed, 25 Aug 2004 18:28:15 GMT (envelope-from obrien@repoman.freebsd.org) Received: (from obrien@localhost) by repoman.freebsd.org (8.12.11/8.12.11/Submit) id i7PISFtH078796; Wed, 25 Aug 2004 18:28:15 GMT (envelope-from obrien) Message-Id: <200408251828.i7PISFtH078796@repoman.freebsd.org> From: "David E. O'Brien" Date: Wed, 25 Aug 2004 18:28:15 +0000 (UTC) To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org X-FreeBSD-CVS-Branch: HEAD Subject: cvs commit: src/sys/i386/include in_cksum.h X-BeenThere: cvs-src@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Aug 2004 18:28:15 -0000 obrien 2004-08-25 18:28:15 UTC FreeBSD src repository Modified files: sys/i386/include in_cksum.h Log: 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 http://developer.apple.com/documentation/DeveloperTools/gcc-3.3/gcc/Extended-Asm.html ---8<---8<---8<--- 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. ---8<---8<---8<--- Also, this change also makes the ASM code much easier to read. PR: 69257 Submitted by: Mike Bristow , Qing Li Revision Changes Path 1.16 +14 -16 src/sys/i386/include/in_cksum.h