Skip to contentSkip to conversation

checksum.h header fixes for 2.4

PATCH In review Eric Weigle 3 participants 4 messages Jan 9, 2003 – Jan 10, 2003

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 checksum.h header fixes for 2.4

All-

I'm making a loadable module that will send IP packets; and need to do IP checksums. Unfortunately a simple #include of checksum.h fails because that file does not itself include the headers required to compile correctly. Several of the arch-specific files are this way.

* Some files use VERIFY_READ, VERIFY_WRITE, access_ok from uaccess.h but do not include uaccess.h

* Some files have an IPv6 checksum with struct in6_addr, but do not include linux/in6.h. x86_64 just defines the structure instead of including the file. Either way works, but it's inconsistent. I've moved them all to the #include, but they could all go to the struct in6_addr way too.

These need both linux/in6.h, and uaccess.h

    File name             VERIFY_  in6_addr |  headers
    asm-i386/checksum.h      Y        Y     |    -
    asm-sh/checksum.h        Y        Y     |  config

These need just linux/in6.h

    File name             VERIFY_  in6_addr |  headers
    asm-mips/checksum.h      N        Y     |  uaccess
    asm-mips64/checksum.h    N        Y     |  uaccess
    asm-alpha/checksum.h     N        Y     |    - 
    asm-arm/checksum.h       N        Y     |    - 
    asm-m68k/checksum.h      N        Y     |    - 
    asm-parisc/checksum.h    N        Y     |    - 
    asm-x86_64/checksum.h    N        Y     |  uaccess/compiler/byteorder

The remainder are fine:

    File name             VERIFY_  in6_addr |  headers
    asm-sparc/checksum.h     Y        Y     |  uaccess/in6/cprefix
    asm-sparc64/checksum.h   N        Y     |  uaccess/in6
    asm-s390/checksum.h      N        N     |  uaccess
    asm-s390x/checksum.h     N        N     |  uaccess
    asm-cris/checksum.h      N        N     |    -
    asm-ia64/checksum.h      N        N     |    -
    asm-ppc/checksum.h       N        N     |    -
    asm-ppc64/checksum.h     N        N     |    -

--------------------------------------------------------------------------------

include/asm-i386/checksum.h renamed from include/asm-i386/checksum.h.bak +2 -0
@@ -1,6 +1,8 @@
 #ifndef _I386_CHECKSUM_H
 #define _I386_CHECKSUM_H
 
+#include <linux/in6.h>
+#include <asm/uaccess.h>
 
 /*
  * computes the checksum of a memory block at buff, length len,
include/asm-sh/checksum.h renamed from include/asm-sh/checksum.h.bak +3 -0
@@ -1,6 +1,9 @@
 #ifndef __ASM_SH_CHECKSUM_H
 #define __ASM_SH_CHECKSUM_H
 
+#include <linux/in6.h>
+#include <asm/uaccess.h>
+
 /*
  * This file is subject to the terms and conditions of the GNU General Public
  * License.  See the file "COPYING" in the main directory of this archive
include/asm-mips/checksum.h renamed from include/asm-mips/checksum.h.bak +1 -0
@@ -8,6 +8,7 @@
 #ifndef _ASM_CHECKSUM_H
 #define _ASM_CHECKSUM_H
 
+#include <linux/in6.h>
 #include <asm/uaccess.h>
 
 /*
include/asm-mips64/checksum.h renamed from include/asm-mips64/checksum.h.bak +1 -0
@@ -11,6 +11,7 @@
 #ifndef _ASM_CHECKSUM_H
 #define _ASM_CHECKSUM_H
 
+#include <linux/in6.h>
 #include <asm/uaccess.h>
 
 /*
include/asm-alpha/checksum.h renamed from include/asm-alpha/checksum.h.bak +1 -0
@@ -1,6 +1,7 @@
 #ifndef _ALPHA_CHECKSUM_H
 #define _ALPHA_CHECKSUM_H
 
+#include <linux/in6.h>
 
 /*
  *	This is a version of ip_compute_csum() optimized for IP headers,
include/asm-arm/checksum.h renamed from include/asm-arm/checksum.h.bak +2 -0
@@ -9,6 +9,8 @@
 #ifndef __ASM_ARM_CHECKSUM_H
 #define __ASM_ARM_CHECKSUM_H
 
+#include <linux/in6.h>
+
 /*
  * computes the checksum of a memory block at buff, length len,
  * and adds in "sum" (32-bit)
include/asm-m68k/checksum.h renamed from include/asm-m68k/checksum.h.bak +2 -0
@@ -1,6 +1,8 @@
 #ifndef _M68K_CHECKSUM_H
 #define _M68K_CHECKSUM_H
 
+#include <linux/in6.h>
+
 /*
  * computes the checksum of a memory block at buff, length len,
  * and adds in "sum" (32-bit)
include/asm-parisc/checksum.h renamed from include/asm-parisc/checksum.h.bak +2 -0
@@ -1,6 +1,8 @@
 #ifndef _PARISC_CHECKSUM_H
 #define _PARISC_CHECKSUM_H
 
+#include <linux/in6.h>
+
 /*
  * computes the checksum of a memory block at buff, length len,
  * and adds in "sum" (32-bit)
linux/include/asm-x86_64/checksum.h 2003-01-09 12:59:58.000000000 -0700 renamed from linux/include/asm-x86_64/checksum.h.bak 2003-01-09 12:50:34.000000000 -0700 +2 -3
@@ -1,6 +1,8 @@
 #ifndef _X86_64_CHECKSUM_H
 #define _X86_64_CHECKSUM_H
 
+#include <linux/in6.h>
+
 /* 
  * Checksums for x86-64 
  * Copyright 2002 by Andi Kleen, SuSE Labs 
@@ -171,9 +173,6 @@
  * into UDP/TCP packets and contains some link layer information.
  * Returns the unfolded 32bit checksum.
  */
