From: Jesse Gross Date: Thu, 5 Sep 2013 20:01:58 +0000 (-0700) Subject: datapath: Fix alignment of struct sw_flow_key. X-Git-Tag: sliver-openvswitch-2.0.90-1~16^2~14 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;ds=sidebyside;h=9a6fe4c1ae510f1ee9fb382e285a11a5d8e2722b;p=sliver-openvswitch.git datapath: 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 Reported-by: Fengguang Wu Reported-by: Geert Uytterhoeven Signed-off-by: Jesse Gross --- diff --git a/datapath/flow.c b/datapath/flow.c index 7a697a42f..34e4443c9 100644 --- a/datapath/flow.c +++ b/datapath/flow.c @@ -1995,6 +1995,7 @@ nla_put_failure: * Returns zero if successful or a negative error code. */ 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)); flow_cache = kmem_cache_create("sw_flow", sizeof(struct sw_flow), 0, diff --git a/datapath/flow.h b/datapath/flow.h index eda74f30c..03eae0352 100644 --- a/datapath/flow.h +++ b/datapath/flow.h @@ -127,7 +127,7 @@ struct sw_flow_key { } nd; } ipv6; }; -} __aligned(__alignof__(long)); +} __aligned(BITS_PER_LONG/8); /* Ensure that we can do comparisons as longs. */ struct sw_flow { struct rcu_head rcu;