Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/17257/?format=api
http://patches.dpdk.org/api/patches/17257/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/1480055491-137021-1-git-send-email-chunguang.yang@windriver.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": "<1480055491-137021-1-git-send-email-chunguang.yang@windriver.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1480055491-137021-1-git-send-email-chunguang.yang@windriver.com", "date": "2016-11-25T06:31:31", "name": "[dpdk-dev] lpm: rte_lpm_iterate() - iterate through the routes", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": true, "hash": "53b9ce654a8c427147555ab99f6cd96b17210d85", "submitter": { "id": 610, "url": "http://patches.dpdk.org/api/people/610/?format=api", "name": "alloc", "email": "chunguang.yang@windriver.com" }, "delegate": { "id": 1, "url": "http://patches.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/1480055491-137021-1-git-send-email-chunguang.yang@windriver.com/mbox/", "series": [], "comments": "http://patches.dpdk.org/api/patches/17257/comments/", "check": "warning", "checks": "http://patches.dpdk.org/api/patches/17257/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 5B29447CE;\n\tFri, 25 Nov 2016 07:31:38 +0100 (CET)", "from mail1.windriver.com (mail1.windriver.com [147.11.146.13])\n\tby dpdk.org (Postfix) with ESMTP id 4E795379B\n\tfor <dev@dpdk.org>; Fri, 25 Nov 2016 07:31:35 +0100 (CET)", "from ALA-HCB.corp.ad.wrs.com (ala-hcb.corp.ad.wrs.com\n\t[147.11.189.41])\n\tby mail1.windriver.com (8.15.2/8.15.1) with ESMTPS id uAP6VXh3014550\n\t(version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL)\n\tfor <dev@dpdk.org>; Thu, 24 Nov 2016 22:31:34 -0800 (PST)", "from pek-lpggp3.wrs.com (128.224.153.76) by ALA-HCB.corp.ad.wrs.com\n\t(147.11.189.41) with Microsoft SMTP Server id 14.3.294.0;\n\tThu, 24 Nov 2016 22:31:33 -0800" ], "From": "chunguang yang <chunguang.yang@windriver.com>", "To": "<dev@dpdk.org>", "CC": "<Weiwei.Wang@windriver.com>, <mark.asselstine@windriver.com>", "Date": "Fri, 25 Nov 2016 01:31:31 -0500", "Message-ID": "<1480055491-137021-1-git-send-email-chunguang.yang@windriver.com>", "X-Mailer": "git-send-email 2.7.4", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"UTF-8\"", "Content-Transfer-Encoding": "8bit", "Subject": "[dpdk-dev] [PATCH] lpm: rte_lpm_iterate() - iterate through the\n\troutes", "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": "From: Jörgen Grahn <grahn+src@snipabacken.se>\n\nIn practice, there's a need to iterate through the entries\nof a rte_lpm, apart from the usual insert/delete/lookup\noperations. This is useful for debugging and perhaps for\nthings like removing all entries referencing a certain nexthop.\n\nThis patch implements this through rte_lpm_iterate(), which\nuses a cursor (or iterator) to keep track of the current\nposition. Client code doesn't need to be aware of rte_lpm\nimplementation details.\n\nChange-Id: I28ea3d7d92f318988444553ee2bb30b709bcb3b6\nSigned-off-by: Jorgen Grahn <jorgen.grahn@hiq.se>\nSigned-off-by: alloc <alloc.young@gmail.com>\n---\n lib/librte_lpm/Makefile | 4 +-\n lib/librte_lpm/rte_lpm_iterate.c | 81 ++++++++++++++++++++++++++++++++++++++++\n lib/librte_lpm/rte_lpm_iterate.h | 56 +++++++++++++++++++++++++++\n 3 files changed, 139 insertions(+), 2 deletions(-)\n create mode 100644 lib/librte_lpm/rte_lpm_iterate.c\n create mode 100644 lib/librte_lpm/rte_lpm_iterate.h", "diff": "diff --git a/lib/librte_lpm/Makefile b/lib/librte_lpm/Makefile\nindex 3dc549d..c45da19 100644\n--- a/lib/librte_lpm/Makefile\n+++ b/lib/librte_lpm/Makefile\n@@ -42,10 +42,10 @@ EXPORT_MAP := rte_lpm_version.map\n LIBABIVER := 2\n \n # all source are stored in SRCS-y\n-SRCS-$(CONFIG_RTE_LIBRTE_LPM) := rte_lpm.c rte_lpm6.c\n+SRCS-$(CONFIG_RTE_LIBRTE_LPM) := rte_lpm.c rte_lpm6.c rte_lpm_iterate.c\n \n # install this header file\n-SYMLINK-$(CONFIG_RTE_LIBRTE_LPM)-include := rte_lpm.h rte_lpm6.h\n+SYMLINK-$(CONFIG_RTE_LIBRTE_LPM)-include := rte_lpm.h rte_lpm6.h rte_lpm_iterate.h\n \n ifneq ($(filter y,$(CONFIG_RTE_ARCH_ARM) $(CONFIG_RTE_ARCH_ARM64)),)\n SYMLINK-$(CONFIG_RTE_LIBRTE_LPM)-include += rte_lpm_neon.h\ndiff --git a/lib/librte_lpm/rte_lpm_iterate.c b/lib/librte_lpm/rte_lpm_iterate.c\nnew file mode 100644\nindex 0000000..f643764\n--- /dev/null\n+++ b/lib/librte_lpm/rte_lpm_iterate.c\n@@ -0,0 +1,81 @@\n+/*-\n+ * BSD LICENSE\n+ *\n+ * Copyright(c) 2014 Jörgen Grahn. All rights reserved.\n+ * All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or without\n+ * modification, are permitted provided that the following conditions\n+ * are met:\n+ *\n+ * * Redistributions of source code must retain the above copyright\n+ * notice, this list of conditions and the following disclaimer.\n+ * * Redistributions in binary form must reproduce the above copyright\n+ * notice, this list of conditions and the following disclaimer in\n+ * the documentation and/or other materials provided with the\n+ * distribution.\n+ * * Neither the name of Intel Corporation nor the names of its\n+ * contributors may be used to endorse or promote products derived\n+ * from this software without specific prior written permission.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+#include \"rte_lpm_iterate.h\"\n+#include \"rte_lpm.h\"\n+\n+#include <arpa/inet.h>\n+\n+\n+/**\n+ * Iterate through the lpm, pulling out at most 'buflen' valid routes\n+ * (less means we've hit the end). The cursor should be initialized\n+ * to { 0, 0 } before the first call.\n+ *\n+ * The routes are partially sorted, by prefix length. Undefined\n+ * results if the lpm is modified in parallel with or inbetween calls,\n+ * although the iteration will still terminate properly.\n+ */\n+unsigned\n+rte_lpm_iterate(struct rte_lpm_route* const buf, unsigned buflen,\n+\t\tconst struct rte_lpm* lpm,\n+\t\tstruct rte_lpm_cursor* const cursor)\n+{\n+\tstruct rte_lpm_route* p = buf;\n+\tstruct rte_lpm_route* const end = p + buflen;\n+\n+\tconst struct rte_lpm_rule_info* const rinfo = lpm->rule_info;\n+\tconst struct rte_lpm_rule* const rtbl = lpm->rules_tbl;\n+\n+\tunsigned d = cursor->d;\n+\tunsigned n = cursor->n;\n+\n+\twhile(p!=end) {\n+\t\tif(d==32) break;\n+\t\tif(n>=rinfo[d].used_rules) {\n+\t\t\td++;\n+\t\t\tn = 0;\n+\t\t\tcontinue;\n+\t\t}\n+\t\tconst struct rte_lpm_rule rule = rtbl[rinfo[d].first_rule + n];\n+\t\tp->addr.s_addr = htonl(rule.ip);\n+\t\tp->plen = d+1;\n+\t\tp->nh = rule.next_hop;\n+\t\tp++;\n+\t\tn++;\n+\t}\n+\n+\tcursor->d = d;\n+\tcursor->n = n;\n+\n+\treturn p - buf;\n+}\ndiff --git a/lib/librte_lpm/rte_lpm_iterate.h b/lib/librte_lpm/rte_lpm_iterate.h\nnew file mode 100644\nindex 0000000..25c7841\n--- /dev/null\n+++ b/lib/librte_lpm/rte_lpm_iterate.h\n@@ -0,0 +1,56 @@\n+/*-\n+ * BSD LICENSE\n+ *\n+ * Copyright(c) 2014 Jörgen Grahn. All rights reserved.\n+ * All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or without\n+ * modification, are permitted provided that the following conditions\n+ * are met:\n+ *\n+ * * Redistributions of source code must retain the above copyright\n+ * notice, this list of conditions and the following disclaimer.\n+ * * Redistributions in binary form must reproduce the above copyright\n+ * notice, this list of conditions and the following disclaimer in\n+ * the documentation and/or other materials provided with the\n+ * distribution.\n+ * * Neither the name of Intel Corporation nor the names of its\n+ * contributors may be used to endorse or promote products derived\n+ * from this software without specific prior written permission.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+#ifndef _RTE_LPM_ITERATE_H_\n+#define _RTE_LPM_ITERATE_H_\n+\n+#include <stdint.h>\n+#include <netinet/in.h>\n+\n+struct rte_lpm;\n+\n+struct rte_lpm_cursor {\n+\tunsigned d;\n+\tunsigned n;\n+};\n+\n+struct rte_lpm_route {\n+\tstruct in_addr addr;\n+\tuint8_t plen;\n+\tuint8_t nh;\n+};\n+\n+unsigned rte_lpm_iterate(struct rte_lpm_route* buf, unsigned buflen,\n+\t\t\t const struct rte_lpm* lpm,\n+\t\t\t struct rte_lpm_cursor* cursor);\n+\n+#endif\n", "prefixes": [ "dpdk-dev" ] }{ "id": 17257, "url": "