From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0DD9C433F5 for ; Fri, 18 Feb 2022 19:05:00 +0000 (UTC) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D38D64014E; Fri, 18 Feb 2022 20:04:59 +0100 (CET) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 3EF0C40141 for ; Fri, 18 Feb 2022 20:04:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645211098; x=1676747098; h=from:to:subject:date:message-id:references:in-reply-to: content-transfer-encoding:mime-version; bh=WqVRkd+9tWl6CTMPxaypkQjiz5BhmcbFLPnDer/K44o=; b=ds1wDHIT+16+IKeFFwwOQu+sd2vFmMRoIg/NAGn1uG53s7zq9bof+qVc Y7sO6iVUhBNJx7Cg/l21RqZ/kXDkBxlJ81oYKXdznuSpnUYDtfv5nGDId NSIEGKkFFhdoerO/SpITqMwf6YrwE9VVKexx9w0CHRqgRPgkSk0jLFQer DpTFaTUhOCDcIgFzjFc3gwJAasVX+Ts/Fk7FfJkREFKUejWSrw4x6Xi6r W2kd0CtfSx81C1TrJ8G+iQakWrb5s2J4fZEVwlyEavBQBnfwV+w417iog OfRUUy9l7txSSV5CSAWjh9kAW497WBjcwb8Dz7Sc+y1H25buccZIep3yw w==; X-IronPort-AV: E=McAfee;i="6200,9189,10262"; a="311933535" X-IronPort-AV: E=Sophos;i="5.88,379,1635231600"; d="scan'208";a="311933535" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Feb 2022 11:04:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,379,1635231600"; d="scan'208";a="778094691" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmsmga005.fm.intel.com with ESMTP; 18 Feb 2022 11:04:56 -0800 Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) 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.2308.20; Fri, 18 Feb 2022 11:04:55 -0800 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX608.amr.corp.intel.com (10.22.229.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Fri, 18 Feb 2022 11:04:55 -0800 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20 via Frontend Transport; Fri, 18 Feb 2022 11:04:55 -0800 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.103) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.20; Fri, 18 Feb 2022 11:04:55 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jwQhr0WT9rf7Yzo/PP42/PtmUzOo6uI3iRzc5mZlNOmCq3kpluI3UbsY//wDKRqcQWp51A8ErXqBJJlKsjwyOhiQGNEm7l+rUEyzXTvFgpVuFfC7xmGKC7l+Q3w7VuIDgviGKyHMCSKYwE1rctMhul709CU1DLTIOLEp494ucGUFlOvBDQIXntffdk+rPmzQIcWlyr86B4op6EwMwBTNRHRy+F6/AqiLMA0ohZ3Ome38YGWUOqFNIFNOgoxwKk6ORYN4XGqwPuok5Acb50uPkwBwFFouyUWbryT8S2P7KiLVOALjhn32lpGfG0ihHhDDXPu6vSYT+/X98tt9OMmx1w== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+v3pGhwHEAPX5DfZ/AwZbpfJ3fVbH/c1bKCpSQk9g7U=; b=CrhC8hypZ8IsmSdiMoYyMLSyxVqbvAEvRDs37e0aRBlB1F0fOuTCB9YfHVDs/SCdWradAI35ELoxj/94j5FypG5w1SKaaWc61alcoB9aR0IBIhB/twt3hI+f+1aOatfTyp3GPId6qgYTKBqPmr8tSM3ySkNfFu7MIPPvAVlZzgRV4s2VJ3524vHq6mbyI2yDLA9ECZiAT0Tg0SkUIMEFDqmZVu0RvVCmP8YSJElFEJl/sW0VT1xjJvhHxhw4BzvsYvE0oZM2O0/v4/pw3fHiARNwy8e0Htehf2rUZupBYVt/XHxlHalK4x6CXaMTx136HZen+DRXo5Vlk7zzL5VkHA== 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 Received: from DM6PR11MB4491.namprd11.prod.outlook.com (2603:10b6:5:204::19) by BYAPR11MB3125.namprd11.prod.outlook.com (2603:10b6:a03:8e::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4995.16; Fri, 18 Feb 2022 19:04:52 +0000 Received: from DM6PR11MB4491.namprd11.prod.outlook.com ([fe80::8ccc:ed65:78fa:1b07]) by DM6PR11MB4491.namprd11.prod.outlook.com ([fe80::8ccc:ed65:78fa:1b07%4]) with mapi id 15.20.4995.022; Fri, 18 Feb 2022 19:04:52 +0000 From: "Ananyev, Konstantin" To: Huichao Cai , "dev@dpdk.org" Subject: RE: [PATCH v2] ip_frag: add IPv4 options fragment and test data Thread-Topic: [PATCH v2] ip_frag: add IPv4 options fragment and test data Thread-Index: AQHYIkk/ZQei/Xs0jE6RscQWgHDMmayZrhNA Date: Fri, 18 Feb 2022 19:04:52 +0000 Message-ID: References: <1637743626-70632-1-git-send-email-chcchc88@163.com> <1644915055-38172-1-git-send-email-chcchc88@163.com> In-Reply-To: <1644915055-38172-1-git-send-email-chcchc88@163.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.6.200.16 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: fe899628-d5b7-40ca-b15d-08d9f3118b41 x-ms-traffictypediagnostic: BYAPR11MB3125:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8273; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 38d1ZVeYE0QHAkflnX73yQBYpz7k/lxsKsSq5LZTZrQXR8/9oT7aVRKc+xHH8V8plwvFCX8TQIQdMZHpQLganoTKHzteM4msSmdg3AoOxeKH8SuHPbVMiLh+B0At9yE6/nFtWhHVPR0HBfknlsfj3VjkJPEFx64r0nR9q2Nuh6R2GRRlIfflwZ7iM2x1S7i3PLFrD/sfN6QtDMMR39Bsg604OYpGiYg6++XATDfKVsGXpYuuMp4c+sM9Vlyoqflt+ayOeZ65tRotX6oH+9Hs3Moq9ad37SqctIiqhSCWud03lF+qHcp8tvCc1fRoafu0DIsGaoN+8H8bg2VVAzRkXvI5jnjdV7+ruszQKsUHEmZdXxdtKnIIE09TpS25bz4pbi3l094dyAJGMpcavtoDlJIQyeeOfGdpH7McmCNzKZo05w1SXvi5SOUvYK6ClLAZyyZUmNpnQKVkZmqmR7AfcMkSnSMwE6a3CmtltHkn8VyvTf50wRhdsQNllMYqEtO05zvh3s8Y4A8gn/gcFB2m1PE70gXeO2mCq6JHLEPGEUg1W+/ePbPRkrZwumeZHLEYWSiM+fvlq7fsg4FQdbQ3Wf05sfo/DyzI0Gf4q7864DNh5Kl4YBU4iQPUYMlfzDIRRIXBpMeGHD3QHsDDlB59Ob3dWw6GQ5RQ9aHZWHbK0c08K7gZRVS+I5cmn52tqND2ARiiuzNLR+b5ixUsuUNeww== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR11MB4491.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(52536014)(110136005)(8936002)(5660300002)(55016003)(66556008)(316002)(86362001)(66946007)(76116006)(8676002)(38070700005)(66476007)(64756008)(66446008)(26005)(9686003)(186003)(2906002)(82960400001)(508600001)(38100700002)(33656002)(122000001)(71200400001)(6506007)(7696005); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?j0EtOA/TtKB3/xc6VYVaPwZRCWZ47h1tY6kJvNdcv0GjmuqLrChcf79+tNyc?= =?us-ascii?Q?9t0zvn4iXfk1bPirg971V96eO1idBmCPr0PHyI5gnBDpQTC4j4IWWF+vx+wL?= =?us-ascii?Q?FTHn4r7PbFxIdVpu033rOeZF5zbSpJGiUhgafLWL69ucsu+fOu2eFAkzmYaL?= =?us-ascii?Q?ufa6MnAodebAywf4kO/QgstqbVaAqQzjOg44CXIDpqKfb9Wra8/vaqKYzjRc?= =?us-ascii?Q?M5MY2PtF0R3IcGXoa8Lab7xVKeVETLAOasoAZ5adYe+98ObOPdn98jvVhHFa?= =?us-ascii?Q?C/0CGkncAxMoK033JFcZns0uYkoSbMIBDo8nH6wgvUqhjUHAI+C3+9dUM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nlEwSwdzUGxPWsioo3wAH98SSplU3YdBGnynE0W/KWR1I0SxD2+ux?= =?us-ascii?Q?jn5JvvNyL8qFOql794I1cDWIT/Br6BSBXsiwsAUrERWpnTfQzjvUZLXqz1IM?= =?us-ascii?Q?2zBQgo/Eqk62HTKkscqlAm6kdNxCrV8s3/jx1EmYvUyJU/mfnasS7C99omYa?= =?us-ascii?Q?b8hcVyW+x1/AbNtEsSd5IHuNlNimZ6FAU3hpix4T+tX6MJl9VP0joiQOyCWE?= =?us-ascii?Q?D41Vn+YryYY0mF5OWka+Vp56jL6ZkhmihYeMHggG1zhoNLo0q2R6QZK10709?= =?us-ascii?Q?3+VRdmt2la0nUrAuajCb3xOv5EfTgIPnqScjNwMM42J7vVqZIa0pxRpf1Ldr?= =?us-ascii?Q?GMOx2Eb+I7XQNVgaKmMTGsCpRpnYvH2ggqo3Sf1Ra0rQ5D4C1D/RiPRErxKo?= =?us-ascii?Q?9Q9kkM/0SDkPAg6Z6mL/Vi7BNsCi9fcgvD1Fbm4ViNTEnJkgGsbvX0KdBypY?= =?us-ascii?Q?kNg4nQ=3D=3D?= 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: DM6PR11MB4491.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: fe899628-d5b7-40ca-b15d-08d9f3118b41 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Feb 2022 19:04:52.3624 (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: vbOSL+FQIr0fr2Lr+YcSNUJhydVXWukDZA1BhrQU/VXheCGv9S18Md3uvK2clRSVWNCK1aUkCS2pt0vWyeNly7C6Hj36bXMekzAhjq6YCk0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB3125 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Hi Huichao, =20 > According to RFC791,the options may appear or not in datagrams. > They must be implemented by all IP modules (host and gateways). > What is optional is their transmission in any particular datagram, > not their implementation.So we have to deal with it during the > fragmenting process.Add some test data for the IPv4 header optional > field fragmenting. >=20 ... > diff --git a/lib/ip_frag/rte_ipv4_fragmentation.c b/lib/ip_frag/rte_ipv4_= fragmentation.c > index 2e7739d..82c070b 100644 > --- a/lib/ip_frag/rte_ipv4_fragmentation.c > +++ b/lib/ip_frag/rte_ipv4_fragmentation.c > @@ -12,6 +12,12 @@ >=20 > #include "ip_frag_common.h" >=20 > +/* IP options */ > +#define RTE_IPOPT_EOL 0 > +#define RTE_IPOPT_NOP 1 > +#define RTE_IPOPT_COPIED(v) ((v) & 0x80) > +#define RTE_IPOPT_MAX_LEN 40 > + > /* Fragment Offset */ > #define RTE_IPV4_HDR_DF_SHIFT 14 > #define RTE_IPV4_HDR_MF_SHIFT 13 > @@ -22,6 +28,8 @@ >=20 > #define IPV4_HDR_FO_ALIGN (1 << RTE_IPV4_HDR_FO_SHIFT) >=20 > +#define RTE_IPV4_HDR_MAX_LEN 60 > + > static inline void __fill_ipv4hdr_frag(struct rte_ipv4_hdr *dst, > const struct rte_ipv4_hdr *src, uint16_t header_len, > uint16_t len, uint16_t fofs, uint16_t dofs, uint32_t mf) > @@ -41,6 +49,58 @@ static inline void __free_fragments(struct rte_mbuf *m= b[], uint32_t num) > rte_pktmbuf_free(mb[i]); > } >=20 > +static inline void __create_ipopt_frag_hdr(uint8_t *iph, > + uint16_t *ipopt_len, uint8_t *ipopt_frag_hdr) > +{ > + uint16_t len =3D *ipopt_len; > + struct rte_ipv4_hdr *iph_opt =3D (struct rte_ipv4_hdr *)ipopt_frag_hdr; > + > + *ipopt_len =3D 0; > + rte_memcpy(ipopt_frag_hdr, iph, sizeof(struct rte_ipv4_hdr)); > + iph_opt->ihl =3D sizeof(struct rte_ipv4_hdr) / RTE_IPV4_IHL_MULTIPLIER; > + ipopt_frag_hdr +=3D sizeof(struct rte_ipv4_hdr); > + > + if (unlikely(len > RTE_IPOPT_MAX_LEN)) > + return; > + > + uint8_t *p_opt =3D iph + sizeof(struct rte_ipv4_hdr); > + > + while (len > 0) { > + if (unlikely(*p_opt =3D=3D RTE_IPOPT_NOP)) { > + len--; > + p_opt++; > +#ifdef RTE_IPOPT_KEEP_IP_HLEN Who will define this macro and when? In general we trying to avoid conditional compilations within DPDK. Can we always use one way or another? As you are doing a copy anyway, probably no harm just completely remove RTE_IPOPT_KEEP_IP_HLEN and related behaviour and copy only options that need to be copied. WDYT? > + ipopt_frag_hdr[(*ipopt_len)++] =3D RTE_IPOPT_NOP; > +#endif > + continue; > + } else if (unlikely(*p_opt =3D=3D RTE_IPOPT_EOL)) > + break; > + > + if (p_opt[1] < 2 || p_opt[1] > len) > + break; > + if (RTE_IPOPT_COPIED(*p_opt)) { > + rte_memcpy(ipopt_frag_hdr + *ipopt_len, > + p_opt, p_opt[1]); > + *ipopt_len +=3D p_opt[1]; > +#ifdef RTE_IPOPT_KEEP_IP_HLEN > + } else { > + memset(ipopt_frag_hdr + *ipopt_len, > + RTE_IPOPT_NOP, p_opt[1]); > + *ipopt_len +=3D p_opt[1]; > +#endif > + } > + > + len -=3D p_opt[1]; > + p_opt +=3D p_opt[1]; > + } > + > + len =3D RTE_ALIGN_CEIL(*ipopt_len, RTE_IPV4_IHL_MULTIPLIER); > + memset(ipopt_frag_hdr + *ipopt_len, > + RTE_IPOPT_EOL, len - *ipopt_len); > + *ipopt_len =3D len; > + iph_opt->ihl +=3D len / RTE_IPV4_IHL_MULTIPLIER; > +} > + > /** > * IPv4 fragmentation. > * > @@ -76,6 +136,8 @@ static inline void __free_fragments(struct rte_mbuf *m= b[], uint32_t num) > uint32_t more_in_segs; > uint16_t fragment_offset, flag_offset, frag_size, header_len; > uint16_t frag_bytes_remaining; > + uint8_t ipopt_frag_hdr[RTE_IPV4_HDR_MAX_LEN]; > + uint16_t ipopt_len; >=20 > /* > * Formal parameter checking. > @@ -117,6 +179,7 @@ static inline void __free_fragments(struct rte_mbuf *= mb[], uint32_t num) > in_seg_data_pos =3D header_len; > out_pkt_pos =3D 0; > fragment_offset =3D 0; > + ipopt_len =3D header_len - sizeof(struct rte_ipv4_hdr); >=20 > more_in_segs =3D 1; > while (likely(more_in_segs)) { > @@ -188,10 +251,26 @@ static inline void __free_fragments(struct rte_mbuf= *mb[], uint32_t num) > (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 - header_len); > + /* Create a separate IP header to handle frag options. */ > + if (unlikely((fragment_offset =3D=3D 0) && > + ((flag_offset & RTE_IPV4_HDR_OFFSET_MASK) =3D=3D 0) && > + (ipopt_len))) { > + __create_ipopt_frag_hdr((uint8_t *)in_hdr, > + &ipopt_len, ipopt_frag_hdr); > + > + fragment_offset =3D (uint16_t)(fragment_offset + > + out_pkt->pkt_len - header_len); >=20 > - out_pkt->l3_len =3D header_len; > + out_pkt->l3_len =3D header_len; > + > + header_len =3D sizeof(struct rte_ipv4_hdr) + ipopt_len; > + in_hdr =3D (struct rte_ipv4_hdr *)ipopt_frag_hdr; > + } else { > + fragment_offset =3D (uint16_t)(fragment_offset + > + out_pkt->pkt_len - header_len); > + > + out_pkt->l3_len =3D header_len; > + } >=20 > /* Write the fragment to the output list */ > pkts_out[out_pkt_pos] =3D out_pkt; > -- > 1.8.3.1