get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/7924/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 7924,
    "url": "http://patches.dpdk.org/api/patches/7924/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/51540495.a2d9.15092ff2946.Coremail.mablexidana@163.com/",
    "project": {
        "id": 1,
        "url": "http://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": "<51540495.a2d9.15092ff2946.Coremail.mablexidana@163.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/51540495.a2d9.15092ff2946.Coremail.mablexidana@163.com",
    "date": "2015-10-23T04:40:07",
    "name": "[dpdk-dev] fix lpm bugs",
    "commit_ref": null,
    "pull_url": null,
    "state": "not-applicable",
    "archived": true,
    "hash": "ec6c91abef5b86a17b089256779e0d9363e2ac5c",
    "submitter": {
        "id": 356,
        "url": "http://patches.dpdk.org/api/people/356/?format=api",
        "name": "mablexidana",
        "email": "mablexidana@163.com"
    },
    "delegate": null,
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/51540495.a2d9.15092ff2946.Coremail.mablexidana@163.com/mbox/",
    "series": [],
    "comments": "http://patches.dpdk.org/api/patches/7924/comments/",
    "check": "pending",
    "checks": "http://patches.dpdk.org/api/patches/7924/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id E4A66C408;\n\tFri, 23 Oct 2015 06:40:14 +0200 (CEST)",
            "from m13-4.163.com (m13-4.163.com [220.181.13.4])\n\tby dpdk.org (Postfix) with ESMTP id 174BBC402\n\tfor <dev@dpdk.org>; Fri, 23 Oct 2015 06:40:11 +0200 (CEST)",
            "from mablexidana$163.com ( [182.92.253.20] ) by\n\tajax-webmail-wmsvr4 (Coremail) ; Fri, 23 Oct 2015 12:40:07 +0800 (CST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com;\n\ts=s110527; h=Date:From:Subject:MIME-Version:Message-ID; bh=ukzeI\n\tdNx5hwi12Ibo38m2CptzhLmrfdlzE5CV641m5I=; b=k1JpyMsIElvwRBb1NAYou\n\tP7pdKOx5T6bZrWW+ZoQA6g0n5ZDf75Ev6N7D9j+g1Ua3hDA+2nGjGnyQr1vyy+BN\n\t+L1+EEqzWM0y+kT2TFnJ/MuccHcCk1/0kJ4+otUQRZa66/xb1ZIzzz5DjdQqaHoH\n\tCI3I4nBGUGd2w9zP92TujA=",
        "X-Originating-IP": "[182.92.253.20]",
        "Date": "Fri, 23 Oct 2015 12:40:07 +0800 (CST)",
        "From": "mablexidana  <mablexidana@163.com>",
        "To": "\"Bruce Richardson\" <bruce.richardson@intel.com>, dev@dpdk.org",
        "X-Priority": "3",
        "X-Mailer": "Coremail Webmail Server Version SP_ntes V3.5 build\n\t20150911(74783.7961) Copyright (c) 2002-2015 www.mailtech.cn 163com",
        "In-Reply-To": "<313921ca.4b27.1508d543038.Coremail.mablexidana@163.com>",
        "References": "<5e5d9466.100a4.15089d2018f.Coremail.mablexidana@163.com>\n\t<20151021110749.GD16140@bricha3-MOBL3>\n\t<313921ca.4b27.1508d543038.Coremail.mablexidana@163.com>",
        "X-CM-CTRLDATA": "dn3Lx2Zvb3Rlcl9odG09MjkwMDg6NTY=",
        "MIME-Version": "1.0",
        "Message-ID": "<51540495.a2d9.15092ff2946.Coremail.mablexidana@163.com>",
        "X-CM-TRANSID": "BMGowADX3gIouilWWhOPAA--.24131W",
        "X-CM-SenderInfo": "xpdezvp0lgt0rd6rljoofrz/1tbiMRKcsFUL3JdtuAACsN",
        "X-Coremail-Antispam": "1U5529EdanIXcx71UUUUU7vcSsGvfC2KfnxnUU==",
        "Content-Type": "text/plain; charset=GBK",
        "Content-Transfer-Encoding": "base64",
        "X-Content-Filtered-By": "Mailman/MimeDel 2.1.15",
        "Subject": "Re: [dpdk-dev] [PATCH] fix lpm bugs",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "patches and discussions about DPDK <dev.dpdk.org>",
        "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://dpdk.org/ml/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "hi:\nFixes: 396284f345a1 (\"add app/test/test_lpm.c test lpm, add 3 new cases 1),add->lookup 2),add->delete->lookup 3),add->delete->add->lookup\")\n[PATCH] add app/test/test_lpm.c test lpm, add 3 new cases\n\n\ntest procedure:\n 1),add->lookup \n 2),add->delete->lookup \n 3),add->delete->add->lookup\n\n\nThis is the test program to test lpm bugs. \n\n\n\n\nThanks\n\n\nRegards\n\n\nyuexin\n---\n app/test/test_lpm.c | 480 ++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 480 insertions(+)\n\n\n #include <rte_memory.h>\n@@ -44,6 +47,7 @@\n #include <rte_branch_prediction.h>\n #include <rte_ip.h>\n #include <time.h>\n+#include <sys/time.h>\n\n\n #include \"test.h\"\n\n\n@@ -77,8 +81,69 @@ static int32_t test14(void);\n static int32_t test15(void);\n static int32_t test16(void);\n static int32_t test17(void);\n+static int32_t test_random(void);\n static int32_t perf_test(void);\n\n\n+#ifndef RTE_VERSION_NUM\n+#define RTE_VERSION_NUM(a,b,c,d) ((a) << 24 | (b) << 16 | (c) << 8 | (d))\n+#endif\n+\n+#ifndef RTE_VERSION\n+#define RTE_VERSION RTE_VERSION_NUM( \\\n+            RTE_VER_MAJOR, \\\n+            RTE_VER_MINOR, \\\n+            RTE_VER_PATCH_LEVEL,\\\n+            0)\n+#endif\n+\n+\n+#define LPM_ADD_ROUTE_MAX       100\n+#define LPM_TEST_LOOKUP_COUNT   1\n+#define  ARG                    32\n+\n+#define RTE_LPM_V3_MAX_DEPTH    32\n+#define RAND_SEED               1024\n+\n+\n+#define PRINT_IP_FORMAT         \"%u.%u.%u.%u\"\n+#define  PRINT_HIP(x)\\\n+        ((x >> 24) & 0xFF),\\\n+        ((x >> 16) & 0xFF),\\\n+        ((x >>  8) & 0xFF),\\\n+        ((x >>  0) & 0xFF)\n+\n+/*route struct node define*/\n+struct route_node {\n+    uint32_t dip;\n+    uint32_t depth;\n+    uint16_t next_hop;\n+    uint16_t flags;\n+};\n+\n+/*global varible define*/\n+struct route_node route_table_arrary[LPM_ADD_ROUTE_MAX];\n+\n+\n+/*for test_random route table test functions*/\n+long getCurrentTime(void);\n+int test_random_lpm_case_1(struct rte_lpm *lpm);\n+int test_random_lpm_case_2(struct rte_lpm *lpm);\n+int test_random_lpm_case_3(struct rte_lpm *lpm);\n+int lpm_random_lookup(struct rte_lpm *lpm_tree, uint32_t dip_count);\n+int lpm_random_add(struct rte_lpm *lpm_tree, int count);\n+int lpm_random_delete(struct rte_lpm *lpm_tree, uint32_t index);\n+int lpm_random_add_nexthop(struct rte_lpm *lpm_tree, int count, int next_hop);\n+void lpm_route_show(struct rte_lpm *lpm);\n+void lpm_route_show_v2(struct rte_lpm *lpm, uint32_t hop1, uint32_t hop2);\n+int route_table_arrary_create(void);\n+int route_table_arrary_add(uint32_t dip, uint8_t depth, uint32_t next_hop);\n+#if RTE_VERSION >= RTE_VERSION_NUM(2, 1, 0, 0)\n+uint32_t depth_to_mask(uint8_t depth);\n+int route_table_lpm_lookup(struct rte_lpm *lpm_tree, uint32_t dip, uint8_t *next_hop);\n+#else\n+int route_table_lpm_lookup(struct rte_lpm *lpm_tree, uint32_t dip, uint16_t *next_hop);\n+#endif\n+\n rte_lpm_test tests[] = {\n /* Test Cases */\n test0,\n@@ -99,6 +164,7 @@ rte_lpm_test tests[] = {\n test15,\n test16,\n test17,\n+test_random,\n perf_test,\n };\n\n\n@@ -1137,6 +1203,420 @@ test17(void)\n return PASS;\n }\n\n\n+long\n+getCurrentTime(void)\n+{\n+    struct timeval tv;\n+    gettimeofday(&tv,NULL);\n+    return tv.tv_sec * 1000 + tv.tv_usec / 1000;\n+}\n+\n+#if RTE_VERSION >= RTE_VERSION_NUM(2, 1, 0, 0)\n+/*convertt the depth to net mask*/\n+uint32_t depth_to_mask(uint8_t depth)\n+{\n+    return (int)0x80000000 >> (depth - 1);\n+}\n+#endif\n+\n+/*for route test table operate*/\n+int\n+route_table_arrary_create(void)\n+{\n+    memset(route_table_arrary, 0, sizeof(struct route_node) * LPM_ADD_ROUTE_MAX);\n+    return 0;\n+}\n+\n+/*add the route to the route test table*/\n+int\n+route_table_arrary_add(uint32_t dip, uint8_t depth, uint32_t next_hop)\n+{\n+    uint32_t i = 0;\n+    uint32_t dip_masked = dip & depth_to_mask(depth);\n+\n+    for(i = 0; i < LPM_ADD_ROUTE_MAX; i++) {\n+        if(route_table_arrary[i].flags == 1\n+                && route_table_arrary[i].dip == dip\n+                && route_table_arrary[i].depth == depth) {\n+\n+            route_table_arrary[i].dip = dip_masked;\n+            route_table_arrary[i].depth = depth;\n+            route_table_arrary[i].next_hop = next_hop;\n+\n+            return 0;   //exsit, update\n+        }\n+    }\n+\n+    for(i = 0; i < LPM_ADD_ROUTE_MAX; i++) {\n+        if(route_table_arrary[i].flags == 0) {  //add the route\n+            route_table_arrary[i].flags = 1;\n+            route_table_arrary[i].dip = dip_masked;\n+            route_table_arrary[i].depth = depth;\n+            route_table_arrary[i].next_hop = next_hop;\n+\n+            return 0;   //add one by one, success\n+        }\n+    }\n+\n+    return -1;  //add failed\n+}\n+\n+#if RTE_VERSION >= RTE_VERSION_NUM(2, 1, 0, 0)\n+int route_table_lpm_lookup(struct rte_lpm *lpm, uint32_t dip, uint8_t *next_hop)\n+#else\n+int route_table_lpm_lookup(struct rte_lpm *lpm, uint32_t dip, uint16_t *next_hop)\n+#endif\n+{\n+    int i, j;\n+    int start, end;\n+    uint32_t mask;\n+\n+    for(i = RTE_LPM_V3_MAX_DEPTH - 1; i >= 0 ; i--) {\n+#if RTE_VERSION >= RTE_VERSION_NUM(2, 1, 0, 0)\n+        start = lpm->rule_info[i].first_rule;   //find from max depth rule\n+        end = start + lpm->rule_info[i].used_rules;\n+#else\n+        start = i * lpm->max_rules_per_depth;\n+        end = start + lpm->used_rules_at_depth[i];\n+#endif\n+        for(j = start; j < end; j++) {\n+            mask = depth_to_mask(i + 1);\n+\n+            if((dip & mask) == lpm->rules_tbl[j].ip) {\n+                *next_hop = lpm->rules_tbl[j].next_hop;\n+                return 0;\n+            }\n+        }\n+    }\n+\n+    return -1;\n+}\n+\n+/*show lpm's route entries*/\n+void lpm_route_show(struct rte_lpm *lpm)\n+{\n+    uint32_t i = 0, j = 0;\n+    uint32_t start = 0, end = 0, count = 0;\n+\n+    printf(\"[%s:%d]show rule in lpm tree...\\n\",__func__,__LINE__);\n+\n+    for(i = 0; i < RTE_LPM_V3_MAX_DEPTH; i++){\n+#if RTE_VERSION >= RTE_VERSION_NUM(2, 1, 0, 0)\n+        start = lpm->rule_info[i].first_rule;\n+        end = start + lpm->rule_info[i].used_rules;\n+#else\n+        start = i * lpm->max_rules_per_depth;\n+        end = start + lpm->used_rules_at_depth[i];\n+#endif\n+        for(j = start; j < end; j++) {\n+            printf(\"\\trule id : %u, ip : \"PRINT_IP_FORMAT\"/%u, next_hop : %u, \\t\\t lpm arrary(%u - %u - %u)\\n\",\n+                        ++count, PRINT_HIP(lpm->rules_tbl[j].ip), i + 1, lpm->rules_tbl[j].next_hop, i, start, end);\n+        }\n+    }\n+\n+    return;\n+}\n+\n+/*show lpm's route entries on hop1 and hop2*/\n+void\n+lpm_route_show_v2(struct rte_lpm *lpm, uint32_t hop1, uint32_t hop2)\n+{\n+    uint32_t i = 0, j = 0;\n+    uint32_t start = 0, end = 0, count = 0;\n+\n+    printf(\"[%s:%d]show rule in lpm tree...\\n\",__func__,__LINE__);\n+\n+    for(i = 0; i < RTE_LPM_V3_MAX_DEPTH; i++){\n+#if RTE_VERSION >= RTE_VERSION_NUM(2, 1, 0, 0)\n+        start = lpm->rule_info[i].first_rule;\n+        end = start + lpm->rule_info[i].used_rules;\n+#else\n+        start = i * lpm->max_rules_per_depth;\n+        end = start + lpm->used_rules_at_depth[i];\n+#endif\n+        for(j = start; j < end; j++) {\n+            if(lpm->rules_tbl[j].next_hop == hop1 || lpm->rules_tbl[j].next_hop == hop2) {\n+                printf(\"\\trule id : %u, ip : \"PRINT_IP_FORMAT\"/%u, next_hop : %u, \\t\\t lpm arrary(%u - %u - %u)\\n\",\n+                        ++count, PRINT_HIP(lpm->rules_tbl[j].ip), i + 1, lpm->rules_tbl[j].next_hop, i, start, end);\n+            }\n+        }\n+    }\n+\n+    return;\n+}\n+\n+int\n+lpm_random_add_nexthop(struct rte_lpm *lpm_tree, int count, int next_hop)\n+{\n+    int32_t i;\n+    int32_t status = 0;\n+    uint32_t add_dip = 0;\n+    uint8_t add_depth = 0;\n+    uint8_t next_hop_add = 0;\n+uint32_t dip_masked = 0;\n+    uint64_t seed = 0;\n+    int nh = next_hop-1;\n+\n+    seed = getCurrentTime();\n+rte_srand(seed);\n+\n+for (i = 0; i < count; i++) {\n+next_hop_add = nh++;\n+\n+add_dip = 0x10200000 + (rte_rand() >> 48);\n+        add_depth = rte_rand() % 32 + 1;\n+dip_masked = add_dip & depth_to_mask(add_depth);\n+\n+if(dip_masked == 0) {\n+i--;\n+continue;\n+}\n+\n+        status = rte_lpm_add(lpm_tree, dip_masked, add_depth, next_hop_add);\n+        if(status != 0) {\n+            printf(\"lpm add routes failed, ret : %d...\\n\", status);\n+            continue;\n+}\n+\n+        route_table_arrary_add(dip_masked, add_depth, next_hop_add);\n+    }\n+\n+    return 0;\n+}\n+\n+/*for random route add, for route table & lpm struct*/\n+int lpm_random_add(struct rte_lpm *lpm_tree, int count)\n+{\n+    int32_t i;\n+    int32_t status = 0;\n+    uint32_t add_dip = 0;\n+    uint8_t add_depth = 0;\n+    uint8_t next_hop_add = 0;\n+uint32_t dip_masked = 0;\n+    uint64_t seed = 0;\n+\n+    seed = getCurrentTime();\n+rte_srand(seed);\n+    printf(\"seed = %ld\\n\", seed);\n+\n+for (i = 0; i < count; i++) {\n+next_hop_add = i % 256;\n+\n+add_dip = 0x10200000 + (rte_rand() >> 48);\n+        add_depth = rte_rand() % 32 + 1;\n+dip_masked = add_dip & depth_to_mask(add_depth);\n+\n+if(dip_masked == 0) {\n+i--;\n+continue;\n+}\n+\n+        status = rte_lpm_add(lpm_tree, dip_masked, add_depth, next_hop_add);\n+        if(status != 0) {\n+            printf(\"lpm add routes failed, ret : %d...\\n\", status);\n+            continue;\n+}\n+\n+        route_table_arrary_add(dip_masked, add_depth, next_hop_add);\n+    }\n+\n+    return 0;\n+}\n+\n+/*for random lookup the route*/\n+int lpm_random_lookup(struct rte_lpm *lpm_tree, uint32_t query_count)\n+{\n+    uint32_t i = 0;\n+#if RTE_VERSION >= RTE_VERSION_NUM(2, 1, 0, 0)\n+    uint8_t lookup_next_hop_0 = 0;\n+    uint8_t lookup_next_hop_1 = 0;\n+#else\n+    uint16_t lookup_next_hop_0 = 0;\n+    uint16_t lookup_next_hop_1 = 0;\n+#endif\n+\n+uint32_t dip;\n+    int32_t status_0 = 0, status_1 = 0;\n+\n+rte_srand(getCurrentTime());\n+\n+for (i = 0; i < query_count; i++) {\n+dip = 0x10200000 + (rte_rand() >> 48);\n+\n+lookup_next_hop_0 = 0xff;\n+lookup_next_hop_1 = 0xff;\n+\n+status_0 = route_table_lpm_lookup(lpm_tree, dip, &lookup_next_hop_0);\n+        status_1 = rte_lpm_lookup(lpm_tree, dip, &lookup_next_hop_1);\n+\n+        if(status_0 == 0 && status_1 == 0) {\n+            if(lookup_next_hop_0 != lookup_next_hop_1) {\n+                printf(\"lookup times : %u, failed, dip : \"PRINT_IP_FORMAT\", next_hop_0 : %u, next_hop_1 : %u\\n\",\n+i, PRINT_HIP(dip), lookup_next_hop_0, lookup_next_hop_1);\n+            status_1 = rte_lpm_lookup(lpm_tree, dip, &lookup_next_hop_1);\n+printf(\"slit 1, for check a time, status_1 %d, next_hop : %u\\n\", status_1, lookup_next_hop_1);\n+lpm_route_show_v2(lpm_tree, lookup_next_hop_0, lookup_next_hop_1);\n+            return -1;\n+        }\n+        } else if(status_0 < 0 && status_1 < 0) {\n+            //printf(\"i : %u, lpm lookup don't exsit, status_0 : %d, status_1 :%d\\n\", i, status_0, status_1);\n+        continue;\n+} else {\n+            printf(\"lookup times : %u, failed,  dip : \"PRINT_IP_FORMAT\" , status_0 : %d, status_1 :%d, next_hop_0 : %u, next_hop_1 : %u\\n\",\n+i, PRINT_HIP(dip), status_0, status_1, lookup_next_hop_0, lookup_next_hop_1);\n+            status_1 = rte_lpm_lookup(lpm_tree, dip, &lookup_next_hop_1);\n+printf(\"slit 2, for check a time, status_1 %d, next_hop : %u\\n\", status_1, lookup_next_hop_1);\n+lpm_route_show_v2(lpm_tree, lookup_next_hop_0, lookup_next_hop_1);\n+return -1;\n+        }\n+    }\n+\n+    return 0;\n+}\n+\n+/*for delte the route by segment, from start to end*/\n+int lpm_random_delete(struct rte_lpm *lpm_tree, uint32_t index)\n+{\n+    int ret = 0;\n+    uint32_t dip = 0;\n+    uint8_t  depth;\n+    uint16_t next_hop;\n+uint32_t dip_masked;\n+\n+if(route_table_arrary[index].flags == 1) {\n+dip = route_table_arrary[index].dip;\n+depth = route_table_arrary[index].depth;\n+next_hop = route_table_arrary[index].next_hop;\n+dip_masked = dip & depth_to_mask(depth);\n+\n+route_table_arrary[index].flags = 0;\n+route_table_arrary[index].dip = 0;\n+route_table_arrary[index].depth = 0;\n+route_table_arrary[index].next_hop = 0;\n+\n+ret = rte_lpm_delete(lpm_tree, dip_masked, depth);\n+if(ret < 0) {\n+   printf(\"delete, failed, index : %u, dip : \"PRINT_IP_FORMAT\", depth : %u\\n\", index, PRINT_HIP(dip), depth);\n+   return -1;\n+}\n+}\n+\n+    return 0;\n+}\n+\n+\n+/*add -> lookup*/\n+int\n+test_random_lpm_case_1(struct rte_lpm *lpm)\n+{\n+    int ret = 0;\n+\n+    ret = lpm_random_add(lpm, LPM_ADD_ROUTE_MAX);\n+    if(ret < 0) {\n+        return ret;\n+    }\n+\n+    ret = lpm_random_lookup(lpm, LPM_TEST_LOOKUP_COUNT);\n+    if(ret < 0) {\n+        return ret;\n+    }\n+\n+    return 0;\n+}\n+\n+/*add -> del -> lookup*/\n+int\n+test_random_lpm_case_2(struct rte_lpm *lpm)\n+{\n+    int i = 0, ret = 0;\n+\n+    for(i = 0; i <  LPM_ADD_ROUTE_MAX; i++) {\n+        lpm_random_delete(lpm, i);\n+\n+        ret = lpm_random_lookup(lpm, LPM_TEST_LOOKUP_COUNT);\n+        if(ret < 0) {\n+            return -1;\n+        }\n+    }\n+\n+    return 0;\n+}\n+\n+/*for n times: del ->add -> lookup*/\n+int\n+test_random_lpm_case_3(struct rte_lpm *lpm)\n+{\n+    int ret = 0;\n+    int i = 0;\n+    int hops = 0;\n+    int add = 1;\n+    ret = lpm_random_add(lpm, LPM_ADD_ROUTE_MAX);\n+    if(ret < 0) {\n+        return ret;\n+    }\n+    hops = 200;\n+    for(i = 0; i <  LPM_ADD_ROUTE_MAX; i++) {\n+        usleep(1000);\n+        lpm_random_delete(lpm, i);\n+        lpm_random_add_nexthop(lpm,add,hops);\n+        hops = hops + add;\n+        ret = lpm_random_lookup(lpm, LPM_TEST_LOOKUP_COUNT);\n+            if(ret < 0) {\n+                return -1;\n+            }\n+    }\n+\n+    return 0;\n+}\n+\n+/*\n+ * Test for random routing add, del and lookup\n+ */\n+int32_t\n+test_random(void) {\n+    int ret = PASS;\n+//    int case_process,i;\n+    struct rte_lpm *lpm = NULL;\n+    lpm = rte_lpm_create(__func__, SOCKET_ID_ANY, LPM_ADD_ROUTE_MAX  * ARG, 0);\n+TEST_LPM_ASSERT(lpm != NULL);\n+\n+    route_table_arrary_create();\n+\n+\n+    ret = test_random_lpm_case_1(lpm);\n+    if(ret != 0) {\n+        lpm_route_show(lpm);\n+        printf(\"test_random_lpm_case_1, failed...\\n\");\n+        ret = -1;\n+        goto OUT;\n+    }\n+    printf(\"test_random_lpm_case_1, ok...\\n\");\n+\n+\n+    ret = test_random_lpm_case_2(lpm);\n+    if(ret != 0) {\n+        lpm_route_show(lpm);\n+        printf(\"test_random_lpm_case_2, failed...\\n\");\n+        ret = -1;\n+        goto OUT;\n+    }\n+    printf(\"test_random_lpm_case_2, ok...\\n\");\n+\n+    ret = test_random_lpm_case_3(lpm);\n+    if(ret != 0) {\n+        lpm_route_show(lpm);\n+        printf(\"test_random_lpm_case_3, failed...\\n\");\n+        ret = -1;\n+        goto OUT;\n+    }\n+    printf(\"test_random_lpm_case_3, ok...\\n\");\n+\n+OUT:\n+    rte_lpm_free(lpm) ;\n+    return ret;\n+}\n+\n+\n /*\n  * Lookup performance test\n  */\n--\n1.8.5.2 (Apple Git-48)",
    "diff": "diff --git a/app/test/test_lpm.c b/app/test/test_lpm.c\nindex 8b4ded9..d2f8a52 100644\n--- a/app/test/test_lpm.c\n+++ b/app/test/test_lpm.c\n@@ -35,8 +35,11 @@\n #include <stdint.h>\n #include <stdlib.h>\n #include <errno.h>\n+#include <string.h>\n+#include <unistd.h>\n #include <sys/queue.h>\n\n\n+#include <rte_version.h>\n #include <rte_common.h>\n #include <rte_cycles.h>\n",
    "prefixes": [
        "dpdk-dev"
    ]
}