get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 17231,
    "url": "https://patches.dpdk.org/api/patches/17231/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/1479977798-13417-3-git-send-email-olivier.matz@6wind.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": "<1479977798-13417-3-git-send-email-olivier.matz@6wind.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1479977798-13417-3-git-send-email-olivier.matz@6wind.com",
    "date": "2016-11-24T08:56:35",
    "name": "[dpdk-dev,2/5] mbuf: new helper to check if a mbuf is shared",
    "commit_ref": null,
    "pull_url": null,
    "state": "rejected",
    "archived": true,
    "hash": "7b18c24fd09206302eb88e076d85f1e51f855ecd",
    "submitter": {
        "id": 8,
        "url": "https://patches.dpdk.org/api/people/8/?format=api",
        "name": "Olivier Matz",
        "email": "olivier.matz@6wind.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/1479977798-13417-3-git-send-email-olivier.matz@6wind.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/17231/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/17231/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 0FDFD58C5;\n\tThu, 24 Nov 2016 09:58:07 +0100 (CET)",
            "from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com\n\t[62.23.145.76]) by dpdk.org (Postfix) with ESMTP id 3AC924CE6\n\tfor <dev@dpdk.org>; Thu, 24 Nov 2016 09:57:12 +0100 (CET)",
            "from glumotte.dev.6wind.com (unknown [10.16.0.195])\n\tby proxy.6wind.com (Postfix) with ESMTP id 76E0526D0F;\n\tThu, 24 Nov 2016 09:56:52 +0100 (CET)"
        ],
        "From": "Olivier Matz <olivier.matz@6wind.com>",
        "To": "dev@dpdk.org,\n\tyuanhan.liu@linux.intel.com",
        "Cc": "maxime.coquelin@redhat.com, huawei.xie@intel.com,\n\tstephen@networkplumber.org",
        "Date": "Thu, 24 Nov 2016 09:56:35 +0100",
        "Message-Id": "<1479977798-13417-3-git-send-email-olivier.matz@6wind.com>",
        "X-Mailer": "git-send-email 2.8.1",
        "In-Reply-To": "<1479977798-13417-1-git-send-email-olivier.matz@6wind.com>",
        "References": "<1479977798-13417-1-git-send-email-olivier.matz@6wind.com>",
        "Subject": "[dpdk-dev] [PATCH 2/5] mbuf: new helper to check if a mbuf is shared",
        "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": "Introduce 2 new helpers rte_pktmbuf_seg_is_shared() and\nrte_pktmbuf_data_is_shared() to check if the packet data inside\na mbuf is shared (and shall not be modified).\n\nTo avoid a \"discards const qualifier\" error, add a const to the argument\nof rte_mbuf_from_indirect().\n\nSigned-off-by: Olivier Matz <olivier.matz@6wind.com>\n---\n app/test/test_mbuf.c       | 34 +++++++++++++++++++---\n lib/librte_mbuf/rte_mbuf.h | 71 +++++++++++++++++++++++++++++++++++++++++++++-\n 2 files changed, 100 insertions(+), 5 deletions(-)",
    "diff": "diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c\nindex c0823ea..7656a4d 100644\n--- a/app/test/test_mbuf.c\n+++ b/app/test/test_mbuf.c\n@@ -333,6 +333,7 @@ testclone_testupdate_testdetach(void)\n \tstruct rte_mbuf *m = NULL;\n \tstruct rte_mbuf *clone = NULL;\n \tstruct rte_mbuf *clone2 = NULL;\n+\tstruct rte_mbuf *m2 = NULL;\n \tunaligned_uint32_t *data;\n \n \t/* alloc a mbuf */\n@@ -384,6 +385,11 @@ testclone_testupdate_testdetach(void)\n \tif (*data != MAGIC_DATA)\n \t\tGOTO_FAIL(\"invalid data in clone->next\\n\");\n \n+\tif (rte_pktmbuf_seg_is_shared(m) == 0)\n+\t\tGOTO_FAIL(\"m should be marked as shared\\n\");\n+\tif (rte_pktmbuf_seg_is_shared(clone) == 0)\n+\t\tGOTO_FAIL(\"clone should be marked as shared\\n\");\n+\n \tif (rte_mbuf_refcnt_read(m) != 2)\n \t\tGOTO_FAIL(\"invalid refcnt in m\\n\");\n \n@@ -410,14 +416,32 @@ testclone_testupdate_testdetach(void)\n \tif (rte_mbuf_refcnt_read(m->next) != 3)\n \t\tGOTO_FAIL(\"invalid refcnt in m->next\\n\");\n \n+\t/* prepend data to one of the clone */\n+\tm2 = rte_pktmbuf_alloc(pktmbuf_pool);\n+\tif (m2 == NULL)\n+\t\tGOTO_FAIL(\"cannot allocate m2\");\n+\trte_pktmbuf_append(m2, sizeof(uint32_t));\n+\trte_pktmbuf_chain(m2, clone);\n+\tclone = NULL;\n+\n+\tif (rte_pktmbuf_data_is_shared(m2, 0, sizeof(uint32_t)))\n+\t\tGOTO_FAIL(\"m2 headers should not be marked as shared\");\n+\tif (rte_pktmbuf_data_is_shared(m2, sizeof(uint32_t),\n+\t\t\trte_pktmbuf_pkt_len(m2) - sizeof(uint32_t)) == 0)\n+\t\tGOTO_FAIL(\"m2 data should be marked as shared\");\n+\n \t/* free mbuf */\n \trte_pktmbuf_free(m);\n-\trte_pktmbuf_free(clone);\n-\trte_pktmbuf_free(clone2);\n-\n \tm = NULL;\n-\tclone = NULL;\n+\trte_pktmbuf_free(m2);\n+\tm2 = NULL;\n+\n+\tif (rte_pktmbuf_seg_is_shared(clone2))\n+\t\tGOTO_FAIL(\"clone2 should not be marked as shared\\n\");\n+\n+\trte_pktmbuf_free(clone2);\n \tclone2 = NULL;\n+\n \tprintf(\"%s ok\\n\", __func__);\n \treturn 0;\n \n@@ -428,6 +452,8 @@ testclone_testupdate_testdetach(void)\n \t\trte_pktmbuf_free(clone);\n \tif (clone2)\n \t\trte_pktmbuf_free(clone2);\n+\tif (m2)\n+\t\trte_pktmbuf_free(m2);\n \treturn -1;\n }\n \ndiff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h\nindex 14956f6..cd77a56 100644\n--- a/lib/librte_mbuf/rte_mbuf.h\n+++ b/lib/librte_mbuf/rte_mbuf.h\n@@ -576,7 +576,7 @@ rte_mbuf_data_dma_addr_default(const struct rte_mbuf *mb)\n  *   The address of the direct mbuf corresponding to buffer_addr.\n  */\n static inline struct rte_mbuf *\n-rte_mbuf_from_indirect(struct rte_mbuf *mi)\n+rte_mbuf_from_indirect(const struct rte_mbuf *mi)\n {\n \treturn (struct rte_mbuf *)RTE_PTR_SUB(mi->buf_addr, sizeof(*mi) + mi->priv_size);\n }\n@@ -1574,6 +1574,75 @@ static inline int rte_pktmbuf_is_contiguous(const struct rte_mbuf *m)\n }\n \n /**\n+ * Test if a mbuf segment is shared\n+ *\n+ * Return true if the data embedded in this segment is shared by several\n+ * mbufs. In this case, the mbuf data should be considered as read-only.\n+ *\n+ * @param m\n+ *   The packet mbuf.\n+ * @return\n+ *   - (1), the mbuf segment is shared (read-only)\n+ *   - (0), the mbuf segment is not shared (writable)\n+ */\n+static inline int rte_pktmbuf_seg_is_shared(const struct rte_mbuf *m)\n+{\n+\tif (rte_mbuf_refcnt_read(m) > 1)\n+\t\treturn 1;\n+\n+\tif (RTE_MBUF_INDIRECT(m) &&\n+\t\t\trte_mbuf_refcnt_read(rte_mbuf_from_indirect(m)) > 1)\n+\t\treturn 1;\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * Test if some data in an mbuf chain is shared\n+ *\n+ * Return true if the specified data area in the mbuf chain is shared by\n+ * several mbufs. In this case, this data should be considered as\n+ * read-only.\n+ *\n+ * If the area described by off and len exceeds the bounds of the mbuf\n+ * chain (off + len <= rte_pktmbuf_pkt_len()), the exceeding part of the\n+ * area is ignored.\n+ *\n+ * @param m\n+ *   The packet mbuf.\n+ * @return\n+ *   - (1), the mbuf data is shared (read-only)\n+ *   - (0), the mbuf data is not shared (writable)\n+ */\n+static inline int rte_pktmbuf_data_is_shared(const struct rte_mbuf *m,\n+\tuint32_t off, uint32_t len)\n+{\n+\tconst struct rte_mbuf *seg = m;\n+\n+\tif (likely(off + len <= rte_pktmbuf_data_len(seg)))\n+\t\treturn rte_pktmbuf_seg_is_shared(seg);\n+\n+\twhile (seg->next && off >= rte_pktmbuf_data_len(seg)) {\n+\t\toff -= rte_pktmbuf_data_len(seg);\n+\t\tseg = seg->next;\n+\t}\n+\n+\tif (off + len <= rte_pktmbuf_data_len(seg))\n+\t\treturn rte_pktmbuf_seg_is_shared(seg);\n+\n+\twhile (seg->next && len > 0) {\n+\t\tif (rte_pktmbuf_seg_is_shared(seg))\n+\t\t\treturn 1;\n+\n+\t\tlen -= (rte_pktmbuf_data_len(seg) - off);\n+\t\toff = 0;\n+\t\tseg = seg->next;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/**\n  * @internal used by rte_pktmbuf_read().\n  */\n void *__rte_pktmbuf_read(const struct rte_mbuf *m, uint32_t off,\n",
    "prefixes": [
        "dpdk-dev",
        "2/5"
    ]
}