+ /* Defining pdwd as (uint32_t *) causes some optimization issues (gcc -O2).
+ In prox_ip_cksum(), hdr_checksum is set to 0, as expected by the code below,
+ but when *pdwd is plain uint32_t, GCC does not see the pointer aliasing on
+ the IPv4 header, optimizes this hdr_checksum initialization away, and hence
+ breaks the expectations of the checksum computation loop below.
+ The following typedef tells GCC that the IPv4 header may be aliased by
+ pdwd, which prevents GCC from removing the hdr_checksum = 0 assignment.
+ */
+ typedef uint32_t __attribute__((__may_alias__)) uint32_may_alias;
+ uint32_may_alias *pdwd = (uint32_may_alias *)buf;