-
-struct in6_addr;
-
 #define _HAVE_ARCH_IPV6_CSUM 1
 extern unsigned short 
 csum_ipv6_magic(struct in6_addr *saddr, struct in6_addr *daddr,

--------------------------------------------------------------------------------

Marcelo, please apply.

-Eric

Signature · 5 lines
------------------------------------------------------------
        Eric H. Weigle -- http://public.lanl.gov/ehw/
"They that can give up essential liberty to obtain a little
temporary safety deserve neither" -- Benjamin Franklin
------------------------------------------------------------
#1 lore raw
Quoted 4 lines · Eric Weigle

I'm making a loadable module that will send IP packets; and need to do IP checksums. Unfortunately a simple #include of checksum.h fails because that file does not itself include the headers required to compile correctly. Several of the arch-specific files are this way.

Include the other files you need first. The kernel headers are not really intended to always include everything you might want. That rapidly becomes unmanagable

#2 lore raw
Quoted 11 lines · Eric Weigle
Quoted 7 lines

I'm making a loadable module that will send IP packets; and need to do IP
checksums. Unfortunately a simple #include of checksum.h fails because that
file does not itself include the headers required to compile correctly.
Several of the arch-specific files are this way.

Include the other files you need first. The kernel headers are not really intended to always include everything you might want. That rapidly becomes unmanagable

These files include the ipv6 and VERIFY_* stuff unconditionally. _EVERY_ caller must know to include the in6.h/uaccess.h header files simply to get it to compile. This is what the net/checksum.h file does. There are 31 files including <asm/checksum.h> directly, and all of these _must_ track down the dependencies by hand.

This isn't a _want_, it's an unconditional requirement. The files are broken.

<flamebait>
Of course, it's really C's bug, by doing brain-dead textual inclusion. Trust me, I know the difficulties in managing #includes. </flamebait>

-Eric

Signature · 5 lines
------------------------------------------------------------
        Eric H. Weigle -- http://public.lanl.gov/ehw/
"They that can give up essential liberty to obtain a little
temporary safety deserve neither" -- Benjamin Franklin
------------------------------------------------------------
#3 lore raw
In reply to Eric Weigle

In message <[email protected]> you write:

Quoted 7 lines

All-

I'm making a loadable module that will send IP packets; and need to do IP checksums. Unfortunately a simple #include of checksum.h fails because that file does not itself include the headers required to compile correctly. Several of the arch-specific files are this way.

Quoted 7 lines

* Some files use VERIFY_READ, VERIFY_WRITE, access_ok from uaccess.h but do not include uaccess.h

* Some files have an IPv6 checksum with struct in6_addr, but do not include linux/in6.h. x86_64 just defines the structure instead of including the file. Either way works, but it's inconsistent. I've moved them all to the #include, but they could all go to the struct in6_addr way too.

Two general rules I like:
1) Never include asm/xxx when there is a linux/xxx.
2) asm/ headers shouldn't include linux/ headers. It's too easy to cause insoluble loops.

I this case, I suspect #include <net/checksum.h> is what you really want.

Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.