From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id B8AB05F3B for ; Fri, 8 Jun 2018 16:04:56 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jun 2018 07:04:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,490,1520924400"; d="scan'208";a="230985999" Received: from irsmsx109.ger.corp.intel.com ([163.33.3.23]) by orsmga005.jf.intel.com with ESMTP; 08 Jun 2018 07:04:54 -0700 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.126]) by IRSMSX109.ger.corp.intel.com ([169.254.13.225]) with mapi id 14.03.0319.002; Fri, 8 Jun 2018 15:04:53 +0100 From: "Ananyev, Konstantin" To: "Wu, Yanglong" , "dev@dpdk.org" CC: "Zhang, Qi Z" Thread-Topic: [PATCH v2] net/i40e: illagel pactket checking Thread-Index: AQHT/t1x7XsNx3t8mkezD05N+Xjo6aRWZOxg Date: Fri, 8 Jun 2018 14:04:53 +0000 Message-ID: <2601191342CEEE43887BDE71AB977258C0C3990E@irsmsx105.ger.corp.intel.com> References: <20180607093938.62579-1-yanglong.wu@intel.com> <20180608035412.91329-1-yanglong.wu@intel.com> In-Reply-To: <20180608035412.91329-1-yanglong.wu@intel.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYTA4OGU3YTgtYjAzZi00MjljLTg1MDEtNzhlMWVhZmY3YjZjIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiS2VtSVhwOVF2Y0s2b1NsZDlQcWVSRUY4Y0RwcWNDU3ZZb25jSzhiZCttZUh1T1RSUHBkMVFtQTd0akFVRitSdiJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action x-originating-ip: [163.33.239.182] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v2] net/i40e: illagel pactket checking X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jun 2018 14:04:57 -0000 > -----Original Message----- > From: Wu, Yanglong > Sent: Friday, June 8, 2018 4:54 AM > To: dev@dpdk.org > Cc: Zhang, Qi Z ; Ananyev, Konstantin ; Wu, Yanglong > > Subject: [PATCH v2] net/i40e: illagel pactket checking >=20 > Some illegal packets will lead to TX/RX hang and > can't recover automatically. This pacth check those > illegal packets and protect TX/RX from hanging. >=20 > Signed-off-by: Yanglong Wu > --- > v2: > fix coding style issue and error > --- > drivers/net/i40e/i40e_rxtx.c | 11 +++++++++++ > drivers/net/i40e/i40e_rxtx.h | 2 ++ > 2 files changed, 13 insertions(+) >=20 > diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c > index 6032d5541..05cf3956c 100644 > --- a/drivers/net/i40e/i40e_rxtx.c > +++ b/drivers/net/i40e/i40e_rxtx.c > @@ -1458,6 +1458,17 @@ i40e_prep_pkts(__rte_unused void *tx_queue, struct= rte_mbuf **tx_pkts, > return i; > } >=20 > + /*check the size of pkt len*/ > + if (m->pkt_len > I40E_FRAME_SIZE_MAX || > + m->pkt_len < I40E_TX_MIN_PKT_LEN) { > + rte_errno =3D -EINVAL; > + return i; } Please follow DPDK coding style:=20 If (...) { ... } > + > + /*check the number of mbuf segments*/ > + if (m->nb_segs > I40E_TX_MAX_MTU_SEG) { > + rte_errno =3D -EINVAL; > + return i; } I'll just repeat comment from my previous mail: We already checking that in that function: /* Check for m->nb_segs to not exceed the limits. */ if (!(ol_flags & PKT_TX_TCP_SEG)) { if (m->nb_segs > I40E_TX_MAX_SEG || m->nb_segs > I40E_TX_MAX_MTU_SEG) { rte_errno =3D -EINVAL; return i; } } else if ((m->tso_segsz < I40E_MIN_TSO_MSS) || (m->tso_segsz > I40E_MAX_TSO_MSS)) { /* MSS outside the range (256B - 9674B) are conside= red * malicious */ rte_errno =3D -EINVAL; return i; } Though it seems it is not totally correct, should probably be: if (!(ol_flags & PKT_TX_TCP_SEG)) { if (m->nb_segs > I40E_TX_MAX_SEG) { ... } } else if (m->nb_segs > I40E_TX_MAX_MTU_SEG || m->tso_segsz < I40E_MIN_TSO_MSS || m->tso_segsz > I40E_MAX_TSO_MSS) { ... } Konstantin