Skip to content

Commit

Permalink
net: fix build with gcc 4.4.7 and strict aliasing
Browse files Browse the repository at this point in the history
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: 2b039d5 ("net: fix build with gcc 4.4.7 and strict aliasing")

Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
  • Loading branch information
Daniel Mrzyglod authored and Thomas Monjalon committed Nov 25, 2015
1 parent 66874e5 commit e079655
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/librte_net/rte_ip.h
Expand Up @@ -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];
Expand Down

0 comments on commit e079655

Please sign in to comment.