netdev
[Top] [All Lists]

Re: [BUG] alignment problem in net/core/flow.c:flow_key_compare

To: davem@xxxxxxxxxx
Subject: Re: [BUG] alignment problem in net/core/flow.c:flow_key_compare
From: YOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@xxxxxxxxxxxxxx>
Date: Fri, 19 Mar 2004 11:55:11 +0900 (JST)
Cc: netdev@xxxxxxxxxxx, akpm@xxxxxxxx, mru@xxxxxx
In-reply-to: <20040318162903.59192d13.akpm@xxxxxxxx>
Organization: USAGI Project
References: <20040318162903.59192d13.akpm@xxxxxxxx>
Sender: netdev-bounce@xxxxxxxxxxx
In article <20040318162903.59192d13.akpm@xxxxxxxx> (at Thu, 18 Mar 2004 
16:29:03 -0800), Andrew Morton <akpm@xxxxxxxx> says:

> The solutions I see are either to force the alignment of struct flowi
> to 64 bits, or to use 32-bit access in flow_key_compare.

Here's the patch.

===== include/net/flow.h 1.10 vs edited =====
--- 1.10/include/net/flow.h     Thu Jan 15 17:18:43 2004
+++ edited/include/net/flow.h   Fri Mar 19 11:45:54 2004
@@ -10,6 +10,12 @@
 #include <linux/in6.h>
 #include <asm/atomic.h>
 
+#if (BITS_PER_LONG == 64)
+#define FLOWI_ALIGN_BYTES 8
+#else
+#define FLOWI_ALIGN_BYTES 4
+#endif
+
 struct flowi {
        int     oif;
        int     iif;
@@ -77,7 +83,7 @@
 #define fl_icmp_type   uli_u.icmpt.type
 #define fl_icmp_code   uli_u.icmpt.code
 #define fl_ipsec_spi   uli_u.spi
-};
+} __attribute__((__aligned__(FLOWI_ALIGN_BYTES)));
 
 #define FLOW_DIR_IN    0
 #define FLOW_DIR_OUT   1

-- 
Hideaki YOSHIFUJI @ USAGI Project <yoshfuji@xxxxxxxxxxxxxx>
GPG FP: 9022 65EB 1ECF 3AD1 0BDF  80D8 4807 F894 E062 0EEA

<Prev in Thread] Current Thread [Next in Thread>