From: Daniel Mrzyglod Date: Tue, 24 Nov 2015 16:31:18 +0000 (+0100) Subject: net: fix build with gcc 4.4.7 and strict aliasing X-Git-Tag: spdx-start~7947 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=e079655c41fb;p=dpdk.git net: fix build with gcc 4.4.7 and strict aliasing This fix is for IPv6 checksum offload error on RHEL65. Any optimalisation above -O0 provide error in IPv6 checksum flag "-fstrict-aliasing" is default for optimalisation above -O0. Step 1: testpmd -c 0x6 -n 4 -- -i --portmask=0x3 --disable-hw-vlan --enable-rx-cksum --crc-strip --txqflags=0 Step 2: settings and start set verbose 1 set fwd csum start Step 3: send scapy with bad checksum IPv6/TCP packet Ether(src="52:00:00:00:00:00", dst="90:e2:ba:4a:33:5d")/IPv6(src="::1")/TCP(chksum=0xf)/("X"*46) Step 4: Received packets: RESULTS: IPv6/TCP': ['0xd41'] or other unexpected. EXPECTED RESULTS: IPv6/TCP': ['0x9f5e'] Fixes: 2b039d5f20a3 ("net: fix build with gcc 4.4.7 and strict aliasing") Signed-off-by: Daniel Mrzyglod Acked-by: Konstantin Ananyev --- diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h index 71c519a121..5b7554ab8a 100644 --- a/lib/librte_net/rte_ip.h +++ b/lib/librte_net/rte_ip.h @@ -169,7 +169,8 @@ __rte_raw_cksum(const void *buf, size_t len, uint32_t sum) { /* workaround gcc strict-aliasing warning */ uintptr_t ptr = (uintptr_t)buf; - const uint16_t *u16 = (const uint16_t *)ptr; + typedef uint16_t __attribute__((__may_alias__)) u16_p; + const u16_p *u16 = (const u16_p *)ptr; while (len >= (sizeof(*u16) * 4)) { sum += u16[0];