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 1AED3A09FD; Fri, 18 Dec 2020 12:41:44 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 18B88CAAB; Fri, 18 Dec 2020 12:41:42 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id BDA82CAAB; Fri, 18 Dec 2020 12:41:37 +0100 (CET) IronPort-SDR: cn4tckWCKt6zASSpTfMslMmSFx219PW7DGFTvaWbiNIpiKBgQtdbUm5eJ3vlAeHyQQuVjKSkdt p22Qh8Cb2wlg== X-IronPort-AV: E=McAfee;i="6000,8403,9838"; a="154645974" X-IronPort-AV: E=Sophos;i="5.78,430,1599548400"; d="scan'208";a="154645974" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Dec 2020 03:41:35 -0800 IronPort-SDR: /OgkeYjr9aCcMvIJNN1wbhKwsDuYi20h8VOnhxeimscmyKMLhcQ6czluyriatEiVV7BQfbbW6A T3519gDNVNEw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,430,1599548400"; d="scan'208";a="353933897" Received: from orsmsx605.amr.corp.intel.com ([10.22.229.18]) by orsmga002.jf.intel.com with ESMTP; 18 Dec 2020 03:41:35 -0800 Received: from orsmsx603.amr.corp.intel.com (10.22.229.16) 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; Fri, 18 Dec 2020 03:41:34 -0800 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5 via Frontend Transport; Fri, 18 Dec 2020 03:41:34 -0800 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.169) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.1713.5; Fri, 18 Dec 2020 03:41:34 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FlPFW92y/5D6SfhHkqg09YHlt6uK1aeFatqw/fyBC3pCvWVJwwFJc2pYDMwnlnje6DscSBgrLpVD0UEtCVJd5y6vb+aE4u9WICbbltlDbsAIwRuo3zOiq5helrJO3t7n+kse7cD1ix+XD7bxn+WZN+WaciXaPMWjHChkXKvLEZrvDCqbC7N8QqKP+ZMXUb1ubpeOXLxSUBvA6Ox2D7LOxibQML0lmXhpMZ6BbQ+OIh/afLdF+XyKEIvaH5EIK14FNTAGEEV0yEFGNrVJi0sF+f0b20djxu/MXnEN9cREGs6XOiyDuJP0/LfDIiqnHxx8Da5GL2OTSx/2odoZDnzQhw== 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=t9yjLHDix6wd+HObX6XnxcoERufAIiDD2ttehTIifVI=; b=MlaZrJ+He+M3fi/Wmx2NI5yq4uduJXA98hTZQrIzgt6OGeU2Rpa+XSF5CoxNC9tYsEaxFRX77+gKv/GDQ88CzLABaTXvWFkiqVHGRU1MS2oIJ3qMHU1x/8kYrvLiA2/78VaLyPPl+ItBVfrIe0hOYWVtCk0dy25JgFppfpy9ruH01iBdexnRPzxkSe4ogv9zzzm7nIp1GAzZhKbd+YovqNx3NvbnUysKV4Trv/6lJd2poNcHsk+kEopD1UQ2Up/8M6txBXg39SVevfa3vBgqX1XTtTWb9HiwJM12ds2NwRPoM23Jsa0V4KS+V1Vw1ziFT9WssAcSoyAg+XViMh+OoQ== 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=t9yjLHDix6wd+HObX6XnxcoERufAIiDD2ttehTIifVI=; b=jnx00vucCoVm3lXnhlh4Q1+GhaIdqnwSlwyRWF1co5BzfBz4BL2qj75Pb2YDVnBmkTeCIWiYL2L2YI/j/zl4AD2w8Lbw/Eh5S+Sq02Q8e6cYiSGcPRVsfBpHHu7sorwNxMuzx7YhmhMwLIWerNeD0xVuxH0yOkPJVGyuCpQldUw= Received: from BYAPR11MB3301.namprd11.prod.outlook.com (2603:10b6:a03:7f::26) by BYAPR11MB3446.namprd11.prod.outlook.com (2603:10b6:a03:1a::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.20; Fri, 18 Dec 2020 11:41:33 +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; Fri, 18 Dec 2020 11:41:33 +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 v6] ip_frag: remove padding length of fragment Thread-Index: AQHW07CVtvA2QhdrnkSZinvON3nnI6n8vdLg Date: Fri, 18 Dec 2020 11:41:33 +0000 Message-ID: References: <1605706193-17192-1-git-send-email-luyicai@huawei.com> <1608125790-26496-1-git-send-email-luyicai@huawei.com> In-Reply-To: <1608125790-26496-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: 2853f30d-519b-4c11-0765-08d8a349deb7 x-ms-traffictypediagnostic: BYAPR11MB3446: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:404; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: WRW4xDpSfByNMetfsemq+SzB7E7WGYGu/0MzqSd8ZmnZWwoR3eY4whavGspA6FmH4Zbzz3ZbFPTQt86zRxdXRbk+7h1KbpFrjpcJaOWGRmWv9hkJjbZNoQlA5ijsqsAv+KnlP49ulR0DhXU6mAPKZZECu+Ex+Oz+tGOK+cvsNC7UNZhc1EgQPT5xT1oyRzkpDqnQCTTxwjJzpMgw9Uz1aI3Mf/wKNCarCBWnXQPky3rII91Tk1hhVUUsy87HEcUvtT/JRUP0pwKXMQZXDPdi5e1w1MDSuYV8IEM6/IIWqd5DRVkP3AmIt1V81WRr0IWwsYPogqpw2C+fTj3qi2zU9xY+ZtJnfoxMLkX7PNxxa43tDTJFMKI3LOSUj1CD1LsA 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)(39860400002)(136003)(396003)(366004)(376002)(346002)(5660300002)(33656002)(7696005)(71200400001)(478600001)(9686003)(186003)(76116006)(2906002)(26005)(83380400001)(52536014)(66556008)(8676002)(110136005)(64756008)(54906003)(86362001)(8936002)(66946007)(66446008)(316002)(4326008)(55016002)(66476007)(6506007)(505234006); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?y/NnTsruGaOMhLd4gQ8Q7A+G3wk3CbP+chvL+hblGx0mKdu2d3t9476LJDcE?= =?us-ascii?Q?Atu4H4uxaeq3j6pwhP1mWZAxZyZXvxM4iS1bCykDo6+kr6aQqTivpFNhEBSE?= =?us-ascii?Q?HA77Jyel+ldt6nlwBKFLGZqfYTG/Wzu9IPZaymrIcLGDdHvJ0ir6cAaPzpfu?= =?us-ascii?Q?eo8xy38i/yH8y7RXjUMxXpNc29PzfBktpktVG2SJPh3ZXS5WZKXa/UMBYy4C?= =?us-ascii?Q?tF+0Q/Xz3mtOUjEBoN951f+0JocjNLjSAdOJnvP4z1M8a7z4G7gR40vf2mm1?= =?us-ascii?Q?lmp+tNCWgLB9qqwlsy0QCPlxE64ydVpbTNhEk1uWgXI7Oz59DhR0x5sjjD0k?= =?us-ascii?Q?bftKoplO1ig0Kz01bm3szNgorxh1hHMnspl1HhrU9VLHBTIKsxlL7iFmhWk3?= =?us-ascii?Q?wyZSOg/oyC/zsjSeKGtlK/7CIvptpy6BezojKBpUiZ4bM3jsgZq/YfAV372h?= =?us-ascii?Q?USBQZ+Hf2EISH/emButFUC3QF5zUTMXj2WYxWGb39Cp7EG+oBufgRD6cBbot?= =?us-ascii?Q?ZGhWtlIg08BOtGODUL5yPNE8r97z/TRWDtRB+9htqUEP7IJpGl8wLRp47egm?= =?us-ascii?Q?TdhM6bg/1tf3wWubNlAdIhGmDc/3RVRxRaJOZZlRbYY3AT3jePjD8U39z1N+?= =?us-ascii?Q?fnlqk5sMYsK/prQ9UgL6xV8bG1uIVJ7gkNPPOuKy0xsuqX2OiwlxxwR+Oplg?= =?us-ascii?Q?L9OJOulyotZOX6dFWHXQpHp1F94Bshi+VM0Y3sxcX5NXebd9ncSZLYUYLjEF?= =?us-ascii?Q?83Jcxfewv6XIHdqYELZ8kv3xdIbvzVq5H2srDHxDX2fO0660LBBN0e838VLP?= =?us-ascii?Q?JmVU/unePEtT2kiJbw9cogw5LCslnFv1xG//d31hu75ngGP8IbMi4T/WY7qY?= =?us-ascii?Q?RYHem9UVGH1QY8K0dj951qzElcn8hQb7kCDRwgrNisrmRnkmAOjvmMG/qSjc?= =?us-ascii?Q?afl0ypInFmx6coiLEPYtVSKINnMeoVX6Bf7s8T+oPc4=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: 2853f30d-519b-4c11-0765-08d8a349deb7 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Dec 2020 11:41:33.6512 (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: iTLiDbNxQTpQmIMoZ02w7J6ufWvKfIwnQcuVx0s+vEN92E4sBtKPYUQcjNjI3Z3LJYeMcwkRoKymj8lBuaaGbX6EgWTCZfsPZcQiUPaUDEs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB3446 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v6] 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" >=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. > And also we have the fix for both ipv4 and ipv6. >=20 > Fixes: 7f0983ee331c ("ip_frag: check fragment length of incoming packet") > Cc: stable@dpdk.org >=20 > Signed-off-by: Yicai Lu > --- > v5 -> v6: Have the fix for ipv6. > --- > lib/librte_ip_frag/rte_ipv4_reassembly.c | 11 ++++++++--- > lib/librte_ip_frag/rte_ipv6_reassembly.c | 9 +++++++-- > 2 files changed, 15 insertions(+), 5 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..69666c8 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,9 @@ struct rte_mbuf * > return NULL; > } >=20 > + if (unlikely(trim > 0)) > + rte_pktmbuf_trim(mb, trim); > + > /* 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); > diff --git a/lib/librte_ip_frag/rte_ipv6_reassembly.c b/lib/librte_ip_fra= g/rte_ipv6_reassembly.c > index ad01055..4037da0 100644 > --- a/lib/librte_ip_frag/rte_ipv6_reassembly.c > +++ b/lib/librte_ip_frag/rte_ipv6_reassembly.c > @@ -142,6 +142,7 @@ struct rte_mbuf * > struct ip_frag_key key; > uint16_t ip_ofs; > int32_t ip_len; > + int32_t trim; >=20 > rte_memcpy(&key.src_dst[0], ip_hdr->src_addr, 16); > rte_memcpy(&key.src_dst[2], ip_hdr->dst_addr, 16); > @@ -158,16 +159,17 @@ struct rte_mbuf * > * this is what we remove from the payload len. > */ > ip_len =3D rte_be_to_cpu_16(ip_hdr->payload_len) - sizeof(*frag_hdr); > + 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: <" IPv6_KEY_BYTES_FMT ", %#x>, " > - "ofs: %u, len: %d, flags: %#x\n" > + "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, IPv6_KEY_BYTES(key.src_dst), key.id, ip_ofs, ip_len, > - RTE_IPV6_GET_MF(frag_hdr->frag_data), > + trim, RTE_IPV6_GET_MF(frag_hdr->frag_data), > tbl, tbl->max_cycles, tbl->entry_mask, tbl->max_entries, > tbl->use_entries); >=20 > @@ -177,6 +179,9 @@ struct rte_mbuf * > return NULL; > } >=20 > + if (unlikely(trim > 0)) > + rte_pktmbuf_trim(mb, trim); > + > /* try to find/add entry into the fragment's table. */ > fp =3D ip_frag_find(tbl, dr, &key, tms); > if (fp =3D=3D NULL) { > -- Acked-by: Konstantin Ananyev > 1.9.5.msysgit.1