From e079655c41fb89045ddf5237c5f9a78028b2e39c Mon Sep 17 00:00:00 2001 From: Daniel Mrzyglod Date: Tue, 24 Nov 2015 17:31:18 +0100 Subject: [PATCH] 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 --- lib/librte_net/rte_ip.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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]; -- 2.20.1