get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 815503,
    "url": "http://patchwork.ozlabs.org/api/patches/815503/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/netfilter-devel/patch/20170919124954.26852-2-fw@strlen.de/",
    "project": {
        "id": 26,
        "url": "http://patchwork.ozlabs.org/api/projects/26/?format=api",
        "name": "Netfilter Development",
        "link_name": "netfilter-devel",
        "list_id": "netfilter-devel.vger.kernel.org",
        "list_email": "netfilter-devel@vger.kernel.org",
        "web_url": null,
        "scm_url": null,
        "webscm_url": null,
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20170919124954.26852-2-fw@strlen.de>",
    "list_archive_url": null,
    "date": "2017-09-19T12:49:53",
    "name": "[nft,1/2] evaluate: prepare to store expr key rather than datatype",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "6686890f965959eaaea2bac26115d1020d750af4",
    "submitter": {
        "id": 1025,
        "url": "http://patchwork.ozlabs.org/api/people/1025/?format=api",
        "name": "Florian Westphal",
        "email": "fw@strlen.de"
    },
    "delegate": {
        "id": 11902,
        "url": "http://patchwork.ozlabs.org/api/users/11902/?format=api",
        "username": "strlen",
        "first_name": "Florian",
        "last_name": "Westphal",
        "email": "fw@strlen.de"
    },
    "mbox": "http://patchwork.ozlabs.org/project/netfilter-devel/patch/20170919124954.26852-2-fw@strlen.de/mbox/",
    "series": [
        {
            "id": 3866,
            "url": "http://patchwork.ozlabs.org/api/series/3866/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/netfilter-devel/list/?series=3866",
            "date": "2017-09-19T12:49:52",
            "name": "store expression instead of data type as set key",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/3866/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/815503/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/815503/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<netfilter-devel-owner@vger.kernel.org>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org",
        "Authentication-Results": "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netfilter-devel-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)",
        "Received": [
            "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xxN4P3c4Bz9s7c\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 19 Sep 2017 22:49:41 +1000 (AEST)",
            "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751868AbdISMtl (ORCPT <rfc822;incoming@patchwork.ozlabs.org>);\n\tTue, 19 Sep 2017 08:49:41 -0400",
            "from Chamillionaire.breakpoint.cc ([146.0.238.67]:54694 \"EHLO\n\tChamillionaire.breakpoint.cc\" rhost-flags-OK-OK-OK-OK)\n\tby vger.kernel.org with ESMTP id S1751687AbdISMtk (ORCPT\n\t<rfc822;netfilter-devel@vger.kernel.org>);\n\tTue, 19 Sep 2017 08:49:40 -0400",
            "from fw by Chamillionaire.breakpoint.cc with local (Exim 4.84_2)\n\t(envelope-from <fw@breakpoint.cc>)\n\tid 1duHux-0003Dh-BS; Tue, 19 Sep 2017 14:46:23 +0200"
        ],
        "From": "Florian Westphal <fw@strlen.de>",
        "To": "<netfilter-devel@vger.kernel.org>",
        "Cc": "Florian Westphal <fw@strlen.de>",
        "Subject": "[PATCH nft 1/2] evaluate: prepare to store expr key rather than\n\tdatatype",
        "Date": "Tue, 19 Sep 2017 14:49:53 +0200",
        "Message-Id": "<20170919124954.26852-2-fw@strlen.de>",
        "X-Mailer": "git-send-email 2.13.5",
        "In-Reply-To": "<20170919124954.26852-1-fw@strlen.de>",
        "References": "<20170919124954.26852-1-fw@strlen.de>",
        "Sender": "netfilter-devel-owner@vger.kernel.org",
        "Precedence": "bulk",
        "List-ID": "<netfilter-devel.vger.kernel.org>",
        "X-Mailing-List": "netfilter-devel@vger.kernel.org"
    },
    "content": "currently set definitions store a datatype rather than\nan expression.\n\nIn order to support use of unqualified data types (string in particular),\nthis prepares implicit set definition helper to expect an expression instead\nof plain data type.  This also has the advantage that we can use EXPR_CONCAT\nto retain the original expressions when key concatentation is used, e.g.\n'meta iifname . tcp dport'.  The netlink serialization code can use\nthis info to store individual key lengths independently of data types.\n\nWould also allow later on to store the original names of the\nexpressions, e.g. \"ip daddr\", in the kernel to support a future\ntypeof keyword, e.g. 'type typeof(ip daddr)' instead of 'type ipv4_addr'.\n\nSigned-off-by: Florian Westphal <fw@strlen.de>\n---\n src/evaluate.c | 42 +++++++++++++++++++++++-------------------\n 1 file changed, 23 insertions(+), 19 deletions(-)",
    "diff": "diff --git a/src/evaluate.c b/src/evaluate.c\nindex e767542a868e..86159cf55f94 100644\n--- a/src/evaluate.c\n+++ b/src/evaluate.c\n@@ -62,9 +62,7 @@ static int __fmtstring(3, 4) set_error(struct eval_ctx *ctx,\n \n static struct expr *implicit_set_declaration(struct eval_ctx *ctx,\n \t\t\t\t\t     const char *name,\n-\t\t\t\t\t     const struct datatype *keytype,\n-\t\t\t\t\t     unsigned int keylen,\n-\t\t\t\t\t     unsigned int keybyteorder,\n+\t\t\t\t\t     struct expr *key,\n \t\t\t\t\t     struct expr *expr)\n {\n \tstruct cmd *cmd;\n@@ -74,8 +72,8 @@ static struct expr *implicit_set_declaration(struct eval_ctx *ctx,\n \tset = set_alloc(&expr->location);\n \tset->flags\t= NFT_SET_ANONYMOUS | expr->set_flags;\n \tset->handle.set = xstrdup(name),\n-\tset->keytype \t= set_datatype_alloc(keytype, keybyteorder);\n-\tset->keylen\t= keylen;\n+\tset->keytype \t= set_datatype_alloc(key->dtype, key->byteorder);\n+\tset->keylen\t= key->len;\n \tset->init\t= expr;\n \n \tif (ctx->table != NULL)\n@@ -1184,6 +1182,7 @@ static int expr_evaluate_map(struct eval_ctx *ctx, struct expr **expr)\n {\n \tstruct expr_ctx ectx = ctx->ectx;\n \tstruct expr *map = *expr, *mappings;\n+\tstruct expr *key;\n \n \texpr_set_context(&ctx->ectx, NULL, 0);\n \tif (expr_evaluate(ctx, &map->map) < 0)\n@@ -1197,11 +1196,15 @@ static int expr_evaluate_map(struct eval_ctx *ctx, struct expr **expr)\n \n \tswitch (map->mappings->ops->type) {\n \tcase EXPR_SET:\n+\t\tkey = constant_expr_alloc(&map->location,\n+\t\t\t\t ctx->ectx.dtype,\n+\t\t\t\t ctx->ectx.byteorder,\n+\t\t\t\t ctx->ectx.len, NULL);\n+\n \t\tmappings = implicit_set_declaration(ctx, \"__map%d\",\n-\t\t\t\t\t\t    ctx->ectx.dtype,\n-\t\t\t\t\t\t    ctx->ectx.len,\n-\t\t\t\t\t\t    ctx->ectx.byteorder,\n+\t\t\t\t\t\t    key,\n \t\t\t\t\t\t    mappings);\n+\t\texpr_free(key);\n \n \t\tmappings->set->datatype = set_datatype_alloc(ectx.dtype,\n \t\t\t\t\t\t\t     ectx.byteorder);\n@@ -1539,8 +1542,7 @@ static int expr_evaluate_relational(struct eval_ctx *ctx, struct expr **expr)\n \t\tif (right->ops->type == EXPR_SET)\n \t\t\tright = rel->right =\n \t\t\t\timplicit_set_declaration(ctx, \"__set%d\",\n-\t\t\t\t\t\t\t left->dtype, left->len,\n-\t\t\t\t\t\t\t left->byteorder, right);\n+\t\t\t\t\t\t\t left, right);\n \t\telse if (!datatype_equal(left->dtype, right->dtype))\n \t\t\treturn expr_binary_error(ctx->msgs, right, left,\n \t\t\t\t\t\t \"datatype mismatch, expected %s, \"\n@@ -1597,9 +1599,7 @@ static int expr_evaluate_relational(struct eval_ctx *ctx, struct expr **expr)\n \t\tcase EXPR_SET:\n \t\t\tassert(rel->op == OP_NEQ);\n \t\t\tright = rel->right =\n-\t\t\t\timplicit_set_declaration(ctx, \"__set%d\",\n-\t\t\t\t\t\t\t left->dtype, left->len,\n-\t\t\t\t\t\t\t left->byteorder, right);\n+\t\t\t\timplicit_set_declaration(ctx, \"__set%d\", left, right);\n \t\t\t/* fall through */\n \t\tcase EXPR_SET_REF:\n \t\t\tassert(rel->op == OP_NEQ);\n@@ -1978,8 +1978,7 @@ static int stmt_evaluate_flow(struct eval_ctx *ctx, struct stmt *stmt)\n \t\tset->set_flags |= NFT_SET_TIMEOUT;\n \n \tsetref = implicit_set_declaration(ctx, stmt->flow.table ?: \"__ft%d\",\n-\t\t\t\t\t  key->dtype, key->len,\n-\t\t\t\t\t  key->dtype->byteorder, set);\n+\t\t\t\t\t  key, set);\n \n \tstmt->flow.set = setref;\n \n@@ -2609,6 +2608,7 @@ static int stmt_evaluate_objref_map(struct eval_ctx *ctx, struct stmt *stmt)\n {\n \tstruct expr *map = stmt->objref.expr;\n \tstruct expr *mappings;\n+\tstruct expr *key;\n \n \texpr_set_context(&ctx->ectx, NULL, 0);\n \tif (expr_evaluate(ctx, &map->map) < 0)\n@@ -2622,11 +2622,15 @@ static int stmt_evaluate_objref_map(struct eval_ctx *ctx, struct stmt *stmt)\n \n \tswitch (map->mappings->ops->type) {\n \tcase EXPR_SET:\n+\t\tkey = constant_expr_alloc(&stmt->location,\n+\t\t\t\t\t  ctx->ectx.dtype,\n+\t\t\t\t\t  ctx->ectx.byteorder,\n+\t\t\t\t\t  ctx->ectx.len, NULL);\n+\n \t\tmappings = implicit_set_declaration(ctx, \"__objmap%d\",\n-\t\t\t\t\t\t    ctx->ectx.dtype,\n-\t\t\t\t\t\t    ctx->ectx.len,\n-\t\t\t\t\t\t    ctx->ectx.byteorder,\n-\t\t\t\t\t\t    mappings);\n+\t\t\t\t\t\t    key, mappings);\n+\t\texpr_free(key);\n+\n \t\tmappings->set->datatype = &string_type;\n \t\tmappings->set->datalen  = NFT_OBJ_MAXNAMELEN * BITS_PER_BYTE;\n \t\tmappings->set->objtype  = stmt->objref.type;\n",
    "prefixes": [
        "nft",
        "1/2"
    ]
}