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 76CCDA00BE; Wed, 29 Apr 2020 13:38:56 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 100111DA61; Wed, 29 Apr 2020 13:38:56 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id A3BB41DA57 for ; Wed, 29 Apr 2020 13:38:54 +0200 (CEST) IronPort-SDR: JqkANuUbOxtcRv+HSRw/gX/3m7LM2/TfXWFL3r7cXgxMCnVaNlL3c3rPET3ap0T6CFQwmmHSNp xICa72aC3lWQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Apr 2020 04:38:53 -0700 IronPort-SDR: LD8rNwfcYjJocNeph5edbraGtss1R0IQ2DLVnn2xXghJmZVVzLHC+81aqvj0hcwg0XY26pDgrC aTGDCnOsQcdQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,331,1583222400"; d="scan'208";a="336933431" Received: from orsmsx101.amr.corp.intel.com ([10.22.225.128]) by orsmga001.jf.intel.com with ESMTP; 29 Apr 2020 04:38:53 -0700 Received: from orsmsx154.amr.corp.intel.com (10.22.226.12) by ORSMSX101.amr.corp.intel.com (10.22.225.128) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 29 Apr 2020 04:38:52 -0700 Received: from ORSEDG002.ED.cps.intel.com (10.7.248.5) by ORSMSX154.amr.corp.intel.com (10.22.226.12) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 29 Apr 2020 04:38:52 -0700 Received: from NAM02-BL2-obe.outbound.protection.outlook.com (104.47.38.50) by edgegateway.intel.com (134.134.137.101) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 29 Apr 2020 04:38:52 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=K5qhrdRD8n7mJLtqatE08MofAQXeNSUQ/P85yyHFYKebHMNT9OWdFoA68L6Jk5aOUFRJQoE+SBXWIJGM+G0iOvRxBXyZUI/L2qPnwyyB6wIf6YaQjCnVYyHYNJfO2Qr0aOqMZ62MptUldRdVaYstCIixGGlF1Ey4MjAe/64/Oyfp0I6Vfv0d1A9pQqqtRV9JPHoAHUyrzOHlL7tFwAiJidVYhlH8U8PITvBiQzzDNt2UElkAUFQkIBoIhXUda3ClEobneYw5q4bnLKEBTJNhbN/tHLIwX5YFx++V9tBWX8n4j1mLzDaXYIOTQPc0xayv2CDZQ2K+9qA4LFyAhga/8w== 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=iY26e+NPG5kobbMKnn2TrNiuiEubzVZKIXMRQjXcEFA=; b=mztUwW8HU8X6eE50gZS7/dCSiFb4T7oYQj3iwaNyCkPhtIPrr+2t+dPaMst3NxAUMHDbH2CZseCDHje9f4IjxD5l7RJZD5hve/d2OQKU07b9q65O1/GHRxujIpCsoobjeR6trsvXSL1NJMP68SmY0nScVjMpY1o9z8yMEh8NXDaMGukR4JonOdUtg3DDQa3L+lMs55PWZFrTAPRIGfAqzjlkQMcJpojEKBb6Daj+wV3z1dGDKfNuvbMDVw9Y7KGfWGGMypHwGdRrZAvKc9DBP3CmRg8q1JyGzeqR/MoqaNwBQpFF51zw4oqmalW3Oz7YfGNbHBhRNOrm+peD+9RTkA== 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=iY26e+NPG5kobbMKnn2TrNiuiEubzVZKIXMRQjXcEFA=; b=YVDZnKvyUnZoBt6Q+No1p9l0svt3vuds3cIiqPwT7dNINU+adS3hnOu47wbBmcJT/1bf3zo55uhau0tfVmfRcYAROKS5krPAh/F3v3yi1UHcxKD/fG3KqvJWPdFsIjog7V9WEFi6efC0DMV4q6MwW2lM+VIvO3UxOcZ9C4q0Md0= Received: from BYAPR11MB3301.namprd11.prod.outlook.com (2603:10b6:a03:7f::26) by BYAPR11MB2710.namprd11.prod.outlook.com (2603:10b6:a02:c7::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.22; Wed, 29 Apr 2020 11:38:50 +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.023; Wed, 29 Apr 2020 11:38:50 +0000 From: "Ananyev, Konstantin" To: Pu Xu <583493798@qq.com> CC: "dev@dpdk.org" Thread-Topic: [PATCH] ipv4_fragmentation: fix fragmentation of ipv4 packet with optional header Thread-Index: AQHWHIxkL7GeKhoH0kaQEBs/OeSBVaiP+BJg Date: Wed, 29 Apr 2020 11:38:50 +0000 Message-ID: References: <20200427120618.84166-1-583493798@qq.com> In-Reply-To: <20200427120618.84166-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.165] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: a953266a-5378-4b12-9269-08d7ec31e362 x-ms-traffictypediagnostic: BYAPR11MB2710: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-forefront-prvs: 03883BD916 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)(136003)(396003)(39860400002)(6916009)(33656002)(186003)(2906002)(26005)(8936002)(478600001)(71200400001)(966005)(9686003)(6506007)(5660300002)(7696005)(66446008)(64756008)(316002)(52536014)(66476007)(76116006)(66946007)(86362001)(66556008)(4326008)(66574012)(55016002)(8676002); DIR:OUT; SFP:1102; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: lSgxLiInVBjSxsFMR0KtdqRQcWcTTOcxnVI9nOVeajDC1EMmSIl0be2UDDWxw+7ZHdfLAoF06zhQpBxhFHgBOhwTfxVxA2MOVeQbk0pkVzUoa6sBx0oZI48wTd3mdt/lWWEwEVVylh1XdDZXOFpM25en8L4I7u+NYlMUMzWCMfhVNh/2MDMDEg5AWtx6oLTTU3QNKqu8cL7cHwFEwoPTqAgOU0G1Fi8m5xRvPPZN1IqbjxEoE5rlrhTxWpCKJm/7YeA8/AdQDoSohGBEOwywbFANKkSDYZgUORCggIqpNO4K9JBcCXOQntcS0h4KWZ2yVD3U0xmm2ZYVdXErnjtaVBo0nn1eFXKM30o44ri4na2u9LjJe8dWmzLCLc0PZJFURxM67wPf6kzLAM3n1G9eTWA5q1GslmUdqgJpKc8TrX4awimq4vvKBLCP+3cpUF3DcKap0byn+GshHr6bcIlSZq79npKORQVPBqpzxnyWA1Kl/W9M57i49jJW29jDD4NRSF4iFasIf+4svYpIGF2GuA== x-ms-exchange-antispam-messagedata: Jup3YPyRtZt6Qkz90Rpxcjy69NSpfUsag+TTRK3wpY8opUHh69zISumyuQBzAOnccaxcbTs9NxM6l+X1DHPQLy4wikxfNDQjO5rHiT2Jg1PuPueTIC6KJvIHTqHJNvi/ZgEV/SgKCho3NcRZYc1XZbcu3NdfmA3UOelAHrMlmY8RsNA+f4K0neq4Ift7FyR1GfN71CQVFGKBI0dpXvvTMucJ0Uvf37nAz7B2Mlw3Alz+QQxpcxJ8wBUO3nVNwEgZ2yaVPeEAlx420lE+h0boyl7e+0YUutskGzqQhzupeqxbA4o3t3IQoGJSeQk6YPK5a/cyH8uty0BvTmsI2MVBNl5dQSUY7kLhHmWwfBPwp5+p3TIrzLdxYdXWPuDfiE1s38hGiFcDkvCwPpoU0V2dyu1FrD2ItY/imFcsMM8TC8wMkOX+rtYK1A9wocsi9XtJn04W574snXBNJrGlCalSJhyFB9NzYTYTlalKf+0baf9w3QT6/rEMs3nD5xcaDRYTRklnUNKpPtPZ5qcwcE/nO2BhtnGqcBrPeuEyBufIHds3u/qIVG612Vh4OkoC5EIh2YZouQnDCgn8MT7/HGfBFMLFoguyYMibSEXK9UWU84DFJ1z0NFGRT/8InMOZ0arx+ziijLKkX4gFJd032FQMBtYJCiXSI6bSitzYJEBlBGE2I3nK0LwZvYT7igJ0vzNJB5inaMaxdzA/X6h3CN3gvH+T/EBX5GVs/C64fA28Y3SsZaDdMlri15eYUKUzWX0T6RF7us3qBUtx59chkeIlpHCEjORzLFSzuwoTuF4VypP8Gg5Rr3UCfSR+miQEdvyE 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: a953266a-5378-4b12-9269-08d7ec31e362 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Apr 2020 11:38:50.7785 (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: ELSs8Hr1ug8WjA9lcfRQGz+N8+Ye5jtizz0LCYkyUhlN4jCauwk+QtHQ06UcBtgS+X/bm4B6B3h5cUgB8kOQkCPNZrtxeeB6P3KW/kPqYgg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB2710 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH] ipv4_fragmentation: fix fragmentation of ipv4 packet with optional header 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, First of all - if it is a fix, then we need to have: Fixes: ... And probably=20 Cc: stable@dpdk.org As described here: https://doc.dpdk.org/guides/contributing/patches.html=20 Second it would be good to add some text here -=20 problem statement and solution description. >=20 > Signed-off-by: Pu Xu <583493798@qq.com> > --- > lib/librte_ip_frag/rte_ipv4_fragmentation.c | 20 +++++++++++--------- > 1 file changed, 11 insertions(+), 9 deletions(-) >=20 > diff --git a/lib/librte_ip_frag/rte_ipv4_fragmentation.c b/lib/librte_ip_= frag/rte_ipv4_fragmentation.c > index e9de335ae..156087ca3 100644 > --- a/lib/librte_ip_frag/rte_ipv4_fragmentation.c > +++ b/lib/librte_ip_frag/rte_ipv4_fragmentation.c > @@ -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,16 @@ 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 & 0xf) * 4; We do have a special define for that in librte_net/rte_ip.h: ** Internet header length mask for version_ihl field */ #define RTE_IPV4_HDR_IHL_MASK (0x0f) /** * Internet header length field multiplier (IHL field specifies overall hea= der * length in number of 4-byte words) */ #define RTE_IPV4_IHL_MULTIPLIER (4) Please use them in the code above. Also as now we are getting header_len from the packet itself, It would be good to check that it contains a valid value. Otherwise ill-formed ip-header can crash dpdk app. > /* > * 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 +104,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 +126,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; > @@ -181,9 +183,9 @@ rte_ipv4_fragment_packet(struct rte_mbuf *pkt_in, > flag_offset, fragment_offset, more_in_segs); I think we have to update __fill_ipv4hdr_frag() too, otherwise options from original header wouldn't be copied into the new header. >=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.20.1