get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 26128,
    "url": "https://patches.dpdk.org/api/patches/26128/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20170630165140.59594-17-ferruh.yigit@intel.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": "<20170630165140.59594-17-ferruh.yigit@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20170630165140.59594-17-ferruh.yigit@intel.com",
    "date": "2017-06-30T16:51:36",
    "name": "[dpdk-dev,v9,16/20] ctrl_if: initialize netlink interface",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "7a81cc13b12973bbaa8151eb94b37aec1e6d15d8",
    "submitter": {
        "id": 324,
        "url": "https://patches.dpdk.org/api/people/324/?format=api",
        "name": "Ferruh Yigit",
        "email": "ferruh.yigit@intel.com"
    },
    "delegate": null,
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20170630165140.59594-17-ferruh.yigit@intel.com/mbox/",
    "series": [],
    "comments": "https://patches.dpdk.org/api/patches/26128/comments/",
    "check": "fail",
    "checks": "https://patches.dpdk.org/api/patches/26128/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 [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id 2C2257CE7;\n\tFri, 30 Jun 2017 18:52:44 +0200 (CEST)",
            "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby dpdk.org (Postfix) with ESMTP id 94F1B235\n\tfor <dev@dpdk.org>; Fri, 30 Jun 2017 18:52:08 +0200 (CEST)",
            "from orsmga004.jf.intel.com ([10.7.209.38])\n\tby orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t30 Jun 2017 09:52:08 -0700",
            "from silpixa00372839.ir.intel.com (HELO\n\tsilpixa00372839.ger.corp.intel.com) ([10.237.222.154])\n\tby orsmga004.jf.intel.com with ESMTP; 30 Jun 2017 09:52:06 -0700"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.40,287,1496127600\"; d=\"scan'208\";a=\"103233335\"",
        "From": "Ferruh Yigit <ferruh.yigit@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "Ferruh Yigit <ferruh.yigit@intel.com>,\n\tStephen Hemminger <stephen@networkplumber.org>,\n\tBruce Richardson <bruce.richardson@intel.com>,\n\tAnatoly Burakov <anatoly.burakov@intel.com>",
        "Date": "Fri, 30 Jun 2017 17:51:36 +0100",
        "Message-Id": "<20170630165140.59594-17-ferruh.yigit@intel.com>",
        "X-Mailer": "git-send-email 2.13.0",
        "In-Reply-To": "<20170630165140.59594-1-ferruh.yigit@intel.com>",
        "References": "<20170621110651.75299-1-ferruh.yigit@intel.com>\n\t<20170630165140.59594-1-ferruh.yigit@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v9 16/20] ctrl_if: initialize netlink interface",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<http://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": "<http://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": "Initialize netlink sockets to exchange data between kernelspace.\n\nSigned-off-by: Ferruh Yigit <ferruh.yigit@intel.com>\n---\n lib/librte_ctrl_if/Makefile      |   2 +\n lib/librte_ctrl_if/rte_ctrl_if.c |   9 +++\n lib/librte_ctrl_if/rte_nl.c      | 158 +++++++++++++++++++++++++++++++++++++++\n lib/librte_ctrl_if/rte_nl.h      |  48 ++++++++++++\n 4 files changed, 217 insertions(+)\n create mode 100644 lib/librte_ctrl_if/rte_nl.c\n create mode 100644 lib/librte_ctrl_if/rte_nl.h",
    "diff": "diff --git a/lib/librte_ctrl_if/Makefile b/lib/librte_ctrl_if/Makefile\nindex c682af4c4..0da04f7d0 100644\n--- a/lib/librte_ctrl_if/Makefile\n+++ b/lib/librte_ctrl_if/Makefile\n@@ -38,12 +38,14 @@ LIB = librte_ctrl_if.a\n \n CFLAGS += -O3\n CFLAGS += $(WERROR_FLAGS)\n+LDLIBS += -lpthread\n \n EXPORT_MAP := rte_ctrl_if_version.map\n \n LIBABIVER := 1\n \n SRCS-$(CONFIG_RTE_LIBRTE_CTRL_IF) := rte_ctrl_if.c\n+SRCS-$(CONFIG_RTE_LIBRTE_CTRL_IF) += rte_nl.c\n \n #\n # Export include files\ndiff --git a/lib/librte_ctrl_if/rte_ctrl_if.c b/lib/librte_ctrl_if/rte_ctrl_if.c\nindex 8b0718969..a26699be7 100644\n--- a/lib/librte_ctrl_if/rte_ctrl_if.c\n+++ b/lib/librte_ctrl_if/rte_ctrl_if.c\n@@ -44,6 +44,7 @@\n \n #include <rte_log.h>\n #include \"rte_ctrl_if.h\"\n+#include \"rte_nl.h\"\n \n #define NAMESZ 32\n #define IFNAME \"dpdk\"\n@@ -95,6 +96,13 @@ control_interface_init(void)\n \t\treturn -1;\n \t}\n \n+\tret = control_interface_nl_init();\n+\tif (ret < 0) {\n+\t\tRTE_LOG(ERR, CTRL_IF, \"Failed to initialize netlink\\n\");\n+\t\tclose(unci_rtnl_fd);\n+\t\tunci_rtnl_fd = -1;\n+\t}\n+\n \treturn ret;\n }\n \n@@ -119,6 +127,7 @@ static void\n control_interface_release(void)\n {\n \tclose(unci_rtnl_fd);\n+\tcontrol_interface_nl_release();\n }\n \n static int\ndiff --git a/lib/librte_ctrl_if/rte_nl.c b/lib/librte_ctrl_if/rte_nl.c\nnew file mode 100644\nindex 000000000..e88b3fc91\n--- /dev/null\n+++ b/lib/librte_ctrl_if/rte_nl.c\n@@ -0,0 +1,158 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2017 Intel Corporation. All rights reserved.\n+ *   All rights reserved.\n+ *\n+ *   Redistribution and use in source and binary forms, with or without\n+ *   modification, are permitted provided that the following conditions\n+ *   are met:\n+ *\n+ *     * Redistributions of source code must retain the above copyright\n+ *       notice, this list of conditions and the following disclaimer.\n+ *     * Redistributions in binary form must reproduce the above copyright\n+ *       notice, this list of conditions and the following disclaimer in\n+ *       the documentation and/or other materials provided with the\n+ *       distribution.\n+ *     * Neither the name of Intel Corporation nor the names of its\n+ *       contributors may be used to endorse or promote products derived\n+ *       from this software without specific prior written permission.\n+ *\n+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ *   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+#include <string.h>\n+#include <unistd.h>\n+\n+#include <sys/socket.h>\n+#include <linux/netlink.h>\n+\n+#include <rte_spinlock.h>\n+#include <rte_log.h>\n+#include \"rte_nl.h\"\n+#include \"rte_ctrl_if.h\"\n+\n+#define MAX_PAYLOAD sizeof(struct unci_nl_msg)\n+\n+struct ctrl_if_nl {\n+\tunion {\n+\t\tstruct nlmsghdr nlh;\n+\t\tuint8_t nlmsg[NLMSG_SPACE(MAX_PAYLOAD)];\n+\t};\n+\tstruct msghdr msg;\n+\tstruct iovec iov;\n+\tstruct sockaddr_nl dest_addr;\n+};\n+\n+static int sock_fd = -1;\n+static pthread_t thread_id;\n+\n+static struct ctrl_if_nl nl_s;\n+static struct ctrl_if_nl nl_r;\n+\n+static void *\n+nl_recv(void *arg)\n+{\n+\tint ret;\n+\n+\tfor (;;) {\n+\t\tret = recvmsg(sock_fd, &nl_r.msg, 0);\n+\t\tif (ret < 0)\n+\t\t\tcontinue;\n+\n+\t\tif ((unsigned int)ret < sizeof(struct unci_nl_msg)) {\n+\t\t\tRTE_LOG(WARNING, CTRL_IF,\n+\t\t\t\t\t\"Received %d bytes, payload %zu\\n\",\n+\t\t\t\t\tret, sizeof(struct unci_nl_msg));\n+\t\t\tcontinue;\n+\t\t}\n+\t}\n+\n+\treturn arg;\n+}\n+\n+static void\n+nl_setup_header(struct ctrl_if_nl *nl)\n+{\n+\tnl->dest_addr.nl_family = AF_NETLINK;\n+\tnl->dest_addr.nl_pid = 0;   /*  For Linux Kernel */\n+\tnl->dest_addr.nl_groups = 0;\n+\n+\tmemset(nl->nlmsg, 0, NLMSG_SPACE(MAX_PAYLOAD));\n+\n+\t/* Fill the netlink message header */\n+\tnl->nlh.nlmsg_len = NLMSG_LENGTH(MAX_PAYLOAD);\n+\tnl->nlh.nlmsg_pid = getpid();  /* self pid */\n+\tnl->nlh.nlmsg_flags = 0;\n+\n+\tnl->iov.iov_base = (void *)nl->nlmsg;\n+\tnl->iov.iov_len = nl->nlh.nlmsg_len;\n+\tmemset(&nl->msg, 0, sizeof(struct msghdr));\n+\tnl->msg.msg_name = (void *)&nl->dest_addr;\n+\tnl->msg.msg_namelen = sizeof(struct sockaddr_nl);\n+\tnl->msg.msg_iov = &nl->iov;\n+\tnl->msg.msg_iovlen = 1;\n+}\n+\n+static int\n+nl_socket_init(void)\n+{\n+\tstruct sockaddr_nl src_addr;\n+\tint fd;\n+\tint ret;\n+\n+\tfd = socket(PF_NETLINK, SOCK_RAW, UNCI_NL_GRP);\n+\tif (fd < 0)\n+\t\treturn -1;\n+\n+\tsrc_addr.nl_family = AF_NETLINK;\n+\tsrc_addr.nl_pid = getpid();\n+\tret = bind(fd, (struct sockaddr *)&src_addr, sizeof(src_addr));\n+\tif (ret) {\n+\t\tclose(fd);\n+\t\treturn -1;\n+\t}\n+\n+\tnl_setup_header(&nl_s);\n+\tnl_setup_header(&nl_r);\n+\n+\treturn fd;\n+}\n+\n+int\n+control_interface_nl_init(void)\n+{\n+\tint ret;\n+\n+\tsock_fd = nl_socket_init();\n+\tif (sock_fd < 0) {\n+\t\tRTE_LOG(ERR, CTRL_IF, \"Failed to initialize netlink socket\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\tret = pthread_create(&thread_id, NULL, nl_recv, NULL);\n+\tif (ret != 0) {\n+\t\tRTE_LOG(ERR, CTRL_IF, \"Failed to create receive thread\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+void\n+control_interface_nl_release(void)\n+{\n+\tpthread_cancel(thread_id);\n+\tpthread_join(thread_id, NULL);\n+\tclose(sock_fd);\n+}\ndiff --git a/lib/librte_ctrl_if/rte_nl.h b/lib/librte_ctrl_if/rte_nl.h\nnew file mode 100644\nindex 000000000..05a61e193\n--- /dev/null\n+++ b/lib/librte_ctrl_if/rte_nl.h\n@@ -0,0 +1,48 @@\n+/*-\n+ *   BSD LICENSE\n+ *\n+ *   Copyright(c) 2017 Intel Corporation. All rights reserved.\n+ *   All rights reserved.\n+ *\n+ *   Redistribution and use in source and binary forms, with or without\n+ *   modification, are permitted provided that the following conditions\n+ *   are met:\n+ *\n+ *     * Redistributions of source code must retain the above copyright\n+ *       notice, this list of conditions and the following disclaimer.\n+ *     * Redistributions in binary form must reproduce the above copyright\n+ *       notice, this list of conditions and the following disclaimer in\n+ *       the documentation and/or other materials provided with the\n+ *       distribution.\n+ *     * Neither the name of Intel Corporation nor the names of its\n+ *       contributors may be used to endorse or promote products derived\n+ *       from this software without specific prior written permission.\n+ *\n+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ *   \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+\n+#ifndef _RTE_NL_H_\n+#define _RTE_NL_H_\n+\n+#ifdef __cplusplus\n+extern \"C\" {\n+#endif\n+\n+int control_interface_nl_init(void);\n+void control_interface_nl_release(void);\n+\n+#ifdef __cplusplus\n+}\n+#endif\n+\n+#endif /* _RTE_NL_H_ */\n",
    "prefixes": [
        "dpdk-dev",
        "v9",
        "16/20"
    ]
}