get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 38232,
    "url": "https://patches.dpdk.org/api/patches/38232/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20180416150058.2620-10-adrien.mazarguil@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": "<20180416150058.2620-10-adrien.mazarguil@6wind.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20180416150058.2620-10-adrien.mazarguil@6wind.com",
    "date": "2018-04-16T16:22:03",
    "name": "[dpdk-dev,v5,09/11] ethdev: fix shallow copy of flow API RSS action",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "08cf5ae0edeb0e8789c8766b3cfd17c0ae4359cc",
    "submitter": {
        "id": 165,
        "url": "https://patches.dpdk.org/api/people/165/?format=api",
        "name": "Adrien Mazarguil",
        "email": "adrien.mazarguil@6wind.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20180416150058.2620-10-adrien.mazarguil@6wind.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/38232/comments/",
    "check": "fail",
    "checks": "https://patches.dpdk.org/api/patches/38232/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 [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 881782BEB;\n\tMon, 16 Apr 2018 18:22:35 +0200 (CEST)",
            "from mail-wr0-f177.google.com (mail-wr0-f177.google.com\n\t[209.85.128.177]) by dpdk.org (Postfix) with ESMTP id 443AED49E\n\tfor <dev@dpdk.org>; Mon, 16 Apr 2018 18:22:17 +0200 (CEST)",
            "by mail-wr0-f177.google.com with SMTP id z73so27708702wrb.0\n\tfor <dev@dpdk.org>; Mon, 16 Apr 2018 09:22:17 -0700 (PDT)",
            "from 6wind.com (host.78.145.23.62.rev.coltfrance.com.\n\t[62.23.145.78]) by smtp.gmail.com with ESMTPSA id\n\te64sm10664983wmg.22.2018.04.16.09.22.16\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tMon, 16 Apr 2018 09:22:16 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=6wind-com.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:in-reply-to;\n\tbh=rirFOPGE7wLIcP5j4weXanNGGjHfuPw9gYghrdCnQaQ=;\n\tb=NC/JK4pGpM1FZKFJM3dn7CK/PpxK+JGi0e4wUDlKvDAmidrxKdvzYyRUjItNs/Q6wu\n\tSWMw956434/eYdvxSxLwMqLRnyNPfHnXlvwiUxL1MLy2IpHt66QrudFXpOuTgMr94ALG\n\t7Nm3KvaWnxhhJqs04BU+hlry3Slm4fHEWpiK0ySF0xTtBoKzPEAu45rbcg5HQ0Q8DHcO\n\tfNm+6Eh3aFtD//3knXwFbNHJ65WEPD9O2unLPMw0KMZA51KRPAKfylpsGLesHry9HlmC\n\tGSXn1oYCFnuKFBbWXR06ZECFnpiILmfFiVh/FHSNqAbhNp0SOLohawr6ivvKldpieaHs\n\tpT4w==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:in-reply-to;\n\tbh=rirFOPGE7wLIcP5j4weXanNGGjHfuPw9gYghrdCnQaQ=;\n\tb=pU0M4eyhdhbhNs18l35g3ju0yDBoiM/HQ9L4RZr37gHSafNqvLRzLwlKTupIphKNFE\n\tQmsaearHOeDQD0suPw/0crzmVsDLJA941CVcK3UDKpYTv3aTm5vqLkc0LHpWy/vCSi7O\n\t5pe1a6UxMw0iH4yS3AHKoHbEVo/8ORFc1p18tQh5EedDw5G3yUwa+h6DXZZCzyYhBWv7\n\tWYi8HuArYA/zE6KOqzpV3R1nw8+fTn/KL5cOIbBilkD/pDZOTwxh3lwfs/iZckAkrlzV\n\tTuu4JQqJ8QSIxHcFku3Lu3PuUlKlhzyypoLnB8t/sig7sv+r0dbUlTDyM+RhSlvj42Ip\n\te1PA==",
        "X-Gm-Message-State": "ALQs6tD+fxXObDiNtM9Fai29u8NAyiOb0y7op+3qmlXS9vgWfX1qFwVk\n\tGyzP8wD6WAN+dpbxQReUC5Ua7y/U",
        "X-Google-Smtp-Source": "AIpwx48YaQ0C9Gk3Lninh8LIN7V1vL3v8+HBW50hN3gKec0/+ysx7bSv1JTZvFsinv9sBTgGjwaGag==",
        "X-Received": "by 10.223.178.88 with SMTP id y24mr8246159wra.70.1523895737426; \n\tMon, 16 Apr 2018 09:22:17 -0700 (PDT)",
        "Date": "Mon, 16 Apr 2018 18:22:03 +0200",
        "From": "Adrien Mazarguil <adrien.mazarguil@6wind.com>",
        "To": "dev@dpdk.org",
        "Cc": "stable@dpdk.org, Gaetan Rivet <gaetan.rivet@6wind.com>,\n\tThomas Monjalon <thomas@monjalon.net>",
        "Message-ID": "<20180416150058.2620-10-adrien.mazarguil@6wind.com>",
        "References": "<20180410161132.8776-1-adrien.mazarguil@6wind.com>\n\t<20180416150058.2620-1-adrien.mazarguil@6wind.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=us-ascii",
        "Content-Disposition": "inline",
        "In-Reply-To": "<20180416150058.2620-1-adrien.mazarguil@6wind.com>",
        "X-Mailer": "git-send-email 2.11.0",
        "Subject": "[dpdk-dev] [PATCH v5 09/11] ethdev: fix shallow copy of flow API\n\tRSS action",
        "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://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": "<https://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": "The rss_conf field is defined as a pointer to struct rte_eth_rss_conf.\n\nEven assuming it is permanently allocated and a pointer copy is safe,\npointed data may change and not reflect an applied flow rule anymore.\n\nThis patch aligns with testpmd by making a deep copy instead.\n\nFixes: 18da437b5f63 (\"ethdev: add flow rule copy function\")\nCc: stable@dpdk.org\nCc: Gaetan Rivet <gaetan.rivet@6wind.com>\n\nSigned-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>\nCc: Thomas Monjalon <thomas@monjalon.net>\n---\n lib/librte_ether/rte_flow.c | 145 +++++++++++++++++++++++++++------------\n 1 file changed, 102 insertions(+), 43 deletions(-)",
    "diff": "diff --git a/lib/librte_ether/rte_flow.c b/lib/librte_ether/rte_flow.c\nindex a3823d874..ada280810 100644\n--- a/lib/librte_ether/rte_flow.c\n+++ b/lib/librte_ether/rte_flow.c\n@@ -255,60 +255,119 @@ rte_flow_error_set(struct rte_flow_error *error,\n \treturn -code;\n }\n \n-/** Compute storage space needed by item specification. */\n-static void\n-flow_item_spec_size(const struct rte_flow_item *item,\n-\t\t    size_t *size, size_t *pad)\n+/** Pattern item specification types. */\n+enum item_spec_type {\n+\tITEM_SPEC,\n+\tITEM_LAST,\n+\tITEM_MASK,\n+};\n+\n+/** Compute storage space needed by item specification and copy it. */\n+static size_t\n+flow_item_spec_copy(void *buf, const struct rte_flow_item *item,\n+\t\t    enum item_spec_type type)\n {\n-\tif (!item->spec) {\n-\t\t*size = 0;\n+\tsize_t size = 0;\n+\tconst void *item_spec =\n+\t\ttype == ITEM_SPEC ? item->spec :\n+\t\ttype == ITEM_LAST ? item->last :\n+\t\ttype == ITEM_MASK ? item->mask :\n+\t\tNULL;\n+\n+\tif (!item_spec)\n \t\tgoto empty;\n-\t}\n \tswitch (item->type) {\n \t\tunion {\n \t\t\tconst struct rte_flow_item_raw *raw;\n-\t\t} spec;\n+\t\t} src;\n+\t\tunion {\n+\t\t\tstruct rte_flow_item_raw *raw;\n+\t\t} dst;\n \n-\t/* Not a fall-through */\n \tcase RTE_FLOW_ITEM_TYPE_RAW:\n-\t\tspec.raw = item->spec;\n-\t\t*size = offsetof(struct rte_flow_item_raw, pattern) +\n-\t\t\tspec.raw->length * sizeof(*spec.raw->pattern);\n+\t\tsrc.raw = item_spec;\n+\t\tdst.raw = buf;\n+\t\tsize = offsetof(struct rte_flow_item_raw, pattern) +\n+\t\t\tsrc.raw->length * sizeof(*src.raw->pattern);\n+\t\tif (dst.raw)\n+\t\t\tmemcpy(dst.raw, src.raw, size);\n \t\tbreak;\n \tdefault:\n-\t\t*size = rte_flow_desc_item[item->type].size;\n+\t\tsize = rte_flow_desc_item[item->type].size;\n+\t\tif (buf)\n+\t\t\tmemcpy(buf, item_spec, size);\n \t\tbreak;\n \t}\n empty:\n-\t*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;\n+\treturn RTE_ALIGN_CEIL(size, sizeof(double));\n }\n \n-/** Compute storage space needed by action configuration. */\n-static void\n-flow_action_conf_size(const struct rte_flow_action *action,\n-\t\t      size_t *size, size_t *pad)\n+/** Compute storage space needed by action configuration and copy it. */\n+static size_t\n+flow_action_conf_copy(void *buf, const struct rte_flow_action *action)\n {\n-\tif (!action->conf) {\n-\t\t*size = 0;\n+\tsize_t size = 0;\n+\n+\tif (!action->conf)\n \t\tgoto empty;\n-\t}\n \tswitch (action->type) {\n \t\tunion {\n \t\t\tconst struct rte_flow_action_rss *rss;\n-\t\t} conf;\n+\t\t} src;\n+\t\tunion {\n+\t\t\tstruct rte_flow_action_rss *rss;\n+\t\t} dst;\n+\t\tsize_t off;\n \n-\t/* Not a fall-through. */\n \tcase RTE_FLOW_ACTION_TYPE_RSS:\n-\t\tconf.rss = action->conf;\n-\t\t*size = offsetof(struct rte_flow_action_rss, queue) +\n-\t\t\tconf.rss->num * sizeof(*conf.rss->queue);\n+\t\tsrc.rss = action->conf;\n+\t\tdst.rss = buf;\n+\t\toff = 0;\n+\t\tif (dst.rss)\n+\t\t\t*dst.rss = (struct rte_flow_action_rss){\n+\t\t\t\t.num = src.rss->num,\n+\t\t\t};\n+\t\toff += offsetof(struct rte_flow_action_rss, queue);\n+\t\tif (src.rss->num) {\n+\t\t\tsize = sizeof(*src.rss->queue) * src.rss->num;\n+\t\t\tif (dst.rss)\n+\t\t\t\tmemcpy(dst.rss->queue, src.rss->queue, size);\n+\t\t\toff += size;\n+\t\t}\n+\t\toff = RTE_ALIGN_CEIL(off, sizeof(double));\n+\t\tif (dst.rss) {\n+\t\t\tdst.rss->rss_conf = (void *)((uintptr_t)dst.rss + off);\n+\t\t\t*(struct rte_eth_rss_conf *)(uintptr_t)\n+\t\t\t\tdst.rss->rss_conf = (struct rte_eth_rss_conf){\n+\t\t\t\t.rss_key_len = src.rss->rss_conf->rss_key_len,\n+\t\t\t\t.rss_hf = src.rss->rss_conf->rss_hf,\n+\t\t\t};\n+\t\t}\n+\t\toff += sizeof(*src.rss->rss_conf);\n+\t\tif (src.rss->rss_conf->rss_key_len) {\n+\t\t\toff = RTE_ALIGN_CEIL(off, sizeof(double));\n+\t\t\tsize = sizeof(*src.rss->rss_conf->rss_key) *\n+\t\t\t\tsrc.rss->rss_conf->rss_key_len;\n+\t\t\tif (dst.rss) {\n+\t\t\t\t((struct rte_eth_rss_conf *)(uintptr_t)\n+\t\t\t\t dst.rss->rss_conf)->rss_key =\n+\t\t\t\t\t(void *)((uintptr_t)dst.rss + off);\n+\t\t\t\tmemcpy(dst.rss->rss_conf->rss_key,\n+\t\t\t\t       src.rss->rss_conf->rss_key,\n+\t\t\t\t       size);\n+\t\t\t}\n+\t\t\toff += size;\n+\t\t}\n+\t\tsize = off;\n \t\tbreak;\n \tdefault:\n-\t\t*size = rte_flow_desc_action[action->type].size;\n+\t\tsize = rte_flow_desc_action[action->type].size;\n+\t\tif (buf)\n+\t\t\tmemcpy(buf, action->conf, size);\n \t\tbreak;\n \t}\n empty:\n-\t*pad = RTE_ALIGN_CEIL(*size, sizeof(double)) - *size;\n+\treturn RTE_ALIGN_CEIL(size, sizeof(double));\n }\n \n /** Store a full rte_flow description. */\n@@ -320,7 +379,6 @@ rte_flow_copy(struct rte_flow_desc *desc, size_t len,\n {\n \tstruct rte_flow_desc *fd = NULL;\n \tsize_t tmp;\n-\tsize_t pad;\n \tsize_t off1 = 0;\n \tsize_t off2 = 0;\n \tsize_t size = 0;\n@@ -345,24 +403,26 @@ rte_flow_copy(struct rte_flow_desc *desc, size_t len,\n \t\t\t\tdst = memcpy(fd->data + off1, item,\n \t\t\t\t\t     sizeof(*item));\n \t\t\toff1 += sizeof(*item);\n-\t\t\tflow_item_spec_size(item, &tmp, &pad);\n \t\t\tif (item->spec) {\n \t\t\t\tif (fd)\n-\t\t\t\t\tdst->spec = memcpy(fd->data + off2,\n-\t\t\t\t\t\t\t   item->spec, tmp);\n-\t\t\t\toff2 += tmp + pad;\n+\t\t\t\t\tdst->spec = fd->data + off2;\n+\t\t\t\toff2 += flow_item_spec_copy\n+\t\t\t\t\t(fd ? fd->data + off2 : NULL, item,\n+\t\t\t\t\t ITEM_SPEC);\n \t\t\t}\n \t\t\tif (item->last) {\n \t\t\t\tif (fd)\n-\t\t\t\t\tdst->last = memcpy(fd->data + off2,\n-\t\t\t\t\t\t\t   item->last, tmp);\n-\t\t\t\toff2 += tmp + pad;\n+\t\t\t\t\tdst->last = fd->data + off2;\n+\t\t\t\toff2 += flow_item_spec_copy\n+\t\t\t\t\t(fd ? fd->data + off2 : NULL, item,\n+\t\t\t\t\t ITEM_LAST);\n \t\t\t}\n \t\t\tif (item->mask) {\n \t\t\t\tif (fd)\n-\t\t\t\t\tdst->mask = memcpy(fd->data + off2,\n-\t\t\t\t\t\t\t   item->mask, tmp);\n-\t\t\t\toff2 += tmp + pad;\n+\t\t\t\t\tdst->mask = fd->data + off2;\n+\t\t\t\toff2 += flow_item_spec_copy\n+\t\t\t\t\t(fd ? fd->data + off2 : NULL, item,\n+\t\t\t\t\t ITEM_MASK);\n \t\t\t}\n \t\t\toff2 = RTE_ALIGN_CEIL(off2, sizeof(double));\n \t\t} while ((item++)->type != RTE_FLOW_ITEM_TYPE_END);\n@@ -387,12 +447,11 @@ rte_flow_copy(struct rte_flow_desc *desc, size_t len,\n \t\t\t\tdst = memcpy(fd->data + off1, action,\n \t\t\t\t\t     sizeof(*action));\n \t\t\toff1 += sizeof(*action);\n-\t\t\tflow_action_conf_size(action, &tmp, &pad);\n \t\t\tif (action->conf) {\n \t\t\t\tif (fd)\n-\t\t\t\t\tdst->conf = memcpy(fd->data + off2,\n-\t\t\t\t\t\t\t   action->conf, tmp);\n-\t\t\t\toff2 += tmp + pad;\n+\t\t\t\t\tdst->conf = fd->data + off2;\n+\t\t\t\toff2 += flow_action_conf_copy\n+\t\t\t\t\t(fd ? fd->data + off2 : NULL, action);\n \t\t\t}\n \t\t\toff2 = RTE_ALIGN_CEIL(off2, sizeof(double));\n \t\t} while ((action++)->type != RTE_FLOW_ACTION_TYPE_END);\n",
    "prefixes": [
        "dpdk-dev",
        "v5",
        "09/11"
    ]
}