From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id BDBAA81F6C for ; Wed, 14 Dec 2016 23:51:59 -0800 (PST) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP; 14 Dec 2016 23:51:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,351,1477983600"; d="scan'208";a="42836474" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga006.fm.intel.com with ESMTP; 14 Dec 2016 23:51:59 -0800 Received: from fmsmsx112.amr.corp.intel.com (10.18.116.6) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 14 Dec 2016 23:51:58 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX112.amr.corp.intel.com (10.18.116.6) with Microsoft SMTP Server (TLS) id 14.3.248.2; Wed, 14 Dec 2016 23:51:58 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.11]) by shsmsx102.ccr.corp.intel.com ([169.254.2.54]) with mapi id 14.03.0248.002; Thu, 15 Dec 2016 15:51:27 +0800 From: "Wu, Jiaxin" To: "Wu, Hao A" , "edk2-devel@lists.01.org" CC: "Fu, Siyuan" , "Ye, Ting" Thread-Topic: [PATCH 4/6] MdeModulePkg/DxeNetLib: Rewrite NetblockChecksum function logic Thread-Index: AQHSVf0FAKXCY/+TxEiHV+D12gyQkKEIpAPw Date: Thu, 15 Dec 2016 07:51:26 +0000 Message-ID: <895558F6EA4E3B41AC93A00D163B72741627F61C@SHSMSX103.ccr.corp.intel.com> References: <1481714811-12568-1-git-send-email-hao.a.wu@intel.com> <1481714811-12568-5-git-send-email-hao.a.wu@intel.com> In-Reply-To: <1481714811-12568-5-git-send-email-hao.a.wu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYTcwNGI0YjAtYjhiMS00M2NjLTlmODMtZWI1MjBiNTEyOWEzIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IkNQRDZJdWk0d1wvMXJoVUg1emhwcysxZDZhM3JuN1NUcUJGa0l6ZWs5Qll3PSJ9 x-ctpclassification: CTP_IC x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH 4/6] MdeModulePkg/DxeNetLib: Rewrite NetblockChecksum function logic X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Dec 2016 07:51:59 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Wu Jiaxin > -----Original Message----- > From: Wu, Hao A > Sent: Wednesday, December 14, 2016 7:27 PM > To: edk2-devel@lists.01.org > Cc: Wu, Hao A ; Fu, Siyuan ; Ye, > Ting ; Wu, Jiaxin > Subject: [PATCH 4/6] MdeModulePkg/DxeNetLib: Rewrite > NetblockChecksum function logic >=20 > This commit rewrites the logic for NetblockChecksum. It processes the > checksum of the left-over byte first to prevent possible mis-reports by s= tatic > code checkers. >=20 > Cc: Fu Siyuan > Cc: Ye Ting > Cc: Wu Jiaxin > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Hao Wu > --- > MdeModulePkg/Library/DxeNetLib/NetBuffer.c | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) >=20 > diff --git a/MdeModulePkg/Library/DxeNetLib/NetBuffer.c > b/MdeModulePkg/Library/DxeNetLib/NetBuffer.c > index bbbdbc0..95cb717 100644 > --- a/MdeModulePkg/Library/DxeNetLib/NetBuffer.c > +++ b/MdeModulePkg/Library/DxeNetLib/NetBuffer.c > @@ -1,7 +1,7 @@ > /** @file > Network library functions providing net buffer operation support. >=20 > -Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.
> +Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
> This program and the accompanying materials are licensed and made > available under the terms and conditions of the BSD License which > accompanies this distribution. The full text of the license may be found= at > @@ -1661,6 +1661,13 @@ NetblockChecksum ( >=20 > Sum =3D 0; >=20 > + // > + // Add left-over byte, if any > + // > + if (Len % 2 !=3D 0) { > + Sum +=3D *(Bulk + Len - 1); > + } > + > while (Len > 1) { > Sum +=3D *(UINT16 *) Bulk; > Bulk +=3D 2; > @@ -1668,13 +1675,6 @@ NetblockChecksum ( > } >=20 > // > - // Add left-over byte, if any > - // > - if (Len > 0) { > - Sum +=3D *(UINT8 *) Bulk; > - } > - > - // > // Fold 32-bit sum to 16 bits > // > while ((Sum >> 16) !=3D 0) { > -- > 1.9.5.msysgit.0