From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 535A6A0547; Thu, 28 Oct 2021 14:25:03 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 13B6E41100; Thu, 28 Oct 2021 14:25:03 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mails.dpdk.org (Postfix) with ESMTP id 5A70640DF4 for ; Thu, 28 Oct 2021 14:25:01 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10150"; a="316596610" X-IronPort-AV: E=Sophos;i="5.87,189,1631602800"; d="scan'208";a="316596610" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Oct 2021 05:25:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,189,1631602800"; d="scan'208";a="447947815" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga003.jf.intel.com with ESMTP; 28 Oct 2021 05:24:59 -0700 Received: from orsmsx605.amr.corp.intel.com (10.22.229.18) 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.2242.12; Thu, 28 Oct 2021 05:24:59 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) 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.2242.12 via Frontend Transport; Thu, 28 Oct 2021 05:24:59 -0700 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (104.47.58.100) 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.2242.12; Thu, 28 Oct 2021 05:24:59 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CoBQVlh3f9GQw4WmglR6pC6HLH2hCDuHm7JabaO/F9Rxs7n5yc0+RofK5sbo5Xa0AWBP2QHh8Roh6HMMgak11R5B5+o3O0Fccmp3hobm7CP0YPCN/uloEKY0SeNdBO5GQT0zzz9dABQy4raLhRy1QkE3nL4oPL/mAZ7UK19o/MOxQFOUKVFLCbk6vl2sBKdDzrEGXw+DbDIa4xTaP/T2jRjUHLX/bsVKrBrsBS8qvRta3qaCDfAmIfbPNjil62flLbZTdN4st65N8aYFG6s0Sy9S7YEbzTMurycsmzl5KU4B44ehW9MTG3t5IT6Kz3wgSBUo/PbdsGXp5FlUAaRMwA== 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=/9x8JpBv2HzxlQt+j4H/G0lrgeDpsbNqfWmM+7oe3bc=; b=jPCuK5Lk1gMJ6KTEujMzURf0UTDu7P8RgzVoDJ0pLj8woLxLfulcoDU8li0Y8lV+bZMbHkdTpzGaTtADvJpiMhIcD5GEsapjQ8fbaCAqcgfw1G6eVeFGJCBIR0wVgHWjwV6kFft5xf75wR2GGEsPrz9VSZtWe2wJg6573TpcY0yvxQftreqC1g4SzWueVvWL6sBGoOJrWc4Xj9ix91mxu7k9M8SsCDaH7L6aRZPpSz318w7RRA+1TmLU7mjD/KLPYVJaxZoRkilxxuLZWWUg8YmAd1JaH5wrrXVTBUifyJAdtaizyQguwtpuqyODdZE/Lv4E2/5fdwzoxtU03mHfGw== 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=/9x8JpBv2HzxlQt+j4H/G0lrgeDpsbNqfWmM+7oe3bc=; b=Vw7vbezYfuSZZuhz0fq0pyyP8tde5Mpuol/VQ258HdOWHklfduxj6lslkWp6KgLzIM34n/CqrgST+J1Xh0n8NKOl9l0sp3eTnAdQ5Co1LGLibFl/29B1YhVDfOCiedmAYBKJX80u3PK9L+7LlV+vGrzIB+BPpO7lGraAofOf/Eg= Received: from DM6PR11MB4491.namprd11.prod.outlook.com (2603:10b6:5:204::19) by DM6PR11MB3386.namprd11.prod.outlook.com (2603:10b6:5:5c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4628.20; Thu, 28 Oct 2021 12:24:58 +0000 Received: from DM6PR11MB4491.namprd11.prod.outlook.com ([fe80::2c0c:5383:f814:3b4e]) by DM6PR11MB4491.namprd11.prod.outlook.com ([fe80::2c0c:5383:f814:3b4e%6]) with mapi id 15.20.4649.015; Thu, 28 Oct 2021 12:24:58 +0000 From: "Ananyev, Konstantin" To: huichao cai , "dev@dpdk.org" Thread-Topic: [PATCH] test/ipfrag: add test content to the test unit Thread-Index: AQHXyXZM9GZ+qC3f80aWVtgZnn0CjKvoWp9g Date: Thu, 28 Oct 2021 12:24:58 +0000 Message-ID: References: <1635148739-61415-1-git-send-email-chcchc88@163.com> In-Reply-To: <1635148739-61415-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: 163.com; dkim=none (message not signed) header.d=none;163.com; dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 0f8c9cf3-334a-4ae3-6670-08d99a0df4e7 x-ms-traffictypediagnostic: DM6PR11MB3386: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:608; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: jwH0lAga9sez/DXVfNPWoWhPnTI5JSe37gLmz9oSsEz4w2O5uWayeHq/B1SwyUvR8E9JrG4RhmD+TXDYrxeRYCxXI8HLZ4k242I1WXfUDdLo+VI6PhxbBrSiMP4tU2dxN0YnEbW2IBPoZSMYOi+slb0dF1wsglEHYG6vy4C3/HUczFEN4cdnYffVV247jfDZPBxFMMCCD2A3SxsEpNAUZO2HsBR1+UteT2oNoF7z5zQEt8pMYqEkoYbdF9FUT1Id7oAddDLV4b5YY0Opk2EqgpQWJ9is2RnXR7RnLKGAeDkty4sA9aL5oa/eogTeYhNh9+TuyA26yJmnwg3u/Pb/5GXW7ZFb2RQcmHY4YA9Oyo5ZvqTvS4rzANrbEC306gry9x2OmaCCtA5D19Kf1rzh2CPg9nJXUw+V80s4vg5Kc6oxA9MOZgyWRHrPRYfyA1wCsGXS5mEtZAM1f+zZvBbhwrMLA1ke2ZjekvWeVXqkE50SCttynmmmp6UrkhhD8t2sW4X3q4yI/fpkmktE1l2T4aOkgUwwfe3+GGHjSh6eV60EMHprgUF7QGmBHwpnrmFXExsK2r01JS6qdyom7OkM7+v8jQJK2DcS2OG2HJII8ppE6vbhTvdpK3IlgNb81aSqOQ7CB2bjEuJNdO5jBGfQ2bAIw8ZDC9aSKM+EVpcnepiC+91NV3SiYctcUtNt4pMlMtQO0GeKol/dUiCHcMMLGw== 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:(366004)(8676002)(186003)(9686003)(33656002)(71200400001)(8936002)(122000001)(110136005)(5660300002)(55016002)(66446008)(508600001)(66946007)(52536014)(66476007)(38070700005)(316002)(26005)(76116006)(86362001)(66556008)(7696005)(82960400001)(2906002)(6506007)(55236004)(83380400001)(64756008)(38100700002); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?RyEmt3hK/SbiN72Q/Rr1Fs9EWiq2Mklz1JbPcn8ckr/kMe0MTE8iC5FKd3pX?= =?us-ascii?Q?LvJqfyb3Z0+J/mJ4Tya0/5xja4GsDhDlFPXpOrY1LIehHFTs+2gZ1fcbvg2c?= =?us-ascii?Q?fKaIvRDi342uVal/UXt6dofGL0o3Rh4tlMoPzEP6fPaU7Cr7BiH9L2n8NurI?= =?us-ascii?Q?0DwsQ80afD2DZ+/bmw2GHrJAowl3lVg8mN7AeJTgnjxs/rnRZAJFVjt/dg6j?= =?us-ascii?Q?4zLp6l6n2WZPKVLM4iQUjwoO1nwsh5N6kFM7KFHMTUNoJ6EZr4g6OT+qibtq?= =?us-ascii?Q?IrkcsabZgj+fKRao0morSSwBP5U+f7WM50EpuJyv31U0CRtpDoISYwypCVtU?= =?us-ascii?Q?ZNjcblcYy/+db+mY3ktsgDA6D3TrwAlLC45GmdPOGq44wich9fjue3dgKeQD?= =?us-ascii?Q?JhEWIbQthw7wSey3arHivAMUZ7/gyMn93lSA9LdBgHi4lKjut8wGTiBHlquO?= =?us-ascii?Q?Ry+xbyADz2OkvLNXrRTScemaBKaV92Nn/Pe80NFz/Bf+9qs/s8A6QBrtBc6+?= =?us-ascii?Q?23j4CIWp28DivXyueRLKMEsZkO7ZIuRywYIZZihRzCb7ApkYQO6PjkUb/V+R?= =?us-ascii?Q?57jyg/pNxI7XUrCRLO/dBh+glpEgp1b98lLzaoif5qorrgVVRHaRzWrYNosE?= =?us-ascii?Q?qqBfujgr0rlu9qq0lpz/7BQBOLQgPHde4BcZKkw2zRs4G45ukH5EKs2bx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Q2yzZPVQ57C8r8dnzjVo?= =?us-ascii?Q?TXZNS2WQubXCp63i5r3Cm5FqtXsbqud8dG2EG5hUiH4FVNcszcqT3wxR+jRt?= =?us-ascii?Q?0eOdUQ=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: 0f8c9cf3-334a-4ae3-6670-08d99a0df4e7 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Oct 2021 12:24:58.2874 (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: 3pNzNy6MrT32PHOmIvCZarbuTkpPC/TJ3l92gMyhbm8oV86nhd261nFG52wkrR3Wf5us+w/iMjOlEI3cds2of7BN/8PQmRvKecxISBTnFrU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR11MB3386 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH] test/ipfrag: add test content to the test unit 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 Sender: "dev" > Add the test content of the fragment_offset(offset and MF) > to the test_ip_frag function. Add test data for a fragment > that is not the last fragment. >=20 > Signed-off-by: huichao cai > --- > app/test/test_ipfrag.c | 95 +++++++++++++++++++++++++++++++++++++++++---= ------ > 1 file changed, 79 insertions(+), 16 deletions(-) >=20 > diff --git a/app/test/test_ipfrag.c b/app/test/test_ipfrag.c > index da8c212..1ced25a 100644 > --- a/app/test/test_ipfrag.c > +++ b/app/test/test_ipfrag.c > @@ -89,12 +89,14 @@ static void ut_teardown(void) > } >=20 > static void > -v4_allocate_packet_of(struct rte_mbuf *b, int fill, size_t s, int df, > +v4_allocate_packet_of(struct rte_mbuf *b, int fill, > + size_t s, int df, uint8_t mf, uint16_t off, > uint8_t ttl, uint8_t proto, uint16_t pktid) > { > /* Create a packet, 2k bytes long */ > b->data_off =3D 0; > char *data =3D rte_pktmbuf_mtod(b, char *); > + rte_be16_t fragment_offset =3D 0; /**< fragmentation offset */ >=20 > memset(data, fill, sizeof(struct rte_ipv4_hdr) + s); >=20 > @@ -106,9 +108,17 @@ static void ut_teardown(void) > b->data_len =3D b->pkt_len; > hdr->total_length =3D rte_cpu_to_be_16(b->pkt_len); > hdr->packet_id =3D rte_cpu_to_be_16(pktid); > - hdr->fragment_offset =3D 0; > + > if (df) > - hdr->fragment_offset =3D rte_cpu_to_be_16(0x4000); > + fragment_offset |=3D 0x4000; > + > + if (mf) > + fragment_offset |=3D 0x2000; > + > + if (off) > + fragment_offset |=3D off; > + > + hdr->fragment_offset =3D rte_cpu_to_be_16(fragment_offset); >=20 > if (!ttl) > ttl =3D 64; /* default to 64 */ > @@ -155,38 +165,73 @@ static void ut_teardown(void) > rte_pktmbuf_free(mb[i]); > } >=20 > +static inline void > +test_get_offset(struct rte_mbuf **mb, int32_t len, > + uint16_t *offset, int ipv) > +{ > + int32_t i; > + > + for (i =3D 0; i < len; i++) { > + if (ipv =3D=3D 4) { > + struct rte_ipv4_hdr *iph =3D > + rte_pktmbuf_mtod(mb[i], struct rte_ipv4_hdr *); > + offset[i] =3D iph->fragment_offset; > + } else if (ipv =3D=3D 6) { > + struct ipv6_extension_fragment *fh =3D > + rte_pktmbuf_mtod_offset( > + mb[i], > + struct ipv6_extension_fragment *, > + sizeof(struct rte_ipv6_hdr)); > + offset[i] =3D fh->frag_data; > + } > + } > +} > + > static int > test_ip_frag(void) > { > static const uint16_t RND_ID =3D UINT16_MAX; > int result =3D TEST_SUCCESS; > - size_t i; > + size_t i, j; >=20 > struct test_ip_frags { > int ipv; > size_t mtu_size; > size_t pkt_size; > int set_df; > + uint8_t set_mf; > + uint16_t set_of; > uint8_t ttl; > uint8_t proto; > uint16_t pkt_id; > int expected_frags; > + uint16_t expected_fragment_offset[BURST]; > } tests[] =3D { > - {4, 1280, 1400, 0, 64, IPPROTO_ICMP, RND_ID, 2}, > - {4, 1280, 1400, 0, 64, IPPROTO_ICMP, 0, 2}, > - {4, 600, 1400, 0, 64, IPPROTO_ICMP, RND_ID, 3}, > - {4, 4, 1400, 0, 64, IPPROTO_ICMP, RND_ID, -EINVAL}, > - {4, 600, 1400, 1, 64, IPPROTO_ICMP, RND_ID, -ENOTSUP}, > - {4, 600, 1400, 0, 0, IPPROTO_ICMP, RND_ID, 3}, > - > - {6, 1280, 1400, 0, 64, IPPROTO_ICMP, RND_ID, 2}, > - {6, 1300, 1400, 0, 64, IPPROTO_ICMP, RND_ID, 2}, > - {6, 4, 1400, 0, 64, IPPROTO_ICMP, RND_ID, -EINVAL}, > - {6, 1300, 1400, 0, 0, IPPROTO_ICMP, RND_ID, 2}, > + {4, 1280, 1400, 0, 0, 0, 64, IPPROTO_ICMP, RND_ID, 2, > + {0x2000, 0x009D}}, > + {4, 1280, 1400, 0, 0, 0, 64, IPPROTO_ICMP, 0, 2, > + {0x2000, 0x009D}}, > + {4, 600, 1400, 0, 0, 0, 64, IPPROTO_ICMP, RND_ID, 3, > + {0x2000, 0x2048, 0x0090}}, > + {4, 4, 1400, 0, 0, 0, 64, IPPROTO_ICMP, RND_ID, -EINVAL}, > + {4, 600, 1400, 1, 0, 0, 64, IPPROTO_ICMP, RND_ID, -ENOTSUP}, > + {4, 600, 1400, 0, 0, 0, 0, IPPROTO_ICMP, RND_ID, 3, > + {0x2000, 0x2048, 0x0090}}, > + {4, 68, 104, 0, 1, 13, 0, IPPROTO_ICMP, RND_ID, 3, > + {0x200D, 0x2013, 0x2019}}, > + > + {6, 1280, 1400, 0, 0, 0, 64, IPPROTO_ICMP, RND_ID, 2, > + {0x0001, 0x04D0}}, > + {6, 1300, 1400, 0, 0, 0, 64, IPPROTO_ICMP, RND_ID, 2, > + {0x0001, 0x04E0}}, > + {6, 4, 1400, 0, 0, 0, 64, IPPROTO_ICMP, RND_ID, -EINVAL}, > + {6, 1300, 1400, 0, 0, 0, 0, IPPROTO_ICMP, RND_ID, 2, > + {0x0001, 0x04E0}}, > }; >=20 > for (i =3D 0; i < RTE_DIM(tests); i++) { > int32_t len =3D 0; > + uint16_t fragment_offset[BURST]; > uint16_t pktid =3D tests[i].pkt_id; > struct rte_mbuf *pkts_out[BURST]; > struct rte_mbuf *b =3D rte_pktmbuf_alloc(pkt_pool); > @@ -201,6 +246,8 @@ static void ut_teardown(void) > v4_allocate_packet_of(b, 0x41414141, > tests[i].pkt_size, > tests[i].set_df, > + tests[i].set_mf, > + tests[i].set_of, > tests[i].ttl, > tests[i].proto, > pktid); > @@ -225,14 +272,30 @@ static void ut_teardown(void) >=20 > rte_pktmbuf_free(b); >=20 > - if (len > 0) > + if (len > 0) { > + test_get_offset(pkts_out, len, > + fragment_offset, tests[i].ipv); > test_free_fragments(pkts_out, len); > + } >=20 > printf("%zd: checking %d with %d\n", i, len, > tests[i].expected_frags); > RTE_TEST_ASSERT_EQUAL(len, tests[i].expected_frags, > "Failed case %zd.\n", i); >=20 > + if (len > 0) { > + for (j =3D 0; j < (size_t)len; j++) { > + printf("%zd-%zd: checking %d with %d\n", > + i, j, fragment_offset[j], > + rte_cpu_to_be_16( > + tests[i].expected_fragment_offset[j])); > + RTE_TEST_ASSERT_EQUAL(fragment_offset[j], > + rte_cpu_to_be_16( > + tests[i].expected_fragment_offset[j]), > + "Failed case %zd.\n", i); > + } > + } > + > } >=20 > return result; > -- > 1.8.3.1 >=20 Acked-by: Konstantin Ananyev