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 A6B2FA04AE; Fri, 1 May 2020 17:32:49 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2ED751DA0A; Fri, 1 May 2020 17:32:49 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id DDBFB1DA08; Fri, 1 May 2020 17:32:46 +0200 (CEST) IronPort-SDR: tAE/AZW7eZbuidGvz79ObotqPFcOZn0idLEXoQ6jvyIENdK27bkselfIKjlNGvi6KZxDN8R+4S KYDWQ+38KdXw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 May 2020 08:32:45 -0700 IronPort-SDR: mM0QPqGez1eJhHXd2iHcLDi50Bc0ybAOoHR7rbxYwZijfX3oqlxaqDx8NoMUmTMIpemAas5Hy6 g9vIcwaTiEig== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,339,1583222400"; d="scan'208";a="276851180" Received: from orsmsx101.amr.corp.intel.com ([10.22.225.128]) by orsmga002.jf.intel.com with ESMTP; 01 May 2020 08:32:45 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX101.amr.corp.intel.com (10.22.225.128) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 1 May 2020 08:32:44 -0700 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Fri, 1 May 2020 08:32:44 -0700 Received: from ORSEDG001.ED.cps.intel.com (10.7.248.4) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Fri, 1 May 2020 08:32:44 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.101) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 1 May 2020 08:32:44 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=al5h8otl8oFwDeirV2uhFWTtXFx3xlFNAhH1Q/RmYkE3AQB+tli8925/4LdOQvboDwUHpEdg5AFRoEk65RmoFmw7aeJqgod3maQwn1hQDY/GCLchzbAL1sJwzi78EINuqHpEWKg7iPHQ1b/vw8tGbMQRFX01zKlAKWiEzUJcf1JMJnBBaKAZYtQ3n1h/QvYf/oTJ/kY8IkuYOmRNcZ4NmszH6iCg94StFiWbaYHy74meUdRaMRN48E8D6xZyGym6HLgK2yVMh8DTcIMfYoiPy0dhqCD9QHLcCKBSM+CtIRt5rDD1G098W29UEQ2zNYFwmdHOyN49/3JPdGiw2/mkLA== 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=dWXmaZ+0kVX8IArMcwdkAkwZtJV2Evj3VrdT9gdlywA=; b=UHdGWygkqMEXQDp64OtAeoOSSwm8jsCMKDwwnR+SAVu9FNPWMvuhPa4MWnHSAcrpQjnjghGaf/pjSPd84J4F2u5L6Hy77Yd8s3cvdF5ZX9zAxr5e+sL5TU9HKE4eYd8+0pQyDRFPtn+5WtFt9Wh7Qmm7sa3JSEDwACOnT3nh3zfexfQI5xcifUyf/vbctVoFPdU2Y3gqqd93Bjj+dfIzSOktuK8ZW0HWhdAaCwU2DoiI667b//4TZnVMVDFwrKfjpRYIqWSEztBacOlydO0XbX45khAwk9WXCVr/1ts7m7MyZvGr2ODUkZYSdBukGmHXFyYaa4X+uGPhPm4MgDLQWA== 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=dWXmaZ+0kVX8IArMcwdkAkwZtJV2Evj3VrdT9gdlywA=; b=v1EpB5iLk77v76wYSIhn+ccPTsA3Rv6eskm7y9vyu52yWwFM0rVF/ZwpcX5zGTW3z2tggkCDfbgAADeKrbFyPhCkUTIQeN2CUIo1MwEuBP+QBz+H5/38elJvtG1MWn0HEmCwj9y6clvH3TOoBSgVu2Pj7p+4vjF3LYIdiZErYBc= Received: from BYAPR11MB3301.namprd11.prod.outlook.com (2603:10b6:a03:7f::26) by BYAPR11MB2854.namprd11.prod.outlook.com (2603:10b6:a02:c9::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.20; Fri, 1 May 2020 15:32:43 +0000 Received: from BYAPR11MB3301.namprd11.prod.outlook.com ([fe80::f8cb:58cd:e958:fff4]) by BYAPR11MB3301.namprd11.prod.outlook.com ([fe80::f8cb:58cd:e958:fff4%6]) with mapi id 15.20.2937.028; Fri, 1 May 2020 15:32:43 +0000 From: "Ananyev, Konstantin" To: Pu Xu <583493798@qq.com> CC: "dev@dpdk.org" , "olivier.matz@6wind.com" , "stable@dpdk.org" Thread-Topic: [PATCH] ip_frag: fix fragmenting ipv4 packet with header option Thread-Index: AQHWH7xlUZf53RAt3Ue6QBGoTAvJeKiTWwlQ Date: Fri, 1 May 2020 15:32:41 +0000 Message-ID: References: <20200501132749.130120-1-583493798@qq.com> In-Reply-To: <20200501132749.130120-1-583493798@qq.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.2.0.6 authentication-results: qq.com; dkim=none (message not signed) header.d=none;qq.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.198.151.188] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7d809206-4b95-4748-02b3-08d7ede4e454 x-ms-traffictypediagnostic: BYAPR11MB2854: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-forefront-prvs: 0390DB4BDA x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: gnsAjGTa+QUPQ7NOeUvWhb+RyFl0sKS2rKxnv5pHfrKPazBbJpANk+clq7pCSf971KYAHnnf2Hxsrl1+grRJf2FTILIRmxASD30ndmPRlGvcHzXPbWIpvcDLU4AcOSvoHsI70begJgNfn4HvIzufLsFKJCl1an+rIO6DU76vy4+4DW9e/A0FSJAL0xDckNce/CmgV4bVv9rbU1iboBvvWs0ZRYIuYNgySyTG3FiPyCWZ/Z4zLau71How0zhDZz78tl1T9TwkgKpysABmkDJr+pXznNf9mYEwzFniaQDxLYnjhsPuSEldcXmQsmsZYEr4uIRhxHpjue3nyF9WPll9cyk7d+iLzHYz4lkhtec9t5XD0M/3OlsYcQPQkKRYmskuA0pZ4b9oBRaQf1hHSimWzWrzYHoZa6VThd/y5U+AO9qFAq2TcJ4kDcOZ2hiPPnm5cI3dYzXAHGONyZIO2uV9KcSg8/fHrhIxscwpgeR4++voI6ynW9WnN/rbHYvWawt+9UCx0OZLk7EufxvkfJmwtA== 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; SFTY:; SFS:(366004)(376002)(346002)(39860400002)(136003)(396003)(64756008)(66946007)(66446008)(66556008)(66476007)(54906003)(76116006)(6506007)(186003)(33656002)(316002)(26005)(86362001)(4326008)(52536014)(8676002)(6916009)(55016002)(966005)(8936002)(9686003)(71200400001)(478600001)(2906002)(5660300002)(7696005); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: EsgTIHj8XheoSQRcbpZhRDRzR/ocY8VN+5D9KGshhMSstkTqpLEML6YajOcBSrTNIKxQxz0ZoXA7srS3FERIEzCPZCmjLGt4/nsuKPIx7V91cTpIM6Yay2LzQ7/ARKl7yTwY6ip8ChKmneYvnpusRtfE6cNc0EvUaIqNcL4Dz5swV2qOnmwlCZBOwtDaUjoYYVUjO0BpwH3JPgxYeMXq1zaKQwwrMNqtPFwPt9SOJ/HrN+WcMiroqtq+LQQMjfDLYZ/p5FQH5nWe548qPq0O994vAUQ507uNv/pUlkkDoYDWKyt1drnHYv6bL67Hu6qjk5HTrqk/Y2Gwab3FPAJhZUPHmXDkhQTvWXuJHya3Q4zITSGPdwcPVAx0dm/H5J22h4zGq9wEhACgCjXzz360ThH6p3jSskaAa5RtU+9ss64d1L068STQ+ZOOC/Nxd5/66FU1xDGvGWj5Nk34+xUM/nU8gm/Xzbfalc4f7Mg1+osDbKndu6cAY4dSfFlzZ4lMgrCTq5c9F0MO1ZJ09vSxbK0io4KpJ9NNXemOJgo+ZJutvR6yeIOnLIoNaJ5qhv5SdddKzsS37XTTorkM3f7O30XR8I3U89et9VKpnhUs9eY7NCdiI8gxE5XIhEFjYl6NzL5RgvDWvKH2U4Qq+7S5OVbcyN85Pmh1VpMXPzeURxjrQaXv0xV0UcdaBSaW3nFqVOEGEERFGrkOmLjbp/T6+Gwso8jqmkXuYkUih3j1TCI94yBSdvM2Sn9g+Tc3eCPI3L9t90lNOEZooH3UmhyyOpuAQCe+l/KhaHxOSUvtki7r9RA8gFSF6Xgzk/fYISeJ 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-Network-Message-Id: 7d809206-4b95-4748-02b3-08d7ede4e454 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 May 2020 15:32:42.9275 (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: fTBI9hArRbDN5XOFv2W2wfYpR6SVSvO2P5wpwdKVq1tuQibhyQ8Jp+7QY8/y2vjtApcKXX4LNVTD2Ko6HhQJiaG8YC+C8Cf8/R0E4m7J2aU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB2854 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH] ip_frag: fix fragmenting ipv4 packet with header option 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, > When fragmenting ipv4 packet, the data offset should be calculated throug= h the ihl field in ip header rather than using sizeof(struct > rte_ipv4_hdr). There are few checkpatch errro/warnings: http://mails.dpdk.org/archives/test-report/2020-May/129803.html please fix. >=20 > Fixes: a7c528e5d71f ("net: add rte prefix to IP structure") AFAIK, this commit didn't change anything in ip_frag code. It was just a mechanic renaming for some public structs. Commit-id that you provided in your previous patch version Seems more relevant. With these things fixed: Acked-by: Konstantin Ananyev > Cc: olivier.matz@6wind.com > Cc: stable@dpdk.org >=20 > Signed-off-by: Pu Xu <583493798@qq.com> > --- > lib/librte_ip_frag/rte_ipv4_fragmentation.c | 33 +++++++++++++-------- > 1 file changed, 20 insertions(+), 13 deletions(-) >=20 > diff --git a/lib/librte_ip_frag/rte_ipv4_fragmentation.c b/lib/librte_ip_= frag/rte_ipv4_fragmentation.c > index e9de335ae..ee0049e09 100644 > --- a/lib/librte_ip_frag/rte_ipv4_fragmentation.c > +++ b/lib/librte_ip_frag/rte_ipv4_fragmentation.c > @@ -23,10 +23,10 @@ > #define IPV4_HDR_FO_ALIGN (1 << RTE_IPV4_HDR_FO_SHIFT) >=20 > static inline void __fill_ipv4hdr_frag(struct rte_ipv4_hdr *dst, > - const struct rte_ipv4_hdr *src, uint16_t len, uint16_t fofs, > - uint16_t dofs, uint32_t mf) > + const struct rte_ipv4_hdr *src, uint16_t header_len, > + uint16_t len, uint16_t fofs, uint16_t dofs, uint32_t mf) > { > - rte_memcpy(dst, src, sizeof(*dst)); > + rte_memcpy(dst, src, header_len); > fofs =3D (uint16_t)(fofs + (dofs >> RTE_IPV4_HDR_FO_SHIFT)); > fofs =3D (uint16_t)(fofs | mf << RTE_IPV4_HDR_MF_SHIFT); > dst->fragment_offset =3D rte_cpu_to_be_16(fofs); > @@ -74,7 +74,7 @@ rte_ipv4_fragment_packet(struct rte_mbuf *pkt_in, > struct rte_ipv4_hdr *in_hdr; > uint32_t out_pkt_pos, in_seg_data_pos; > uint32_t more_in_segs; > - uint16_t fragment_offset, flag_offset, frag_size; > + uint16_t fragment_offset, flag_offset, frag_size, header_len; > uint16_t frag_bytes_remaining; >=20 > /* > @@ -86,14 +86,21 @@ rte_ipv4_fragment_packet(struct rte_mbuf *pkt_in, > unlikely(mtu_size < RTE_ETHER_MIN_MTU)) > return -EINVAL; >=20 > + in_hdr =3D rte_pktmbuf_mtod(pkt_in, struct rte_ipv4_hdr *); > + header_len =3D (in_hdr->version_ihl & RTE_IPV4_HDR_IHL_MASK) * RTE_IPV4= _IHL_MULTIPLIER; > + > + /* Check IP header length */ > + if (unlikely(pkt_in->data_len < header_len) || > + unlikely(mtu_size < header_len)) > + return -EINVAL; > + > /* > * Ensure the IP payload length of all fragments is aligned to a > * multiple of 8 bytes as per RFC791 section 2.3. > */ > - frag_size =3D RTE_ALIGN_FLOOR((mtu_size - sizeof(struct rte_ipv4_hdr)), > + frag_size =3D RTE_ALIGN_FLOOR((mtu_size - header_len), > IPV4_HDR_FO_ALIGN); >=20 > - in_hdr =3D rte_pktmbuf_mtod(pkt_in, struct rte_ipv4_hdr *); > flag_offset =3D rte_cpu_to_be_16(in_hdr->fragment_offset); >=20 > /* If Don't Fragment flag is set */ > @@ -102,11 +109,11 @@ rte_ipv4_fragment_packet(struct rte_mbuf *pkt_in, >=20 > /* Check that pkts_out is big enough to hold all fragments */ > if (unlikely(frag_size * nb_pkts_out < > - (uint16_t)(pkt_in->pkt_len - sizeof(struct rte_ipv4_hdr)))) > + (uint16_t)(pkt_in->pkt_len - header_len))) > return -EINVAL; >=20 > in_seg =3D pkt_in; > - in_seg_data_pos =3D sizeof(struct rte_ipv4_hdr); > + in_seg_data_pos =3D header_len; > out_pkt_pos =3D 0; > fragment_offset =3D 0; >=20 > @@ -124,8 +131,8 @@ rte_ipv4_fragment_packet(struct rte_mbuf *pkt_in, > } >=20 > /* Reserve space for the IP header that will be built later */ > - out_pkt->data_len =3D sizeof(struct rte_ipv4_hdr); > - out_pkt->pkt_len =3D sizeof(struct rte_ipv4_hdr); > + out_pkt->data_len =3D header_len; > + out_pkt->pkt_len =3D header_len; > frag_bytes_remaining =3D frag_size; >=20 > out_seg_prev =3D out_pkt; > @@ -176,14 +183,14 @@ rte_ipv4_fragment_packet(struct rte_mbuf *pkt_in, >=20 > out_hdr =3D rte_pktmbuf_mtod(out_pkt, struct rte_ipv4_hdr *); >=20 > - __fill_ipv4hdr_frag(out_hdr, in_hdr, > + __fill_ipv4hdr_frag(out_hdr, in_hdr, header_len, > (uint16_t)out_pkt->pkt_len, > flag_offset, fragment_offset, more_in_segs); >=20 > fragment_offset =3D (uint16_t)(fragment_offset + > - out_pkt->pkt_len - sizeof(struct rte_ipv4_hdr)); > + out_pkt->pkt_len - header_len); >=20 > - out_pkt->l3_len =3D sizeof(struct rte_ipv4_hdr); > + out_pkt->l3_len =3D header_len; >=20 > /* Write the fragment to the output list */ > pkts_out[out_pkt_pos] =3D out_pkt; > -- > 2.17.0 >=20