openvswitch: Fix alignment of struct sw_flow_key.

sw_flow_key alignment was declared as " __aligned(__alignof__(long))".
However, this breaks on the m68k architecture where long is 32 bit in
size but 16 bit aligned by default. This aligns to the size of a long to
ensure that we can always do comparsions in full long-sized chunks. It
also adds an additional build check to catch any reduction in alignment.

CC: Andy Zhou <azhou@nicira.com>
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Jesse Gross <jesse@nicira.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Jesse Gross 2013-09-05 12:17:05 -07:00 committed by David S. Miller
parent 06c54055be
commit 0d40f75bda
2 changed files with 2 additions and 1 deletions

View File

@ -1981,6 +1981,7 @@ int ovs_flow_to_nlattrs(const struct sw_flow_key *swkey,
* Returns zero if successful or a negative error code. */ * Returns zero if successful or a negative error code. */
int ovs_flow_init(void) int ovs_flow_init(void)
{ {
BUILD_BUG_ON(__alignof__(struct sw_flow_key) % __alignof__(long));
BUILD_BUG_ON(sizeof(struct sw_flow_key) % sizeof(long)); BUILD_BUG_ON(sizeof(struct sw_flow_key) % sizeof(long));
flow_cache = kmem_cache_create("sw_flow", sizeof(struct sw_flow), 0, flow_cache = kmem_cache_create("sw_flow", sizeof(struct sw_flow), 0,

View File

@ -125,7 +125,7 @@ struct sw_flow_key {
} nd; } nd;
} ipv6; } ipv6;
}; };
} __aligned(__alignof__(long)); } __aligned(BITS_PER_LONG/8); /* Ensure that we can do comparisons as longs. */
struct sw_flow { struct sw_flow {
struct rcu_head rcu; struct rcu_head rcu;