get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 887,
    "url": "http://patchwork.ozlabs.org/api/patches/887/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/netdev/patch/1222098445-26175-9-git-send-email-remi.denis-courmont@nokia.com/",
    "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": "<1222098445-26175-9-git-send-email-remi.denis-courmont@nokia.com>",
    "list_archive_url": null,
    "date": "2008-09-22T15:47:23",
    "name": "[09/11] Phonet: proc interface for port range",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "b5e2c7490857d815567fc0427ee4fba5a2e2f3a7",
    "submitter": {
        "id": 204,
        "url": "http://patchwork.ozlabs.org/api/people/204/?format=api",
        "name": "Rémi Denis-Courmont",
        "email": "remi.denis-courmont@nokia.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/1222098445-26175-9-git-send-email-remi.denis-courmont@nokia.com/mbox/",
    "series": [],
    "comments": "http://patchwork.ozlabs.org/api/patches/887/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/887/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<netdev-owner@vger.kernel.org>",
        "X-Original-To": "patchwork-incoming@ozlabs.org",
        "Delivered-To": "patchwork-incoming@ozlabs.org",
        "Received": [
            "from vger.kernel.org (vger.kernel.org [209.132.176.167])\n\tby ozlabs.org (Postfix) with ESMTP id D250EDDF25\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue, 23 Sep 2008 01:48:32 +1000 (EST)",
            "(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1753853AbYIVPrx (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tMon, 22 Sep 2008 11:47:53 -0400",
            "(majordomo@vger.kernel.org) by vger.kernel.org id S1753831AbYIVPrw\n\t(ORCPT <rfc822; netdev-outgoing>); Mon, 22 Sep 2008 11:47:52 -0400",
            "from smtp.nokia.com ([192.100.122.233]:53006 \"EHLO\n\tmgw-mx06.nokia.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1753527AbYIVPrq (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Mon, 22 Sep 2008 11:47:46 -0400",
            "from vaebh105.NOE.Nokia.com (vaebh105.europe.nokia.com\n\t[10.160.244.31])\n\tby mgw-mx06.nokia.com (Switch-3.2.6/Switch-3.2.6) with ESMTP id\n\tm8MFlZFb027641\n\tfor <netdev@vger.kernel.org>; Mon, 22 Sep 2008 18:47:43 +0300",
            "from vaebh102.NOE.Nokia.com ([10.160.244.23]) by\n\tvaebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); \n\tMon, 22 Sep 2008 18:47:35 +0300",
            "from localhost.localdomain ([172.21.41.115]) by\n\tvaebh102.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); \n\tMon, 22 Sep 2008 18:47:26 +0300"
        ],
        "From": "=?utf-8?q?R=C3=A9mi=20Denis-Courmont?= <remi.denis-courmont@nokia.com>",
        "To": "netdev@vger.kernel.org",
        "Subject": "[PATCH 09/11] Phonet: proc interface for port range",
        "Date": "Mon, 22 Sep 2008 18:47:23 +0300",
        "Message-Id": "<1222098445-26175-9-git-send-email-remi.denis-courmont@nokia.com>",
        "X-Mailer": "git-send-email 1.5.4.3",
        "In-Reply-To": "<200809221845.54736.remi.denis-courmont@nokia.com>",
        "References": "<200809221845.54736.remi.denis-courmont@nokia.com>",
        "X-OriginalArrivalTime": "22 Sep 2008 15:47:26.0756 (UTC)\n\tFILETIME=[833D1640:01C91CCA]",
        "X-Nokia-AV": "Clean",
        "Sender": "netdev-owner@vger.kernel.org",
        "Precedence": "bulk",
        "List-ID": "<netdev.vger.kernel.org>",
        "X-Mailing-List": "netdev@vger.kernel.org"
    },
    "content": "Phonet endpoints are bound to individual ports.\nThis provides a /proc/sys/net/phonet (or sysctl) interface for\nselecting the range of automatically allocated ports (much like the\nip_local_port_range with IPv4).\n\nSigned-off-by: Remi Denis-Courmont <remi.denis-courmont@nokia.com>\n---\n include/net/phonet/phonet.h |    3 +\n net/phonet/Makefile         |    1 +\n net/phonet/af_phonet.c      |    3 +\n net/phonet/socket.c         |    3 +-\n net/phonet/sysctl.c         |  113 +++++++++++++++++++++++++++++++++++++++++++\n 5 files changed, 122 insertions(+), 1 deletions(-)\n create mode 100644 net/phonet/sysctl.c",
    "diff": "diff --git a/include/net/phonet/phonet.h b/include/net/phonet/phonet.h\nindex d3957d3..1c6f7e7 100644\n--- a/include/net/phonet/phonet.h\n+++ b/include/net/phonet/phonet.h\n@@ -47,6 +47,7 @@ static inline struct pn_sock *pn_sk(struct sock *sk)\n extern const struct proto_ops phonet_dgram_ops;\n \n struct sock *pn_find_sock_by_sa(const struct sockaddr_pn *sa);\n+void phonet_get_local_port_range(int *min, int *max);\n void pn_sock_hash(struct sock *sk);\n void pn_sock_unhash(struct sock *sk);\n int pn_sock_get_port(struct sock *sk, unsigned short sport);\n@@ -97,6 +98,8 @@ struct phonet_protocol {\n int phonet_proto_register(int protocol, struct phonet_protocol *pp);\n void phonet_proto_unregister(int protocol, struct phonet_protocol *pp);\n \n+int phonet_sysctl_init(void);\n+void phonet_sysctl_exit(void);\n void phonet_netlink_register(void);\n int isi_register(void);\n void isi_unregister(void);\ndiff --git a/net/phonet/Makefile b/net/phonet/Makefile\nindex d218abc..ae9c3ed 100644\n--- a/net/phonet/Makefile\n+++ b/net/phonet/Makefile\n@@ -5,4 +5,5 @@ phonet-objs := \\\n \tpn_netlink.o \\\n \tsocket.o \\\n \tdatagram.o \\\n+\tsysctl.o \\\n \taf_phonet.o\ndiff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c\nindex 51397ff..50dc258 100644\n--- a/net/phonet/af_phonet.c\n+++ b/net/phonet/af_phonet.c\n@@ -350,6 +350,7 @@ static int __init phonet_init(void)\n \tphonet_device_init();\n \tdev_add_pack(&phonet_packet_type);\n \tphonet_netlink_register();\n+\tphonet_sysctl_init();\n \n \terr = isi_register();\n \tif (err)\n@@ -357,6 +358,7 @@ static int __init phonet_init(void)\n \treturn 0;\n \n err:\n+\tphonet_sysctl_exit();\n \tsock_unregister(AF_PHONET);\n \tdev_remove_pack(&phonet_packet_type);\n \tphonet_device_exit();\n@@ -366,6 +368,7 @@ err:\n static void __exit phonet_exit(void)\n {\n \tisi_unregister();\n+\tphonet_sysctl_exit();\n \tsock_unregister(AF_PHONET);\n \tdev_remove_pack(&phonet_packet_type);\n \tphonet_device_exit();\ndiff --git a/net/phonet/socket.c b/net/phonet/socket.c\nindex 99a4945..dfd4061 100644\n--- a/net/phonet/socket.c\n+++ b/net/phonet/socket.c\n@@ -273,8 +273,9 @@ int pn_sock_get_port(struct sock *sk, unsigned short sport)\n \n \tif (!sport) {\n \t\t/* search free port */\n-\t\tint port, pmin = 0x40, pmax = 0x7f;\n+\t\tint port, pmin, pmax;\n \n+\t\tphonet_get_local_port_range(&pmin, &pmax);\n \t\tfor (port = pmin; port <= pmax; port++) {\n \t\t\tport_cur++;\n \t\t\tif (port_cur < pmin || port_cur > pmax)\ndiff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c\nnew file mode 100644\nindex 0000000..600a430\n--- /dev/null\n+++ b/net/phonet/sysctl.c\n@@ -0,0 +1,113 @@\n+/*\n+ * File: sysctl.c\n+ *\n+ * Phonet /proc/sys/net/phonet interface implementation\n+ *\n+ * Copyright (C) 2008 Nokia Corporation.\n+ *\n+ * Contact: Remi Denis-Courmont <remi.denis-courmont@nokia.com>\n+ *\n+ * This program is free software; you can redistribute it and/or\n+ * modify it under the terms of the GNU General Public License\n+ * version 2 as published by the Free Software Foundation.\n+ *\n+ * This program is distributed in the hope that it will be useful, but\n+ * WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n+ * General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU General Public License\n+ * along with this program; if not, write to the Free Software\n+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA\n+ * 02110-1301 USA\n+ */\n+\n+#include <linux/seqlock.h>\n+#include <linux/sysctl.h>\n+#include <linux/errno.h>\n+#include <linux/init.h>\n+\n+#define DYNAMIC_PORT_MIN\t0x40\n+#define DYNAMIC_PORT_MAX\t0x7f\n+\n+static DEFINE_SEQLOCK(local_port_range_lock);\n+static int local_port_range_min[2] = {0, 0};\n+static int local_port_range_max[2] = {1023, 1023};\n+static int local_port_range[2] = {DYNAMIC_PORT_MIN, DYNAMIC_PORT_MAX};\n+static struct ctl_table_header *phonet_table_hrd;\n+\n+static void set_local_port_range(int range[2])\n+{\n+\twrite_seqlock(&local_port_range_lock);\n+\tlocal_port_range[0] = range[0];\n+\tlocal_port_range[1] = range[1];\n+\twrite_sequnlock(&local_port_range_lock);\n+}\n+\n+void phonet_get_local_port_range(int *min, int *max)\n+{\n+\tunsigned seq;\n+\tdo {\n+\t\tseq = read_seqbegin(&local_port_range_lock);\n+\t\tif (min)\n+\t\t\t*min = local_port_range[0];\n+\t\tif (max)\n+\t\t\t*max = local_port_range[1];\n+\t} while (read_seqretry(&local_port_range_lock, seq));\n+}\n+\n+static int proc_local_port_range(ctl_table *table, int write, struct file *filp,\n+\t\t\t\tvoid __user *buffer,\n+\t\t\t\tsize_t *lenp, loff_t *ppos)\n+{\n+\tint ret;\n+\tint range[2] = {local_port_range[0], local_port_range[1]};\n+\tctl_table tmp = {\n+\t\t.data = &range,\n+\t\t.maxlen = sizeof(range),\n+\t\t.mode = table->mode,\n+\t\t.extra1 = &local_port_range_min,\n+\t\t.extra2 = &local_port_range_max,\n+\t};\n+\n+\tret = proc_dointvec_minmax(&tmp, write, filp, buffer, lenp, ppos);\n+\n+\tif (write && ret == 0) {\n+\t\tif (range[1] < range[0])\n+\t\t\tret = -EINVAL;\n+\t\telse\n+\t\t\tset_local_port_range(range);\n+\t}\n+\n+\treturn ret;\n+}\n+\n+static struct ctl_table phonet_table[] = {\n+\t{\n+\t\t.ctl_name\t= CTL_UNNUMBERED,\n+\t\t.procname\t= \"local_port_range\",\n+\t\t.data\t\t= &local_port_range,\n+\t\t.maxlen\t\t= sizeof(local_port_range),\n+\t\t.mode\t\t= 0644,\n+\t\t.proc_handler\t= &proc_local_port_range,\n+\t\t.strategy\t= NULL,\n+\t},\n+\t{ .ctl_name = 0 }\n+};\n+\n+struct ctl_path phonet_ctl_path[] = {\n+\t{ .procname = \"net\", .ctl_name = CTL_NET, },\n+\t{ .procname = \"phonet\", .ctl_name = CTL_UNNUMBERED, },\n+\t{ },\n+};\n+\n+int __init phonet_sysctl_init(void)\n+{\n+\tphonet_table_hrd = register_sysctl_paths(phonet_ctl_path, phonet_table);\n+\treturn phonet_table_hrd == NULL ? -ENOMEM : 0;\n+}\n+\n+void phonet_sysctl_exit(void)\n+{\n+\tunregister_sysctl_table(phonet_table_hrd);\n+}\n",
    "prefixes": [
        "09/11"
    ]
}