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 66B27A04AC; Fri, 1 May 2020 12:59:00 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 09CEA1DA12; Fri, 1 May 2020 12:59:00 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id DCC781D92D for ; Fri, 1 May 2020 12:58:57 +0200 (CEST) IronPort-SDR: /D0oG1K8edt9g6eNHYmJ9Je5Ve2IjZKnDi4yJVR5NpsyWPf081rvxpAd6/jQF8d2lyLoRy/gER nW1x0TppEJnA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 May 2020 03:58:56 -0700 IronPort-SDR: gCXE/Dq47PztlkVkhGSQrdNuUItjTJcM++Er7PCaJRud5PZ45R+zO/yYPumXMTcx3J4K8PzyEw RBShweHiAjqA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,339,1583222400"; d="scan'208";a="368415476" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga001.fm.intel.com with ESMTP; 01 May 2020 03:58:56 -0700 Received: from fmsmsx124.amr.corp.intel.com (10.18.125.39) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 1 May 2020 03:58:56 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx124.amr.corp.intel.com (10.18.125.39) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 1 May 2020 03:58:56 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.169) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Fri, 1 May 2020 03:58:56 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C88CzZ+IJ/zEzRJmLVjldZHGoWp99HVk1p4rwpqdG8BXdODv9WVziqTmagnjpFmd6JZYisrBeaBwOc8VJHsochq9pevmbQX4AnaGxtcEgdNmRm41BPZ+VhO1wXbxnVE3xdc/LNEDSeI65ZGXuS+3jN4wW3co2Eeu0OHIM18u92F3hehW1RAmgtLBgFzFG5it0U95qyBafTu+9E1by6yalUuWYeuozcjb8d2ylhLw9g9c3nVQnwIBnKbib7UwjHiQzDbrzCVcLv3xKJuPSSkMgviVdn2Bwnobk5Eyvn1GDymc+XObuW4pHdmqBSY2RnMcu7PxndXUYBS6Wl7I4OroEw== 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=XWsgbc7pXP9g5pRBuBIL/Lab4hb04NB/36y/PkQsLBI=; b=a3XghE1tiAVTZL/YwncqotAXOmO7GQOdCDKvKngSr//4LsyHaNKjMR5oRM+gSfuEMaDvojRU0EIBL1Gu59x9MrLxnVPQ1D7SbHN/UkU8lwHGr3MizzK39fnmUyahmJ3dmaA0UJNNHd58kEyGzrtR/DTx9ce/F8EEa8PriVoOCY6QoyIk4ooBhDnjt99nLXah5rulCVC9K8OcGgR8D/1PlnJIOmqtM7kVJKMbstGsHm/Xz/KMCCMKbIBQReU/0htsG8EUCYAywV35qjG3BwV39X/VRky742o6AmfkSfO2sLV23pO14dSYHRhgkivpJsR+u47lHR4/ZORc3KXsOiYZBg== 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=XWsgbc7pXP9g5pRBuBIL/Lab4hb04NB/36y/PkQsLBI=; b=k/LpAAZgFmdrSTUO2I5lKj4tMaK6P02um0JNnaBM+Opc0cT8CoLewIM375Ko+EATVx1liW8dHiO4GeFUj5kEh3duQhoLdiVfXMNww3nn165cvGMj5XlzDfjT4wxGlkT/BGL0F6fp560z87sHgnBQQZtFBCfCxc8Z3M70Fhp1xxI= Received: from BYAPR11MB3301.namprd11.prod.outlook.com (2603:10b6:a03:7f::26) by BYAPR11MB3078.namprd11.prod.outlook.com (2603:10b6:a03:87::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.22; Fri, 1 May 2020 10:58:53 +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 10:58:53 +0000 From: "Ananyev, Konstantin" To: Pu Xu <583493798@qq.com> CC: "dev@dpdk.org" , "thomas@monjalon.net" Thread-Topic: [PATCH] ip_frag: fix fragmenting ipv4 packet with header option Thread-Index: AQHWH01FfJj+KpRKNEOmGA4KMhJ9tKiTD4PA Date: Fri, 1 May 2020 10:58:53 +0000 Message-ID: References: <20200501001203.129619-1-583493798@qq.com> In-Reply-To: <20200501001203.129619-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: ab72bf76-6447-485f-cc9f-08d7edbea372 x-ms-traffictypediagnostic: BYAPR11MB3078: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6790; x-forefront-prvs: 0390DB4BDA 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:(39860400002)(376002)(366004)(136003)(396003)(346002)(6506007)(55016002)(966005)(8676002)(478600001)(316002)(54906003)(26005)(7696005)(71200400001)(8936002)(4326008)(9686003)(33656002)(64756008)(66946007)(66556008)(66476007)(66446008)(6916009)(86362001)(186003)(76116006)(2906002)(52536014)(5660300002); DIR:OUT; SFP:1102; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: lic38LElfs8yNOlf5m/9+OR8GZDQB6xggXmEmg6RhEcPZfuXvFoT1iOZmTdzY7dlZ+bgk00EBhFD8iaWXl+iGa74zRMSF0PG5Cy2b8u/47gDYUAnDfXMkCbvg7BqfW5Wd9Z9qmn4RrjW9Orvno5piT3zuRPNIoRaXtcrvnWhb6L1is4eol+F7v/uvOUHBf+8mqvIS7KtORB9/OueJFG5e9nIfbENWIEmAKrQEQDCngitHFNl/RQKLtWWhcjYRjrTXCBGpPAbmDZ1HA8qaPBcSWrHhnb2CDpASTMqnak9HzIguRy/qM25xWB083H8Ye2IzeGHmTYfNcZ2JgQ7CS8FmBpgQgT6DmaZtwdElnsikG7LKSoRXQuiehgq6Bpn09TlXvzZEX3aesGH16ptmd7rqZNwIpqNkraKei/cmgneP3li/aZNFO1Y3wiLvOpEcf+qbq2ChVDKwiCR51dczCa4/awFPSt/ve+Irt2CHiHWEo45KFlOFY3eP/zUwMRsgH/CnOAljhE4jUZWNgk4iS0D7A== x-ms-exchange-antispam-messagedata: 2lUzN6/wfB6sDKlaJdR9+9OzF3dGGEYL/esoo32XWKzc8l16aNzHKYK82ckvucZC2/jCeeJBkpNJTxATm4ubGzED25ZCxzd/5lsQo60SjbYCH38+cYw5V/JlwJ5vWNjy2sVNVJIgGIj9WQYcVcQ7DC3t9eJVRHdVIqpuI6scSz180iriVHlIJDYHXc5SB9VhlZL4J9HHcVu881mdmsUoGtm/DeW3OFSJjsbXqeE5mjFRv8C8Y2uEIkc/l9SPg/yF41sJTZ81INlXQ3fO4i72n0qV8ain8HRrhgQ/l6/CoAvCBW3BvJGYe3htbAZzPtRoJ/a/Tcn0OwtebULdfQyN/47Rhdg32Q+RmbMNafHO6vZQTojsjmeiBATP8YxTM49O+h17nwTNTvH4GqYNWii3Ces/shzbC7e2HROc04Bfa09voRN9wQekSYb3x2Fxerz6phZcGrXP2b5tUPQcqDKDXhuRh+F4czkIHOM8DD78CdFTTwvrWu4K7mCYfbzMqHkWI93SUs+kHoS/8PMLZz3NGuBhRvj8JpGrQh12i/mcs+ip3WdOsOl4YZPCklTzP82ER2LoRfPDz1K7An/mh8QkoRM/OTRP5Jv81sibnc9lsmA6Jc9tiBkZQzT07kfwVofWxd8SeyNLZyBtg4JL9JyFHM16WMKdsvkcS+MMegvF4fvpekrg45F/VhBZAsmeo1f3pvQrfEQZIcmq6krk24oDHjJ678V2bh9Fg7WLc2mFVIJ7yJUG5i1VQ4dDxzWTW/ATFEXj4c5D8mZscXyiZ7HQMZoQOPaCJuWz6EchzK2yVljFMVU5T8NQGgNlpldDLKv1 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: ab72bf76-6447-485f-cc9f-08d7edbea372 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 May 2020 10:58:53.6394 (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: ChzMS5Jeblo/GTp/rAMKa3Eogy0QyrwHkstG99Fge95f61Y0w2qqmR3nC9mwjYpnoIi/jsx8AXhvxLNESSrQnBhhToKjIGcn4/wrH+cDBPo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB3078 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" >=20 > 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). Patch looks good to me... Though by some reason I couldn't find it at DPDK patchwork... http://patches.dpdk.org/project/dpdk/list/ Did you register at dev@dpdk.org? >=20 > Fixes: a7c528e5d71f ("net: add rte prefix to IP structure") > 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