Show a patch.

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

{
    "id": 44464,
    "url": "http://patches.dpdk.org/api/patches/44464/?format=api",
    "web_url": "http://patches.dpdk.org/patch/44464/",
    "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"
    },
    "msgid": "<20180910054547.18494-3-david.marchand@6wind.com>",
    "date": "2018-09-10T05:45:46",
    "name": "[2/3] mbuf: add a non fatal sanity check helper",
    "commit_ref": null,
    "pull_url": null,
    "state": "changes-requested",
    "archived": true,
    "hash": "8b89cece97604499243ca5499eae69abc8129396",
    "submitter": {
        "id": 3,
        "url": "http://patches.dpdk.org/api/people/3/?format=api",
        "name": "David Marchand",
        "email": "david.marchand@6wind.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/patch/44464/mbox/",
    "series": [
        {
            "id": 1241,
            "url": "http://patches.dpdk.org/api/series/1241/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1241",
            "date": "2018-09-10T05:45:44",
            "name": "segment sanity checks",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/1241/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/44464/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/44464/checks/",
    "tags": {},
    "headers": {
        "X-Mailer": "git-send-email 2.17.1",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "From": "David Marchand <david.marchand@6wind.com>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=6wind-com.20150623.gappssmtp.com; s=20150623;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=kVBRpwdIa3RbjcBqDAGG0KZBtffIViGt9wurQdHS/Ck=;\n\tb=1kotq6s0eKHm5haJ/zJMp5UHvicoDvMUdpKRkJvaUDaWCr9ibYiRUC2jZMbKkoRBNi\n\tnDwoeJxsmO8UgJfC7e7a7h6+s3COb0dhrYhm7L+W6kUoLS+bhC9qiquXOVUdB1FgqKU/\n\tHSf/M3S4ydnbqQQo/lbNICWfRjWdAzFQVvavZWm+gukCRnWG4cm5Bk8xawI2QRLyRxJd\n\tfrkiglNIcBN+QkHEeT4fR2JpZeGw9uAFpa2ncHbUIxtcDvtP40vyiOSpa9lpJSEHQ9Pw\n\tzLHXcTy299YQr2FQT5Q6MqwJqn0/yPQDnSAoGZeBndImZ+AN75+LDLmQRBNUQA8qeDR0\n\tFURA==",
        "X-Mailman-Version": "2.1.15",
        "Delivered-To": "patchwork@dpdk.org",
        "X-Gm-Message-State": "APzg51CVxg+NoMEYIlg7SUDfWjdnwdioG0QzTCwka2g0I5vw5goWmsiI\n\tm7v8X4pjx744R3COK8h7kgZNLThJVaU=",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Cc": "olivier.matz@6wind.com, wenzhuo.lu@intel.com, jingjing.wu@intel.com,\n\tbernard.iremonger@intel.com",
        "To": "dev@dpdk.org",
        "Errors-To": "dev-bounces@dpdk.org",
        "References": "<20180910054547.18494-1-david.marchand@6wind.com>",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=kVBRpwdIa3RbjcBqDAGG0KZBtffIViGt9wurQdHS/Ck=;\n\tb=txHhxRUYp1Z0OSQqOdRzmepS8vwJwQiWMqmn1ugAP9vbC66ot+9QYiJooefum1vLOk\n\tbltUiEDm7EfoNFY0f9w8EMmZar4NOHhgqqJX49diTk6MlGpk7A4swcWwRneV+NLtGLEx\n\t24kWmQVOM0p0JfvgRVMaqvp19gB7n/LVlPrD9jfna4pn1UKDcCni84nUXmMHzPRyTPJD\n\tURQTk8Hp8H0L5KjnYW9t7Kjcmqr/h85TenWkySaUXSmqecHZvYYfE5mIlPUB0EcSXI75\n\tGjPzqMkWrYMj164DZmpTQHGH+pYgAId9u/UavFay2skRibVO9KmzbnU931OxBunHJbL8\n\tp6Ug==",
        "Return-Path": "<dev-bounces@dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 9BD5D4CA0;\n\tMon, 10 Sep 2018 07:45:58 +0200 (CEST)",
            "from mail-wr1-f67.google.com (mail-wr1-f67.google.com\n\t[209.85.221.67]) by dpdk.org (Postfix) with ESMTP id 0C0724C9D\n\tfor <dev@dpdk.org>; Mon, 10 Sep 2018 07:45:58 +0200 (CEST)",
            "by mail-wr1-f67.google.com with SMTP id v16-v6so20432752wro.11\n\tfor <dev@dpdk.org>; Sun, 09 Sep 2018 22:45:58 -0700 (PDT)",
            "from 6wind.com ([109.190.253.16]) by smtp.gmail.com with ESMTPSA id\n\tt4-v6sm14667473wrb.45.2018.09.09.22.45.55\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tSun, 09 Sep 2018 22:45:56 -0700 (PDT)"
        ],
        "Date": "Mon, 10 Sep 2018 07:45:46 +0200",
        "X-Received": "by 2002:adf:ad8e:: with SMTP id\n\tw14-v6mr14633893wrc.178.1536558357475; \n\tSun, 09 Sep 2018 22:45:57 -0700 (PDT)",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>",
        "Subject": "[dpdk-dev] [PATCH 2/3] mbuf: add a non fatal sanity check helper",
        "In-Reply-To": "<20180910054547.18494-1-david.marchand@6wind.com>",
        "Message-Id": "<20180910054547.18494-3-david.marchand@6wind.com>",
        "Precedence": "list",
        "X-BeenThere": "dev@dpdk.org",
        "X-Original-To": "patchwork@dpdk.org",
        "X-Google-Smtp-Source": "ANB0VdbUIvjrKQ3k6Q577rDXuVzTOzm9Iu2BjZhkjMCjq44RscktS4udie976hcQo2rxkq414rvvFg=="
    },
    "content": "Let's add a little helper that does the same as rte_mbuf_sanity_check but\nwithout the panic.\n\nSigned-off-by: David Marchand <david.marchand@6wind.com>\n---\n lib/librte_mbuf/Makefile             |  2 +\n lib/librte_mbuf/meson.build          |  2 +\n lib/librte_mbuf/rte_mbuf.c           | 74 ++++++++++++++++++++--------\n lib/librte_mbuf/rte_mbuf.h           | 23 +++++++++\n lib/librte_mbuf/rte_mbuf_version.map |  6 +++\n 5 files changed, 86 insertions(+), 21 deletions(-)",
    "diff": "diff --git a/lib/librte_mbuf/Makefile b/lib/librte_mbuf/Makefile\nindex e2b98a254..7d0c824a3 100644\n--- a/lib/librte_mbuf/Makefile\n+++ b/lib/librte_mbuf/Makefile\n@@ -7,6 +7,8 @@ include $(RTE_SDK)/mk/rte.vars.mk\n LIB = librte_mbuf.a\n \n CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3\n+CFLAGS += -DALLOW_EXPERIMENTAL_API\n+\n LDLIBS += -lrte_eal -lrte_mempool\n \n EXPORT_MAP := rte_mbuf_version.map\ndiff --git a/lib/librte_mbuf/meson.build b/lib/librte_mbuf/meson.build\nindex 45ffb0db5..4d9bdf2ba 100644\n--- a/lib/librte_mbuf/meson.build\n+++ b/lib/librte_mbuf/meson.build\n@@ -5,3 +5,5 @@ version = 3\n sources = files('rte_mbuf.c', 'rte_mbuf_ptype.c', 'rte_mbuf_pool_ops.c')\n headers = files('rte_mbuf.h', 'rte_mbuf_ptype.h', 'rte_mbuf_pool_ops.h')\n deps += ['mempool']\n+\n+allow_experimental_apis = true\ndiff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c\nindex 137a320ed..4e65f0f82 100644\n--- a/lib/librte_mbuf/rte_mbuf.c\n+++ b/lib/librte_mbuf/rte_mbuf.c\n@@ -170,49 +170,81 @@ rte_pktmbuf_pool_create(const char *name, unsigned int n,\n /* do some sanity checks on a mbuf: panic if it fails */\n void\n rte_mbuf_sanity_check(const struct rte_mbuf *m, int is_header)\n+{\n+\tconst char *reason;\n+\n+\tif (rte_mbuf_check(m, is_header, &reason))\n+\t\trte_panic(\"%s\\n\", reason);\n+}\n+\n+__rte_experimental\n+int rte_mbuf_check(const struct rte_mbuf *m, int is_header,\n+\t\t   const char **reason)\n {\n \tunsigned int nb_segs, pkt_len;\n \n-\tif (m == NULL)\n-\t\trte_panic(\"mbuf is NULL\\n\");\n+\tif (m == NULL) {\n+\t\t*reason = \"mbuf is NULL\";\n+\t\treturn -1;\n+\t}\n \n \t/* generic checks */\n-\tif (m->pool == NULL)\n-\t\trte_panic(\"bad mbuf pool\\n\");\n-\tif (m->buf_iova == 0)\n-\t\trte_panic(\"bad IO addr\\n\");\n-\tif (m->buf_addr == NULL)\n-\t\trte_panic(\"bad virt addr\\n\");\n+\tif (m->pool == NULL) {\n+\t\t*reason = \"bad mbuf pool\";\n+\t\treturn -1;\n+\t}\n+\tif (m->buf_iova == 0) {\n+\t\t*reason = \"bad IO addr\";\n+\t\treturn -1;\n+\t}\n+\tif (m->buf_addr == NULL) {\n+\t\t*reason = \"bad virt addr\";\n+\t\treturn -1;\n+\t}\n \n \tuint16_t cnt = rte_mbuf_refcnt_read(m);\n-\tif ((cnt == 0) || (cnt == UINT16_MAX))\n-\t\trte_panic(\"bad ref cnt\\n\");\n+\tif ((cnt == 0) || (cnt == UINT16_MAX)) {\n+\t\t*reason = \"bad ref cnt\";\n+\t\treturn -1;\n+\t}\n \n \t/* nothing to check for sub-segments */\n \tif (is_header == 0)\n-\t\treturn;\n+\t\treturn 0;\n \n \t/* data_len is supposed to be not more than pkt_len */\n-\tif (m->data_len > m->pkt_len)\n-\t\trte_panic(\"bad data_len\\n\");\n+\tif (m->data_len > m->pkt_len) {\n+\t\t*reason = \"bad data_len\";\n+\t\treturn -1;\n+\t}\n \n \tnb_segs = m->nb_segs;\n \tpkt_len = m->pkt_len;\n \n \tdo {\n-\t\tif (m->data_off > m->buf_len)\n-\t\t\trte_panic(\"data offset too big in mbuf segment\\n\");\n+\t\tif (m->data_off > m->buf_len) {\n+\t\t\t*reason = \"data offset too big in mbuf segment\";\n+\t\t\treturn -1;\n+\t\t}\n \t\tif ((uint32_t)m->data_off + (uint32_t)m->data_len >\n-\t\t\t\t(uint32_t)m->buf_len)\n-\t\t\trte_panic(\"data length too big in mbuf segment\\n\");\n+\t\t\t\t(uint32_t)m->buf_len) {\n+\t\t\t*reason = \"data length too big in mbuf segment\";\n+\t\t\treturn -1;\n+\t\t}\n \t\tnb_segs -= 1;\n \t\tpkt_len -= m->data_len;\n \t} while ((m = m->next) != NULL);\n \n-\tif (nb_segs)\n-\t\trte_panic(\"bad nb_segs\\n\");\n-\tif (pkt_len)\n-\t\trte_panic(\"bad pkt_len\\n\");\n+\tif (nb_segs) {\n+\t\t*reason = \"bad nb_segs\";\n+\t\treturn -1;\n+\t}\n+\tif (pkt_len) {\n+\t\t*reason = \"bad pkt_len\";\n+\t\treturn -1;\n+\t}\n+\n+\treturn 0;\n }\n \n /* dump a mbuf on console */\ndiff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h\nindex a50b05c64..e12a4c765 100644\n--- a/lib/librte_mbuf/rte_mbuf.h\n+++ b/lib/librte_mbuf/rte_mbuf.h\n@@ -977,6 +977,29 @@ rte_mbuf_ext_refcnt_update(struct rte_mbuf_ext_shared_info *shinfo,\n void\n rte_mbuf_sanity_check(const struct rte_mbuf *m, int is_header);\n \n+/**\n+ * Sanity checks on a mbuf.\n+ *\n+ * Almost like rte_mbuf_sanity_check(), but this function gives the reason\n+ * if corruption is detected rather than panic.\n+ *\n+ * @param m\n+ *   The mbuf to be checked.\n+ * @param is_header\n+ *   True if the mbuf is a packet header, false if it is a sub-segment\n+ *   of a packet (in this case, some fields like nb_segs are not checked)\n+ * @param reason\n+ *   A reference to a string pointer where to store the reason why a mbuf is\n+ *   considered invalid.\n+ * @return\n+ *   - 0 if no issue has been found, reason is left untouched.\n+ *   - -1 if a problem is detected, reason then points to a string describing\n+ *     the reason why the mbuf is deemed invalid.\n+ */\n+__rte_experimental\n+int rte_mbuf_check(const struct rte_mbuf *m, int is_header,\n+\t\t   const char **reason);\n+\n #define MBUF_RAW_ALLOC_CHECK(m) do {\t\t\t\t\\\n \tRTE_ASSERT(rte_mbuf_refcnt_read(m) == 1);\t\t\\\n \tRTE_ASSERT((m)->next == NULL);\t\t\t\t\\\ndiff --git a/lib/librte_mbuf/rte_mbuf_version.map b/lib/librte_mbuf/rte_mbuf_version.map\nindex cae68db8d..2662a37bf 100644\n--- a/lib/librte_mbuf/rte_mbuf_version.map\n+++ b/lib/librte_mbuf/rte_mbuf_version.map\n@@ -45,3 +45,9 @@ DPDK_18.08 {\n \trte_mbuf_user_mempool_ops;\n \trte_pktmbuf_pool_create_by_ops;\n } DPDK_16.11;\n+\n+EXPERIMENTAL {\n+\tglobal:\n+\n+\trte_mbuf_check;\n+} DPDK_18.08;\n",
    "prefixes": [
        "2/3"
    ]
}