Message ID | 1448377959-4440-1-git-send-email-danielx.t.mrzyglod@intel.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 16DA58E8B; Tue, 24 Nov 2015 16:13:18 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 465428E85 for <dev@dpdk.org>; Tue, 24 Nov 2015 16:13:16 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP; 24 Nov 2015 07:13:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,338,1444719600"; d="scan'208";a="858444325" Received: from unknown ([10.217.248.15]) by orsmga002.jf.intel.com with SMTP; 24 Nov 2015 07:13:11 -0800 Received: by (sSMTP sendmail emulation); Tue, 24 Nov 2015 16:12:48 +0100 From: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com> To: dev@dpdk.org Date: Tue, 24 Nov 2015 16:12:39 +0100 Message-Id: <1448377959-4440-1-git-send-email-danielx.t.mrzyglod@intel.com> X-Mailer: git-send-email 2.5.3 Subject: [dpdk-dev] [PATCH] net: fix build with gcc 4.4.7 and strict aliasing X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK <dev.dpdk.org> List-Unsubscribe: <http://dpdk.org/ml/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://dpdk.org/ml/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <http://dpdk.org/ml/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Commit Message
Daniel Mrzyglod
Nov. 24, 2015, 3:12 p.m. UTC
This is fix for GCC 4.4.7.
flag "-fstrict-aliasing" is default for optimalisation above -O0.
Fixes: 2b039d5f20a3 ("net: fix build with gcc 4.4.7 and strict aliasing")
Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
---
lib/librte_net/rte_ip.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
This error fix this situation for IPv6 checksum offload error on RHEL65 Any optimalisation above -O0 provide error in IPv6 checksum Step 1 : start testpmd ./x86_64-native-linuxapp-gcc/app/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 : calculate correct checksum values of IPv6/TCP and IPv6/UDP by scapy Packets info: IPv6/UDP:Ether(dst="02:00:00:00:00:00", src="90:e2:ba:4a:33:5c")/IPv6(src="::2")/UDP()/("X"*46) IPv6/TCP: Ether(src="52:00:00:00:00:00", dst="90:e2:ba:4a:33:5d")/IPv6(src="::1")/TCP()/("X"*46) Step 4 : Send two packets with wrong checksum value,and calculate the right checksum value by port,packets received on another port Send packets info: IPv6/UDP:Ether(dst="90:e2:ba:4a:33:5d", src="52:00:00:00:00:00")/IPv6(src="::1")/UDP(chksum=0xf)/("X"*46) IPv6/TCP:Ether(dst="90:e2:ba:4a:33:5d", src="52:00:00:00:00:00")/IPv6(src="::1")/TCP(chksum=0xf)/("X"*46) RESULTS: 'IPv6/TCP': ['0xd41']}, 'IPv6/UDP': ['0x7d07'], EXPECTED RESULTS: 'IPv6/TCP': ['0x9f5e']}, 'IPv6/UDP': ['0xf26']
On Tue, Nov 24, 2015 at 03:47:28PM +0000, Mrzyglod, DanielX T wrote: > This error fix this situation for IPv6 checksum offload error on RHEL65 > Any optimalisation above -O0 provide error in IPv6 checksum > > > Step 1 : start testpmd > ./x86_64-native-linuxapp-gcc/app/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 : calculate correct checksum values of IPv6/TCP and IPv6/UDP by scapy > Packets info: IPv6/UDP:Ether(dst="02:00:00:00:00:00", src="90:e2:ba:4a:33:5c")/IPv6(src="::2")/UDP()/("X"*46) > IPv6/TCP: Ether(src="52:00:00:00:00:00", dst="90:e2:ba:4a:33:5d")/IPv6(src="::1")/TCP()/("X"*46) > > Step 4 : Send two packets with wrong checksum value,and calculate the right checksum value by port,packets received on another port > Send packets info: IPv6/UDP:Ether(dst="90:e2:ba:4a:33:5d", src="52:00:00:00:00:00")/IPv6(src="::1")/UDP(chksum=0xf)/("X"*46) > IPv6/TCP:Ether(dst="90:e2:ba:4a:33:5d", src="52:00:00:00:00:00")/IPv6(src="::1")/TCP(chksum=0xf)/("X"*46) > > RESULTS: > 'IPv6/TCP': ['0xd41']}, 'IPv6/UDP': ['0x7d07'], > > EXPECTED RESULTS: > 'IPv6/TCP': ['0x9f5e']}, 'IPv6/UDP': ['0xf26'] Hi Daniel, this sort of detail - perhaps in abbreviated form - should be in the commit message for the patch. Can you perhaps do a V2 to include it? /Bruce
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. The solution is to add typedef with __attribute__((__may_alias__) for uint16_t. Step 1 : start testpmd ./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 : Recieved packets: RESULTS: IPv6/TCP': ['0xd41'] or other unexpected. EXPECTED RESULTS: IPv6/TCP': ['0x9f5e'] Daniel Mrzyglod (1): net: fix build with gcc 4.4.7 and strict aliasing lib/librte_net/rte_ip.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
On Tue, 24 Nov 2015 17:31:17 +0100 Daniel Mrzyglod <danielx.t.mrzyglod@intel.com> wrote: > 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. > The solution is to add typedef with __attribute__((__may_alias__) for uint16_t. > > Step 1 : start testpmd > ./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 : Recieved packets: > RESULTS: > IPv6/TCP': ['0xd41'] or other unexpected. > > EXPECTED RESULTS: > IPv6/TCP': ['0x9f5e'] > > Daniel Mrzyglod (1): > net: fix build with gcc 4.4.7 and strict aliasing > > lib/librte_net/rte_ip.h | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > An alternative way of fixing it (without resorting to attributes) would be to use a union.
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Daniel Mrzyglod > Sent: Tuesday, November 24, 2015 3:13 PM > To: dev@dpdk.org > Subject: [dpdk-dev] [PATCH] net: fix build with gcc 4.4.7 and strict aliasing > > This is fix for GCC 4.4.7. > flag "-fstrict-aliasing" is default for optimalisation above -O0. > > Fixes: 2b039d5f20a3 ("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> > 2.5.0
2015-11-25 18:00, Ananyev, Konstantin: > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Daniel Mrzyglod > > Sent: Tuesday, November 24, 2015 3:13 PM > > To: dev@dpdk.org > > Subject: [dpdk-dev] [PATCH] net: fix build with gcc 4.4.7 and strict aliasing > > > > This is fix for GCC 4.4.7. > > flag "-fstrict-aliasing" is default for optimalisation above -O0. > > > > Fixes: 2b039d5f20a3 ("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> Applied, thanks
diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h index 71c519a..5b7554a 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];