get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 811832,
    "url": "http://patchwork.ozlabs.org/api/patches/811832/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/150490444956.11590.4733752227675213913.stgit@john-XPS-13-9360/",
    "project": {
        "id": 7,
        "url": "http://patchwork.ozlabs.org/api/projects/7/?format=api",
        "name": "Linux network development",
        "link_name": "netdev",
        "list_id": "netdev.vger.kernel.org",
        "list_email": "netdev@vger.kernel.org",
        "web_url": null,
        "scm_url": null,
        "webscm_url": null,
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<150490444956.11590.4733752227675213913.stgit@john-XPS-13-9360>",
    "list_archive_url": null,
    "date": "2017-09-08T21:00:49",
    "name": "[net,2/3] bpf: add support for sockmap detach programs",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "2311ef1c7d29f2321ad875da6811f520433e9e1d",
    "submitter": {
        "id": 20028,
        "url": "http://patchwork.ozlabs.org/api/people/20028/?format=api",
        "name": "John Fastabend",
        "email": "john.fastabend@gmail.com"
    },
    "delegate": {
        "id": 34,
        "url": "http://patchwork.ozlabs.org/api/users/34/?format=api",
        "username": "davem",
        "first_name": "David",
        "last_name": "Miller",
        "email": "davem@davemloft.net"
    },
    "mbox": "http://patchwork.ozlabs.org/project/netdev/patch/150490444956.11590.4733752227675213913.stgit@john-XPS-13-9360/mbox/",
    "series": [
        {
            "id": 2291,
            "url": "http://patchwork.ozlabs.org/api/series/2291/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/netdev/list/?series=2291",
            "date": "2017-09-08T21:00:05",
            "name": "Fixes for XDP/BPF",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/2291/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/811832/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/811832/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<netdev-owner@vger.kernel.org>",
        "X-Original-To": "patchwork-incoming@ozlabs.org",
        "Delivered-To": "patchwork-incoming@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=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)",
            "ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"dj+vxgXj\"; dkim-atps=neutral"
        ],
        "Received": [
            "from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xpqVW6wtrz9s75\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat,  9 Sep 2017 07:01:07 +1000 (AEST)",
            "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S932560AbdIHVBG (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tFri, 8 Sep 2017 17:01:06 -0400",
            "from mail-pg0-f67.google.com ([74.125.83.67]:37878 \"EHLO\n\tmail-pg0-f67.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S932400AbdIHVBE (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Fri, 8 Sep 2017 17:01:04 -0400",
            "by mail-pg0-f67.google.com with SMTP id v5so1785561pgn.4\n\tfor <netdev@vger.kernel.org>; Fri, 08 Sep 2017 14:01:04 -0700 (PDT)",
            "from [127.0.1.1] ([72.168.144.71])\n\tby smtp.gmail.com with ESMTPSA id\n\tr3sm4232489pgf.48.2017.09.08.14.00.57\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tFri, 08 Sep 2017 14:01:03 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=gmail.com; s=20161025;\n\th=subject:from:to:cc:date:message-id:in-reply-to:references\n\t:user-agent:mime-version:content-transfer-encoding;\n\tbh=lL/cX5LoduWPqt1SWsmTeWdEJQXyfQ4r2F1/TniQmc8=;\n\tb=dj+vxgXja4nFoGXn6wWRB+hGRVv988p27S9YrY1S+SnD0KSGDxhA5rN50Yk/+R3hMe\n\tvF1KgPwlSeu9Nugt3krUb3qxEdn/40RyiHyp+sG6wqpFKnUfcqxtTGidKpyJXQ2ZifiM\n\tyA87u95LnHLWi+NqB7MbLzKvz24UEcYCV+fVDDddopwi3opYZn7jIvadb5eefLuan5vO\n\tSC6TftWQTWRWFjtzn8Vug3hXk3UwWuPT2Zbpac/A51JulpFPykkcQAl6T42Hw/7+lpLQ\n\tu8mPEitQKJ71eprXavsECt2sGzQ6Kj/Lkxy1iJa/yDnURimOPRPXsGQVuTAks708N20H\n\tjLlg==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to\n\t:references:user-agent:mime-version:content-transfer-encoding;\n\tbh=lL/cX5LoduWPqt1SWsmTeWdEJQXyfQ4r2F1/TniQmc8=;\n\tb=OsyZDyTvQGJdlD9Fd18Dqx5v6DmKwB4D8IecKwmOlpkqHoiLueb4XMaCsPhG/1si8J\n\tzHRkgiPC7i3GYf8blia53MvLNYXnSzsg0RNjSdGCOZH9hcfk2AY4waIdUt7HdexZSCF2\n\tFcK3TEBkisBHJQSswjEPGtAlvUllGqeTOb9lPPC54mzC9OCAyLyrqHR4WredhQGE6NLV\n\tvr5kCaSsyE7I3KdwtkvYb2NBc+sEpzfIeC3y5PcrQk7glTRJwjEZHJVD8arDXjZhgLM5\n\t0HiQRFQnNJbff5jMS/OsdEYnWZZ+Eo0UQ3/skioZREEULyQWAaLEz4LXFGxvzHtU5iGv\n\tpXeQ==",
        "X-Gm-Message-State": "AHPjjUj6Wj5+pa0uteLgWNfQyeftD7I4NkAhqyjon46SGMhAhWwNs2yL\n\tbzFY1mJf/fV+kK7+",
        "X-Google-Smtp-Source": "ADKCNb5x1uRBMi6V0SfUiCGemCgtOtusFoUlopQU7UrhAYzb6dfMCDwdB/uhgIGZi/dLjtdjklMrpA==",
        "X-Received": "by 10.99.44.10 with SMTP id s10mr4170290pgs.381.1504904464125;\n\tFri, 08 Sep 2017 14:01:04 -0700 (PDT)",
        "Subject": "[net PATCH 2/3] bpf: add support for sockmap detach programs",
        "From": "John Fastabend <john.fastabend@gmail.com>",
        "To": "davem@davemloft.net",
        "Cc": "netdev@vger.kernel.org, john.fastabend@gmail.com,\n\tdaniel@iogearbox.net, ast@fb.com",
        "Date": "Fri, 08 Sep 2017 14:00:49 -0700",
        "Message-ID": "<150490444956.11590.4733752227675213913.stgit@john-XPS-13-9360>",
        "In-Reply-To": "<150490397545.11590.1409723973253492363.stgit@john-XPS-13-9360>",
        "References": "<150490397545.11590.1409723973253492363.stgit@john-XPS-13-9360>",
        "User-Agent": "StGit/0.17.1-dirty",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "Content-Transfer-Encoding": "7bit",
        "Sender": "netdev-owner@vger.kernel.org",
        "Precedence": "bulk",
        "List-ID": "<netdev.vger.kernel.org>",
        "X-Mailing-List": "netdev@vger.kernel.org"
    },
    "content": "The bpf map sockmap supports adding programs via attach commands. This\npatch adds the detach command to keep the API symmetric and allow\nusers to remove previously added programs. Otherwise the user would\nhave to delete the map and re-add it to get in this state.\n\nThis also adds a series of additional tests to capture detach operation\nand also attaching/detaching invalid prog types.\n\nAPI note: socks will run (or not run) programs depending on the state\nof the map at the time the sock is added. We do not for example walk\nthe map and remove programs from previously attached socks.\n\nAcked-by: Daniel Borkmann <daniel@iogearbox.net>\nSigned-off-by: John Fastabend <john.fastabend@gmail.com>\n---\n include/linux/bpf.h                     |    8 ++---\n kernel/bpf/sockmap.c                    |    2 +\n kernel/bpf/syscall.c                    |   27 ++++++++++------\n tools/testing/selftests/bpf/test_maps.c |   51 ++++++++++++++++++++++++++++++-\n 4 files changed, 72 insertions(+), 16 deletions(-)",
    "diff": "diff --git a/include/linux/bpf.h b/include/linux/bpf.h\nindex c2cb1b5..8390859 100644\n--- a/include/linux/bpf.h\n+++ b/include/linux/bpf.h\n@@ -385,16 +385,16 @@ static inline void __dev_map_flush(struct bpf_map *map)\n \n #if defined(CONFIG_STREAM_PARSER) && defined(CONFIG_BPF_SYSCALL)\n struct sock  *__sock_map_lookup_elem(struct bpf_map *map, u32 key);\n-int sock_map_attach_prog(struct bpf_map *map, struct bpf_prog *prog, u32 type);\n+int sock_map_prog(struct bpf_map *map, struct bpf_prog *prog, u32 type);\n #else\n static inline struct sock  *__sock_map_lookup_elem(struct bpf_map *map, u32 key)\n {\n \treturn NULL;\n }\n \n-static inline int sock_map_attach_prog(struct bpf_map *map,\n-\t\t\t\t       struct bpf_prog *prog,\n-\t\t\t\t       u32 type)\n+static inline int sock_map_prog(struct bpf_map *map,\n+\t\t\t\tstruct bpf_prog *prog,\n+\t\t\t\tu32 type)\n {\n \treturn -EOPNOTSUPP;\n }\ndiff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c\nindex f6ffde9..6424ce0 100644\n--- a/kernel/bpf/sockmap.c\n+++ b/kernel/bpf/sockmap.c\n@@ -792,7 +792,7 @@ static int sock_map_ctx_update_elem(struct bpf_sock_ops_kern *skops,\n \treturn err;\n }\n \n-int sock_map_attach_prog(struct bpf_map *map, struct bpf_prog *prog, u32 type)\n+int sock_map_prog(struct bpf_map *map, struct bpf_prog *prog, u32 type)\n {\n \tstruct bpf_stab *stab = container_of(map, struct bpf_stab, map);\n \tstruct bpf_prog *orig;\ndiff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c\nindex 70ad8e2..cb17e1c 100644\n--- a/kernel/bpf/syscall.c\n+++ b/kernel/bpf/syscall.c\n@@ -1096,10 +1096,10 @@ static int bpf_obj_get(const union bpf_attr *attr)\n \n #define BPF_PROG_ATTACH_LAST_FIELD attach_flags\n \n-static int sockmap_get_from_fd(const union bpf_attr *attr)\n+static int sockmap_get_from_fd(const union bpf_attr *attr, bool attach)\n {\n+\tstruct bpf_prog *prog = NULL;\n \tint ufd = attr->target_fd;\n-\tstruct bpf_prog *prog;\n \tstruct bpf_map *map;\n \tstruct fd f;\n \tint err;\n@@ -1109,16 +1109,20 @@ static int sockmap_get_from_fd(const union bpf_attr *attr)\n \tif (IS_ERR(map))\n \t\treturn PTR_ERR(map);\n \n-\tprog = bpf_prog_get_type(attr->attach_bpf_fd, BPF_PROG_TYPE_SK_SKB);\n-\tif (IS_ERR(prog)) {\n-\t\tfdput(f);\n-\t\treturn PTR_ERR(prog);\n+\tif (attach) {\n+\t\tprog = bpf_prog_get_type(attr->attach_bpf_fd,\n+\t\t\t\t\t BPF_PROG_TYPE_SK_SKB);\n+\t\tif (IS_ERR(prog)) {\n+\t\t\tfdput(f);\n+\t\t\treturn PTR_ERR(prog);\n+\t\t}\n \t}\n \n-\terr = sock_map_attach_prog(map, prog, attr->attach_type);\n+\terr = sock_map_prog(map, prog, attr->attach_type);\n \tif (err) {\n \t\tfdput(f);\n-\t\tbpf_prog_put(prog);\n+\t\tif (prog)\n+\t\t\tbpf_prog_put(prog);\n \t\treturn err;\n \t}\n \n@@ -1155,7 +1159,7 @@ static int bpf_prog_attach(const union bpf_attr *attr)\n \t\tbreak;\n \tcase BPF_SK_SKB_STREAM_PARSER:\n \tcase BPF_SK_SKB_STREAM_VERDICT:\n-\t\treturn sockmap_get_from_fd(attr);\n+\t\treturn sockmap_get_from_fd(attr, true);\n \tdefault:\n \t\treturn -EINVAL;\n \t}\n@@ -1204,7 +1208,10 @@ static int bpf_prog_detach(const union bpf_attr *attr)\n \t\tret = cgroup_bpf_update(cgrp, NULL, attr->attach_type, false);\n \t\tcgroup_put(cgrp);\n \t\tbreak;\n-\n+\tcase BPF_SK_SKB_STREAM_PARSER:\n+\tcase BPF_SK_SKB_STREAM_VERDICT:\n+\t\tret = sockmap_get_from_fd(attr, false);\n+\t\tbreak;\n \tdefault:\n \t\treturn -EINVAL;\n \t}\ndiff --git a/tools/testing/selftests/bpf/test_maps.c b/tools/testing/selftests/bpf/test_maps.c\nindex 4acc772..fe3a443 100644\n--- a/tools/testing/selftests/bpf/test_maps.c\n+++ b/tools/testing/selftests/bpf/test_maps.c\n@@ -558,7 +558,7 @@ static void test_sockmap(int tasks, void *data)\n \t\t}\n \t}\n \n-\t/* Test attaching bad fds */\n+\t/* Test attaching/detaching bad fds */\n \terr = bpf_prog_attach(-1, fd, BPF_SK_SKB_STREAM_PARSER, 0);\n \tif (!err) {\n \t\tprintf(\"Failed invalid parser prog attach\\n\");\n@@ -571,6 +571,30 @@ static void test_sockmap(int tasks, void *data)\n \t\tgoto out_sockmap;\n \t}\n \n+\terr = bpf_prog_attach(-1, fd, __MAX_BPF_ATTACH_TYPE, 0);\n+\tif (!err) {\n+\t\tprintf(\"Failed unknown prog attach\\n\");\n+\t\tgoto out_sockmap;\n+\t}\n+\n+\terr = bpf_prog_detach(fd, BPF_SK_SKB_STREAM_PARSER);\n+\tif (err) {\n+\t\tprintf(\"Failed empty parser prog detach\\n\");\n+\t\tgoto out_sockmap;\n+\t}\n+\n+\terr = bpf_prog_detach(fd, BPF_SK_SKB_STREAM_VERDICT);\n+\tif (err) {\n+\t\tprintf(\"Failed empty verdict prog detach\\n\");\n+\t\tgoto out_sockmap;\n+\t}\n+\n+\terr = bpf_prog_detach(fd, __MAX_BPF_ATTACH_TYPE);\n+\tif (!err) {\n+\t\tprintf(\"Detach invalid prog successful\\n\");\n+\t\tgoto out_sockmap;\n+\t}\n+\n \t/* Load SK_SKB program and Attach */\n \terr = bpf_prog_load(SOCKMAP_PARSE_PROG,\n \t\t\t    BPF_PROG_TYPE_SK_SKB, &obj, &parse_prog);\n@@ -643,6 +667,13 @@ static void test_sockmap(int tasks, void *data)\n \t\tgoto out_sockmap;\n \t}\n \n+\terr = bpf_prog_attach(verdict_prog, map_fd_rx,\n+\t\t\t      __MAX_BPF_ATTACH_TYPE, 0);\n+\tif (!err) {\n+\t\tprintf(\"Attached unknown bpf prog\\n\");\n+\t\tgoto out_sockmap;\n+\t}\n+\n \t/* Test map update elem afterwards fd lives in fd and map_fd */\n \tfor (i = 0; i < 6; i++) {\n \t\terr = bpf_map_update_elem(map_fd_rx, &i, &sfd[i], BPF_ANY);\n@@ -809,6 +840,24 @@ static void test_sockmap(int tasks, void *data)\n \t\tassert(status == 0);\n \t}\n \n+\terr = bpf_prog_detach(map_fd_rx, __MAX_BPF_ATTACH_TYPE);\n+\tif (!err) {\n+\t\tprintf(\"Detached an invalid prog type.\\n\");\n+\t\tgoto out_sockmap;\n+\t}\n+\n+\terr = bpf_prog_detach(map_fd_rx, BPF_SK_SKB_STREAM_PARSER);\n+\tif (err) {\n+\t\tprintf(\"Failed parser prog detach\\n\");\n+\t\tgoto out_sockmap;\n+\t}\n+\n+\terr = bpf_prog_detach(map_fd_rx, BPF_SK_SKB_STREAM_VERDICT);\n+\tif (err) {\n+\t\tprintf(\"Failed parser prog detach\\n\");\n+\t\tgoto out_sockmap;\n+\t}\n+\n \t/* Test map close sockets */\n \tfor (i = 0; i < 6; i++)\n \t\tclose(sfd[i]);\n",
    "prefixes": [
        "net",
        "2/3"
    ]
}