From 6077b1d358b09e4fb02ac9d5a3bed4884f7afe86 Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Fri, 7 Nov 2003 00:32:55 -0800 Subject: [PATCH] Fix IP checksum for SuSE 9.0 compiler The hammer branch based gcc 3.3 in SuSE 9.0 has a more aggressive optimizer. ip_send_check has this code: iph->check = 0; iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl); The new gcc optimizes the first store away because it doesn't know that ip_fast_csum reads its input memory. This leads to occassionally packets with wrong IP header checksum getting sent; this happens especially with NFS. Fixing it in the constraints would have been ugly and probably not future proof, so this patch just adds a memory clobber to ip_fast_csum. For some reason the issue only hits in 2.6, we haven't seen it in 2.4. Problem occurs on both i386 and x86-64. Credit goes to Olaf Kirch for tracking this down. --- include/asm-i386/checksum.h | 3 ++- include/asm-x86_64/checksum.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/asm-i386/checksum.h b/include/asm-i386/checksum.h index 15d7909bfe3c..1afe056aa3cd 100644 --- a/include/asm-i386/checksum.h +++ b/include/asm-i386/checksum.h @@ -83,7 +83,8 @@ static inline unsigned short ip_fast_csum(unsigned char * iph, are modified, we must also specify them as outputs, or gcc will assume they contain their original values. */ : "=r" (sum), "=r" (iph), "=r" (ihl) - : "1" (iph), "2" (ihl)); + : "1" (iph), "2" (ihl) + : "memory"); return(sum); } diff --git a/include/asm-x86_64/checksum.h b/include/asm-x86_64/checksum.h index 35d3e37d9378..3718a8fbbc21 100644 --- a/include/asm-x86_64/checksum.h +++ b/include/asm-x86_64/checksum.h @@ -68,7 +68,8 @@ static inline unsigned short ip_fast_csum(unsigned char *iph, unsigned int ihl) are modified, we must also specify them as outputs, or gcc will assume they contain their original values. */ : "=r" (sum), "=r" (iph), "=r" (ihl) - : "1" (iph), "2" (ihl)); + : "1" (iph), "2" (ihl) + : "memory"); return(sum); } -- cgit v1.2.3