Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/67583/?format=api
https://patches.dpdk.org/api/patches/67583/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/20200401131849.2209336-5-aconole@redhat.com/", "project": { "id": 1, "url": "https://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20200401131849.2209336-5-aconole@redhat.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20200401131849.2209336-5-aconole@redhat.com", "date": "2020-04-01T13:18:49", "name": "[v2,4/4] ipfrag: add unit test case", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "82fd1ab6007b567c1031c14f6daf80cee0cf692e", "submitter": { "id": 332, "url": "https://patches.dpdk.org/api/people/332/?format=api", "name": "Aaron Conole", "email": "aconole@redhat.com" }, "delegate": { "id": 1, "url": "https://patches.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "https://patches.dpdk.org/project/dpdk/patch/20200401131849.2209336-5-aconole@redhat.com/mbox/", "series": [ { "id": 9151, "url": "https://patches.dpdk.org/api/series/9151/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=9151", "date": "2020-04-01T13:18:45", "name": "ip_frag: add a unit test for fragmentation", "version": 2, "mbox": "https://patches.dpdk.org/series/9151/mbox/" } ], "comments": "https://patches.dpdk.org/api/patches/67583/comments/", "check": "fail", "checks": "https://patches.dpdk.org/api/patches/67583/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 4B087A057B;\n\tWed, 1 Apr 2020 15:19:38 +0200 (CEST)", "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 78ECE1BEBA;\n\tWed, 1 Apr 2020 15:19:09 +0200 (CEST)", "from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com\n [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id EDB4E1BEAE\n for <dev@dpdk.org>; Wed, 1 Apr 2020 15:19:07 +0200 (CEST)", "from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com\n [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id\n us-mta-212-mc3DbAulPUqowPTsKni4IA-1; Wed, 01 Apr 2020 09:19:03 -0400", "from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com\n [10.5.11.22])\n (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n (No client certificate requested)\n by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 56A81107ACC7;\n Wed, 1 Apr 2020 13:19:02 +0000 (UTC)", "from dhcp-25.97.bos.redhat.com (ovpn-116-136.phx2.redhat.com\n [10.3.116.136])\n by smtp.corp.redhat.com (Postfix) with ESMTP id CABD810016EB;\n Wed, 1 Apr 2020 13:19:00 +0000 (UTC)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1585747147;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=LTay9qTf5nB2ox3wAIrG+AVCDiEy4VI1pnE/RCTqqRE=;\n b=iEk2W79wlCVwoOLNtwJFigq4vooQsqNy89n71A3zw+WTELGjBDJQJEqCSg676ayg1vLeZA\n xCQ8sHKDbI4sTYhuFXiSeA0iUoSBjctm0b4pMnCiyB9C++GlPSXHT1touW9MQXBdwWzjID\n 8jq3FT3RHIViNuSfj2CXAZCFcWGBBe8=", "X-MC-Unique": "mc3DbAulPUqowPTsKni4IA-1", "From": "Aaron Conole <aconole@redhat.com>", "To": "dev@dpdk.org", "Cc": "Konstantin Ananyev <konstantin.ananyev@intel.com>,\n Sunil Kumar Kori <skori@marvell.com>,\n Allain Legacy <allain.legacy@windriver.com>,\n Anatoly Burakov <anatoly.burakov@intel.com>, Chas Williams <chas3@att.com>,\n Piotr Azarewicz <piotrx.t.azarewicz@intel.com>,\n Bruce Richardson <bruce.richardson@intel.com>,\n David Marchand <david.marchand@redhat.com>", "Date": "Wed, 1 Apr 2020 09:18:49 -0400", "Message-Id": "<20200401131849.2209336-5-aconole@redhat.com>", "In-Reply-To": "<20200401131849.2209336-1-aconole@redhat.com>", "References": "<20200331160714.697790-1-aconole@redhat.com>\n <20200401131849.2209336-1-aconole@redhat.com>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 2.84 on 10.5.11.22", "X-Mimecast-Spam-Score": "0", "X-Mimecast-Originator": "redhat.com", "Content-Type": "text/plain; charset=US-ASCII", "Content-Transfer-Encoding": "quoted-printable", "Subject": "[dpdk-dev] [PATCH v2 4/4] ipfrag: add unit test case", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "Initial IP fragmentation unit test.\n\nSigned-off-by: Aaron Conole <aconole@redhat.com>\n---\n MAINTAINERS | 1 +\n app/test/meson.build | 2 +\n app/test/test_ipfrag.c | 276 +++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 279 insertions(+)\n create mode 100644 app/test/test_ipfrag.c", "diff": "diff --git a/MAINTAINERS b/MAINTAINERS\nindex 4800f6884a..c81f07ac9c 100644\n--- a/MAINTAINERS\n+++ b/MAINTAINERS\n@@ -1230,6 +1230,7 @@ F: app/test/test_crc.c\n IP fragmentation & reassembly\n M: Konstantin Ananyev <konstantin.ananyev@intel.com>\n F: lib/librte_ip_frag/\n+F: app/test/test_ipfrag.c\n F: doc/guides/prog_guide/ip_fragment_reassembly_lib.rst\n F: examples/ip_fragmentation/\n F: doc/guides/sample_app_ug/ip_frag.rst\ndiff --git a/app/test/meson.build b/app/test/meson.build\nindex 351d29cb65..c2b07fa62f 100644\n--- a/app/test/meson.build\n+++ b/app/test/meson.build\n@@ -58,6 +58,7 @@ test_sources = files('commands.c',\n \t'test_hash_perf.c',\n \t'test_hash_readwrite_lf_perf.c',\n \t'test_interrupts.c',\n+ 'test_ipfrag.c',\n \t'test_ipsec.c',\n \t'test_ipsec_sad.c',\n \t'test_kni.c',\n@@ -187,6 +188,7 @@ fast_tests = [\n ['flow_classify_autotest', false],\n ['hash_autotest', true],\n ['interrupt_autotest', true],\n+ ['ipfrag_autotest', false],\n ['logs_autotest', true],\n ['lpm_autotest', true],\n ['lpm6_autotest', true],\ndiff --git a/app/test/test_ipfrag.c b/app/test/test_ipfrag.c\nnew file mode 100644\nindex 0000000000..4cdc1dcd54\n--- /dev/null\n+++ b/app/test/test_ipfrag.c\n@@ -0,0 +1,276 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2020 Red Hat, Inc.\n+ */\n+\n+#include <time.h>\n+\n+#include <rte_common.h>\n+#include <rte_cycles.h>\n+#include <rte_hexdump.h>\n+#include <rte_ip.h>\n+#include <rte_ip_frag.h>\n+#include <rte_mbuf.h>\n+#include <rte_memcpy.h>\n+#include <rte_random.h>\n+\n+#include \"test.h\"\n+\n+#ifndef ARRAY_SIZE\n+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))\n+#endif\n+\n+static struct rte_mempool *pkt_pool,\n+\t\t\t *direct_pool,\n+\t\t\t *indirect_pool;\n+\n+static int\n+setup_buf_pool(void)\n+{\n+#define NUM_MBUFS (128)\n+#define BURST 32\n+\n+\tif (!pkt_pool)\n+\t\tpkt_pool = rte_pktmbuf_pool_create(\"FRAG_MBUF_POOL\",\n+\t\t\t\t\t\t NUM_MBUFS, BURST, 0,\n+\t\t\t\t\t\t RTE_MBUF_DEFAULT_BUF_SIZE,\n+\t\t\t\t\t\t SOCKET_ID_ANY);\n+\tif (pkt_pool == NULL) {\n+\t\tprintf(\"%s: Error creating pkt mempool\\n\", __func__);\n+\t\tgoto bad_setup;\n+\t}\n+\n+\tif (!direct_pool)\n+\t\tdirect_pool = rte_pktmbuf_pool_create(\"FRAG_D_MBUF_POOL\",\n+\t\t\t\t\t\t NUM_MBUFS, BURST, 0,\n+\t\t\t\t\t\t RTE_MBUF_DEFAULT_BUF_SIZE,\n+\t\t\t\t\t\t SOCKET_ID_ANY);\n+\tif (!direct_pool) {\n+\t\tprintf(\"%s: Error creating direct mempool\\n\", __func__);\n+\t\tgoto bad_setup;\n+\t}\n+\n+\tif (!indirect_pool)\n+\t\tindirect_pool = rte_pktmbuf_pool_create(\"FRAG_I_MBUF_POOL\",\n+\t\t\t\t\t\t\tNUM_MBUFS, BURST, 0,\n+\t\t\t\t\t\t\t0, SOCKET_ID_ANY);\n+\tif (!indirect_pool) {\n+\t\tprintf(\"%s: Error creating indirect mempool\\n\", __func__);\n+\t\tgoto bad_setup;\n+\t}\n+\n+\treturn 0;\n+\n+bad_setup:\n+\tif (pkt_pool)\n+\t\trte_mempool_free(pkt_pool);\n+\n+\tif (direct_pool)\n+\t\trte_mempool_free(direct_pool);\n+\n+\treturn TEST_FAILED;\n+}\n+\n+static int testsuite_setup(void)\n+{\n+\tif (setup_buf_pool())\n+\t\treturn TEST_FAILED;\n+\treturn TEST_SUCCESS;\n+}\n+\n+static void testsuite_teardown(void)\n+{\n+\tif (pkt_pool)\n+\t\trte_mempool_free(pkt_pool);\n+\n+\tif (direct_pool)\n+\t\trte_mempool_free(direct_pool);\n+\n+\tif (indirect_pool)\n+\t\trte_mempool_free(indirect_pool);\n+\n+\tpkt_pool = NULL;\n+}\n+\n+static int ut_setup(void)\n+{\n+\treturn TEST_SUCCESS;\n+}\n+\n+static void ut_teardown(void)\n+{\n+}\n+\n+static int\n+v4_allocate_packet_of(struct rte_mbuf *b, int fill, size_t s, int df,\n+\t\t uint8_t ttl, uint8_t proto, uint16_t pktid)\n+{\n+\t/* Create a packet, 2k bytes long */\n+\tb->data_off = 0;\n+\tchar *data = rte_pktmbuf_mtod(b, char *);\n+\n+\tmemset(data, fill, sizeof(struct rte_ipv4_hdr) + s);\n+\n+\tstruct rte_ipv4_hdr *hdr = (struct rte_ipv4_hdr *)data;\n+\n+\thdr->version_ihl = 0x45; /* standard IP header... */\n+\thdr->type_of_service = 0;\n+\tb->pkt_len = s + sizeof(struct rte_ipv4_hdr);\n+\tb->data_len = b->pkt_len;\n+\thdr->total_length = htonl(b->pkt_len);\n+\thdr->packet_id = htons(pktid);\n+\thdr->fragment_offset = 0;\n+\tif (df)\n+\t\thdr->fragment_offset = htons(0x4000);\n+\n+\tif (!ttl)\n+\t\tttl = 64; /* default to 64 */\n+\n+\tif (!proto)\n+\t\tproto = 1; /* icmp */\n+\n+\thdr->time_to_live = ttl;\n+\thdr->next_proto_id = proto;\n+\thdr->hdr_checksum = 0;\n+\thdr->src_addr = htonl(0x8080808);\n+\thdr->dst_addr = htonl(0x8080404);\n+\n+\treturn 0;\n+}\n+\n+static int\n+v6_allocate_packet_of(struct rte_mbuf *b, int fill, size_t s, uint8_t ttl,\n+\t\t uint8_t proto, uint16_t pktid)\n+{\n+\t/* Create a packet, 2k bytes long */\n+\tb->data_off = 0;\n+\tchar *data = rte_pktmbuf_mtod(b, char *);\n+\n+\tmemset(data, fill, sizeof(struct rte_ipv6_hdr) + s);\n+\n+\tstruct rte_ipv6_hdr *hdr = (struct rte_ipv6_hdr *)data;\n+\tb->pkt_len = s + sizeof(struct rte_ipv6_hdr);\n+\tb->data_len = b->pkt_len;\n+\n+\t/* basic v6 header */\n+\thdr->vtc_flow = htonl(0x60 << 24 | pktid);\n+\thdr->payload_len = htons(b->pkt_len);\n+\thdr->proto = proto;\n+\thdr->hop_limits = ttl;\n+\n+\tmemset(hdr->src_addr, 0x08, sizeof(hdr->src_addr));\n+\tmemset(hdr->dst_addr, 0x04, sizeof(hdr->src_addr));\n+\n+\treturn 0;\n+}\n+\n+static inline void\n+test_free_fragments(struct rte_mbuf *mb[], uint32_t num)\n+{\n+\tuint32_t i;\n+\tfor (i = 0; i < num; i++)\n+\t\trte_pktmbuf_free(mb[i]);\n+}\n+\n+static int\n+test_ip_frag(void)\n+{\n+\tint result = TEST_SUCCESS;\n+\n+\tstruct test_ip_frags {\n+\t\tint ipv;\n+\t\tsize_t mtu_size;\n+\t\tsize_t pkt_size;\n+\t\tint set_df;\n+\t\tint ttl;\n+\t\tuint8_t proto;\n+\t\tint pkt_id;\n+\t\tint expected_frags;\n+\t} tests[] = {\n+\t\t {4, 1280, 1400, 0, 64, IPPROTO_ICMP, -1, 2},\n+\t\t {4, 1280, 1400, 0, 64, IPPROTO_ICMP, 0, 2},\n+\t\t {4, 600, 1400, 0, 64, IPPROTO_ICMP, -1, 3},\n+\t\t {4, 4, 1400, 0, 64, IPPROTO_ICMP, -1, -EINVAL},\n+\t\t {4, 600, 1400, 1, 64, IPPROTO_ICMP, -1, -ENOTSUP},\n+\t\t {4, 600, 1400, 0, 0, IPPROTO_ICMP, -1, 3},\n+\n+\t\t {6, 1280, 1400, 0, 64, IPPROTO_ICMP, -1, 2},\n+\t\t {6, 1300, 1400, 0, 64, IPPROTO_ICMP, -1, 2},\n+\t\t {6, 4, 1400, 0, 64, IPPROTO_ICMP, -1, -EINVAL},\n+\t\t {6, 1300, 1400, 0, 0, IPPROTO_ICMP, -1, 2},\n+\t\t {6, 1280, 1400, 0, 64, IPPROTO_FRAGMENT, -1, -ENOTSUP},\n+\t};\n+\n+\tfor (size_t i = 0; i < ARRAY_SIZE(tests); i++) {\n+\t\tint32_t len;\n+\t\tuint16_t pktid = tests[i].pkt_id;\n+\t\tstruct rte_mbuf *pkts_out[BURST];\n+\t\tstruct rte_mbuf *b = rte_pktmbuf_alloc(pkt_pool);\n+\n+\t\tif (!b)\n+\t\t\treturn TEST_FAILED; /* Serious error.. abort here */\n+\n+\t\tif (tests[i].pkt_id == -1)\n+\t\t\tpktid = rte_rand_max(UINT16_MAX);\n+\n+\t\tif (tests[i].ipv == 4) {\n+\t\t\tif (v4_allocate_packet_of(b, 0x41414141,\n+\t\t\t\t\t\t tests[i].pkt_size,\n+\t\t\t\t\t\t tests[i].set_df,\n+\t\t\t\t\t\t tests[i].ttl,\n+\t\t\t\t\t\t tests[i].proto,\n+\t\t\t\t\t\t pktid))\n+\t\t\t\tresult = TEST_FAILED;\n+\t\t} else if (tests[i].ipv == 6) {\n+\t\t\tif (v6_allocate_packet_of(b, 0x41414141,\n+\t\t\t\t\t\t tests[i].pkt_size,\n+\t\t\t\t\t\t tests[i].ttl,\n+\t\t\t\t\t\t tests[i].proto,\n+\t\t\t\t\t\t pktid))\n+\t\t\t\tresult = TEST_FAILED;\n+\t\t}\n+\n+\t\tif (tests[i].ipv == 4)\n+\t\t\tlen = rte_ipv4_fragment_packet(b, pkts_out, BURST,\n+\t\t\t\t\t\t tests[i].mtu_size,\n+\t\t\t\t\t\t direct_pool,\n+\t\t\t\t\t\t indirect_pool);\n+\t\telse\n+\t\t\tlen = rte_ipv6_fragment_packet(b, pkts_out, BURST,\n+\t\t\t\t\t\t tests[i].mtu_size,\n+\t\t\t\t\t\t direct_pool,\n+\t\t\t\t\t\t indirect_pool);\n+\n+\t\trte_pktmbuf_free(b);\n+\n+\t\tif (len > 0)\n+\t\t\ttest_free_fragments(pkts_out, len);\n+\n+\t\tprintf(\"%d: checking %d with %d\\n\", (int)i, len,\n+\t\t (int)tests[i].expected_frags);\n+\t\tRTE_TEST_ASSERT_EQUAL(len, tests[i].expected_frags,\n+\t\t\t\t \"Failed case %u\\n\", (unsigned int)i);\n+\n+\t}\n+\n+\treturn result;\n+}\n+\n+static struct unit_test_suite ipfrag_testsuite = {\n+\t.suite_name = \"IP Frag Unit Test Suite\",\n+\t.setup = testsuite_setup,\n+\t.teardown = testsuite_teardown,\n+\t.unit_test_cases = {\n+\t\tTEST_CASE_ST(ut_setup, ut_teardown,\n+\t\t\t test_ip_frag),\n+\n+\t\tTEST_CASES_END() /**< NULL terminate unit test array */\n+\t}\n+};\n+\n+static int\n+test_ipfrag(void)\n+{\n+\treturn unit_test_suite_runner(&ipfrag_testsuite);\n+}\n+\n+REGISTER_TEST_COMMAND(ipfrag_autotest, test_ipfrag);\n", "prefixes": [ "v2", "4/4" ] }{ "id": 67583, "url": "