From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id BEBE1A09E9; Mon, 14 Dec 2020 15:44:47 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 29BF63257; Mon, 14 Dec 2020 15:44:46 +0100 (CET) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 9BFE92B9C; Mon, 14 Dec 2020 15:44:42 +0100 (CET) IronPort-SDR: M9oHvfNvxg0r1l43mEsQx9bxPJW9rtJABcuzYBJG/XAszjgxaEcRtbQgVVuO69/fVE2GXXtwJf yGcvTip2USdQ== X-IronPort-AV: E=McAfee;i="6000,8403,9834"; a="174860308" X-IronPort-AV: E=Sophos;i="5.78,420,1599548400"; d="scan'208";a="174860308" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Dec 2020 06:44:40 -0800 IronPort-SDR: K0RlriO6HPy7EDnQSiX7D+s1klqxlspAgi6oKjwoypcYmUadUbbjlx+//olVN1jJb7dM9NCCc/ B9dPIVoMU85w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,420,1599548400"; d="scan'208";a="411270621" Received: from orsmsx605.amr.corp.intel.com ([10.22.229.18]) by orsmga001.jf.intel.com with ESMTP; 14 Dec 2020 06:44:40 -0800 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX605.amr.corp.intel.com (10.22.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 14 Dec 2020 06:44:39 -0800 Received: from orsmsx609.amr.corp.intel.com (10.22.229.22) by ORSMSX612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 14 Dec 2020 06:44:39 -0800 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx609.amr.corp.intel.com (10.22.229.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Mon, 14 Dec 2020 06:44:39 -0800 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.172) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Mon, 14 Dec 2020 06:44:39 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BOTMP6yL++AR001J9Z8JLj3AjCIvAhacY3lCXLOdbqtSQNli0tGLmtdkH/7OfigFuNPapo9Fb02q13mO7FptYUGFTGXnWmb8rwqOrwXu13NQyGjneTVFpTudyAicKI6Wmt/Cd/J3cFXY/rwg1bJKxCkqbPGBrzMWyfg+O+3yvYab/YR+Usp9t8oZxQCzJX93jbdp4OtWKSlam05FQuiKHfcHYtzwMRrpUQCnDvhreNoT7Hzz3wclgjffaViyHQISp16CalJDPLMTlspvpsM0HaQ3EuzF9MruEib1QWscmWx/XJb5gzbC7JUxGA2TY6dSfGtPkbfmKUtWtwt1fbH/RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=90EX2eA1ikWuYW/WVeETUFIK65++mR5Ntcq5m6RaoUM=; b=gTGBwVpl7KY/VpPbHAqcRLlD467L4fPn52fbLDiR7IKXXXtqWakWSxZXB7zJHalh9c50WBWPZ+D3cocuzmy32FULxrhN1YBbH24YN0R3TrF3iyO345oEEXvvwtmcuLcgFg0FuCEW59q9nUFrVWuTIhBWacahSFliSghS7ofi3lxRefaiR8LgVHh8KRA1WXMmbY1uIm1DGdVu/PHiTvFu9bo1kQfMcksSgA1jDLmkw8TgxWXjBzNZ0VAqHvzpv53Y11Qetwy2WimHOH24TSRot/CLcPhQsfIMLNEoM9sQUzKDUIFiNGLz7kyMQ7BlXCdtOkb63Aktqh9xAwDiUNlDiQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=90EX2eA1ikWuYW/WVeETUFIK65++mR5Ntcq5m6RaoUM=; b=ynf0yxX/uzoqCX36a9jzs/+aEGLJ6HclIoSM/fgJZSZ8ba9OuvfUCZOpXNLyu4xvHAI6TiUftP4RyLU6NaxaVdhhzNRZlimSw8yctEYWS83NO5B+tl+Xa2f1xe14ClKym3z6L+k5HdVP4lnG3yR6s0ohPhI/b51BO6inmWByxNo= Received: from BYAPR11MB3301.namprd11.prod.outlook.com (2603:10b6:a03:7f::26) by BYAPR11MB3224.namprd11.prod.outlook.com (2603:10b6:a03:77::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12; Mon, 14 Dec 2020 14:44:35 +0000 Received: from BYAPR11MB3301.namprd11.prod.outlook.com ([fe80::e59d:1af1:8575:8435]) by BYAPR11MB3301.namprd11.prod.outlook.com ([fe80::e59d:1af1:8575:8435%6]) with mapi id 15.20.3654.024; Mon, 14 Dec 2020 14:44:35 +0000 From: "Ananyev, Konstantin" To: Yicai Lu , "dev@dpdk.org" CC: "zhoujingbin@huawei.com" , "chenchanghu@huawei.com" , "jerry.lilijun@huawei.com" , "haifeng.lin@huawei.com" , "guohongzhi1@huawei.com" , "wangyunjian@huawei.com" , "stable@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v5] ip_frag: remove padding length of fragment Thread-Index: AQHW0HcArH9F3eO4oUu1HijgF97tx6n2rd9g Date: Mon, 14 Dec 2020 14:44:35 +0000 Message-ID: References: <1605706193-17192-1-git-send-email-luyicai@huawei.com> <1607771130-13648-1-git-send-email-luyicai@huawei.com> In-Reply-To: <1607771130-13648-1-git-send-email-luyicai@huawei.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.5.1.3 authentication-results: huawei.com; dkim=none (message not signed) header.d=none;huawei.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [46.7.39.127] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: b34448dc-aba7-4885-c7a5-08d8a03ec6e1 x-ms-traffictypediagnostic: BYAPR11MB3224: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5797; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: chq3RYI2Zlnwi28XQFr7qa0GOEB73/O7itp1GEPTxLI6DwyexLTiPS4gfdGrnCKinpkUTx/4T2gTRLS0rpnDqS09ebeWcPRW8wDKW7sG1upQ+m4f2EGnhkcr01i6b+2me7MxfoAua7pT4POk/IEAiPNz50d+E0DVuzB5MQpo3WWhTsG1Vbo+VK1wp4xg6MxHTTPHZ9WQ3AqEzoaCZAWEg9tFsyKwmHO8BIR2+g0XLnAMS5l4Jacp02ecXhTbR24kzbVH05Eiugc1B4Uvmfg19WE/h815RkSPZ0mbGbyQ/Gv/Yw2V260Tih0o+QCywJnGNXZZbYPJFz2hbQF3EMZbjVb/NuSslNuzidE/QvC17bYIHXHvD4C/8fWIL4Cp4ApS x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR11MB3301.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(366004)(136003)(376002)(186003)(7696005)(52536014)(110136005)(76116006)(8936002)(26005)(508600001)(83380400001)(71200400001)(55016002)(5660300002)(4326008)(66446008)(6506007)(64756008)(66946007)(66476007)(54906003)(2906002)(86362001)(66556008)(8676002)(33656002)(9686003)(505234006); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?RnGGv5YeABpEWUHB70Tq0dyHrU66jaAmO5/p3e7NAptrKEDBBv9FB9IbcKcr?= =?us-ascii?Q?Qjx7NeMcBQN3jgEj4eyGQ3S37BR3J7NKzl9yOo7uzb0JTsvk/v19nK5U9ArS?= =?us-ascii?Q?tvl408HOfvC2KANFDTIflux93KUjNE4lxqnYaT52auvmbxp3KpYs9gu4pPTz?= =?us-ascii?Q?896PjJQBLVe4XgWMQ5WKs8zlQ23/l33E5KHvJsgUr5zNeTlY2xcO1f/yg9Q5?= =?us-ascii?Q?05STU/FKFWmf6SiZHYnjXD5wZSO34sB6IRSQV2rqygSjtn176xkPQcuvj9KY?= =?us-ascii?Q?3GWaDu+EB1F7f79qh3LbxcPyTmEcdz4Z/HXL+27k0//SZ1//Z+B/KDOvaXZC?= =?us-ascii?Q?lodsirhrgRy5OX58mheegl+ltIroxfXQdSLq9yv91W2QNlTFr9qCMNU41Dti?= =?us-ascii?Q?2KXEz+9qTLNTdugkexKpB41Uekb/ZVLYdD3FPuW/QqzuZ0VElDckxKckBjT2?= =?us-ascii?Q?D4BShX7Q6zsUKCCqgkkAj/jyb8OXMhVkJqyKYpMj/mNm9Pg2E8r8arjjtuF9?= =?us-ascii?Q?72bpwtlcBSJ5tis/sjAhZ8nyC2VzsvS0+vJel4CZkEWcX87gGMLIXaLXm5//?= =?us-ascii?Q?gx8g37G/T2dSNV78D56UX/vICK6BepDXLR3ei1pcJSaiQrR1cXoe1m9jJlQA?= =?us-ascii?Q?sIIaoWjEpDOhUGHOttos+2bIj+XJHNXrJVUia40zWse3BxzzwIUonjrm9C5Y?= =?us-ascii?Q?+l+gVuqbFVYMqZPDwYUDRdbZfzZeUmNT5TnlAERvXKlz01jcrWuCYvwSWLac?= =?us-ascii?Q?Ab/yg3jRnouseMM7dep2kjd2xDuzZ5HOkbV5zAzlFg/JCY2AK39TDmomvT9x?= =?us-ascii?Q?EvciUzT6GFzGFUGbf/dnM68Ujy6/f6CA0FADk9nI4BWgzunAbFNl69jKUqN9?= =?us-ascii?Q?r2uzwqcm5rDYUWeh9kP0uZmC1nW9KUt2Kq+zCT+8BMkX2itkC+KfYFx7et0L?= =?us-ascii?Q?s2blIf/4A+kCVLWOgerB4jT1VaPtuBtnhicoixpqiWA=3D?= x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BYAPR11MB3301.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b34448dc-aba7-4885-c7a5-08d8a03ec6e1 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Dec 2020 14:44:35.7117 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Bwye8kbIg2hS+oyvXK0lnYym9kPFitoTkH4xdRrStuDmo8bqKK7AIv+Oc8FTFeXWF9HAaeSdK7mNMiiP7OcPchXv/hZldXqBPJhcrzPnjFQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB3224 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v5] ip_frag: remove padding length of fragment 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Yicai, =20 > In some situations, we would get several ip fragments, which total > data length is less than min_ip_len(64) and padding with zeros. > We simulated intermediate fragments by modifying the MTU. > To illustrate the problem, we simplify the packet format and > ignore the impact of the packet header.In namespace2, > a packet whose data length is 1520 is sent. > When the packet passes tap2, the packet is divided into two > fragments: fragment A and B, similar to (1520 =3D 1510 + 10). > When the packet passes tap3, the larger fragment packet A is > divided into two fragments A1 and A2, similar to (1510 =3D 1500 + 10). > Finally, the bond interface receives three fragments: > A1, A2, and B (1520 =3D 1500 + 10 + 10). > One fragmented packet A2 is smaller than the minimum Ethernet > frame length, so it needs to be padded. >=20 > |---------------------------------------------------| > | HOST | > | |--------------| |----------------------------| | > | | ns2 | | |--------------| | | > | | |--------| | | |--------| |--------| | | > | | | tap1 | | | | tap2 | ns1| tap3 | | | > | | |mtu=3D1510| | | |mtu=3D1510| |mtu=3D1500| | | > | |--|1.1.1.1 |--| |--|1.1.1.2 |----|2.1.1.1 |--| | > | |--------| |--------| |--------| | > | | | | | > | |-----------------| | | > | | | > | |--------| | > | | bond | | > |--------------------------------------|mtu=3D1500|---| > |--------| >=20 > When processing the preceding packets above, > DPDK would aggregate fragmented packets A2 and B. > And error packets are generated, which padding(zero) > is displayed in the middle of the packet. >=20 > A2 + B: > 0000 fa 16 3e 9f fb 82 fa 47 b2 57 dc 20 08 00 45 00 > 0010 00 33 b4 66 00 ba 3f 01 c1 a5 01 01 01 01 02 01 > 0020 01 02 c0 c1 c2 c3 c4 c5 c6 c7 00 00 00 00 00 00 > 0030 00 00 00 00 00 00 00 00 00 00 00 00 c8 c9 ca cb > 0040 cc cd ce cf d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db > 0050 dc dd de df e0 e1 e2 e3 e4 e5 e6 >=20 > So, we would calculate the length of padding, and remove > the padding in pkt_len and data_len before aggregation. >=20 > Fixes: 7f0983ee331c ("ip_frag: check fragment length of incoming packet") > Cc: stable@dpdk.org >=20 > Signed-off-by: Yicai Lu > --- > v4 -> v5: Update the comments and description. > --- > lib/librte_ip_frag/rte_ipv4_reassembly.c | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) >=20 > diff --git a/lib/librte_ip_frag/rte_ipv4_reassembly.c b/lib/librte_ip_fra= g/rte_ipv4_reassembly.c > index 1dda8ac..fdf66a4 100644 > --- a/lib/librte_ip_frag/rte_ipv4_reassembly.c > +++ b/lib/librte_ip_frag/rte_ipv4_reassembly.c > @@ -104,6 +104,7 @@ struct rte_mbuf * > const unaligned_uint64_t *psd; > uint16_t flag_offset, ip_ofs, ip_flag; > int32_t ip_len; > + int32_t trim; >=20 > flag_offset =3D rte_be_to_cpu_16(ip_hdr->fragment_offset); > ip_ofs =3D (uint16_t)(flag_offset & RTE_IPV4_HDR_OFFSET_MASK); > @@ -117,14 +118,15 @@ struct rte_mbuf * >=20 > ip_ofs *=3D RTE_IPV4_HDR_OFFSET_UNITS; > ip_len =3D rte_be_to_cpu_16(ip_hdr->total_length) - mb->l3_len; > + trim =3D mb->pkt_len - (ip_len + mb->l3_len + mb->l2_len); >=20 > IP_FRAG_LOG(DEBUG, "%s:%d:\n" > - "mbuf: %p, tms: %" PRIu64 > - ", key: <%" PRIx64 ", %#x>, ofs: %u, len: %d, flags: %#x\n" > + "mbuf: %p, tms: %" PRIu64 ", key: <%" PRIx64 ", %#x>" > + "ofs: %u, len: %d, padding: %d, flags: %#x\n" > "tbl: %p, max_cycles: %" PRIu64 ", entry_mask: %#x, " > "max_entries: %u, use_entries: %u\n\n", > __func__, __LINE__, > - mb, tms, key.src_dst[0], key.id, ip_ofs, ip_len, ip_flag, > + mb, tms, key.src_dst[0], key.id, ip_ofs, ip_len, trim, ip_flag, > tbl, tbl->max_cycles, tbl->entry_mask, tbl->max_entries, > tbl->use_entries); >=20 > @@ -134,6 +136,10 @@ struct rte_mbuf * > return NULL; > } >=20 > + if (unlikely(trim > 0)) { > + rte_pktmbuf_trim(mb, trim); > + } As a nit {} braces are not required for single expression. LGTM in general, just one thing: shouldn't we have the same fix for ipv6 th= en? Konstantin > + > /* try to find/add entry into the fragment's table. */ > if ((fp =3D ip_frag_find(tbl, dr, &key, tms)) =3D=3D NULL) { > IP_FRAG_MBUF2DR(dr, mb); > -- > 1.9.5.msysgit.1