[ovs-dev] [RFC] ofp-actions: Remove expectation of struct ofpact size.
Ben Pfaff
blp at nicira.com
Mon Mar 10 21:47:10 UTC 2014
On Mon, Mar 10, 2014 at 02:12:27PM -0700, Gurucharan Shetty wrote:
> struct ofpact has enums that are packed in case of __GNUC__.
> This packing does not occur for visual studio. For 'struct ofpact_nest',
> we are expecting that this structure is less than or equal to 8 bytes
> which won't be true in compilers where enums are not packed.
>
> Signed-off-by: Gurucharan Shetty <gshetty at nicira.com>
> ---
> There must have been a reason why there was this BUILD_ASSERT in the
> first place. But, I do not understand the reason. (Unit tests don't
> fail after removing the OVS_PACKED_ENUM macro from the related enums
> and this build assert.)
The goal of OFPACT_ALIGNTO is to make sure that every ofpact starts on
an 8-byte boundary, which is in turn important because RISC machines
often require 8-byte alignment for e.g. pointers. Since ofpact_nest
contains nested ofpacts, the ofpact[] array inside it needs to be on
an 8-byte boundary too. The build assertion checked for that, but it
was too strict: any multiple of 8 bytes will work, but it required
exactly 8 bytes.
I think that the build assertion should be relaxed from "<offset> ==
OFPACT_ALIGNTO", to "<offset> % OFPACT_ALIGNTO == 0".
Does that make sense?
Thanks,
Ben.
More information about the dev
mailing list