get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 47056,
    "url": "http://patches.dpdk.org/api/patches/47056/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20181019002358.17132-2-dg@adax.com/",
    "project": {
        "id": 1,
        "url": "http://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": "<20181019002358.17132-2-dg@adax.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20181019002358.17132-2-dg@adax.com",
    "date": "2018-10-19T00:23:54",
    "name": "[v5,1/5] kni: add API to set link status on kernel interface",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "5f290c87338fee0fa3acf43dc00a6a4f50877532",
    "submitter": {
        "id": 1040,
        "url": "http://patches.dpdk.org/api/people/1040/?format=api",
        "name": "Dan Gora",
        "email": "dg@adax.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20181019002358.17132-2-dg@adax.com/mbox/",
    "series": [
        {
            "id": 1983,
            "url": "http://patches.dpdk.org/api/series/1983/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1983",
            "date": "2018-10-19T00:23:53",
            "name": "kni: add API to set link status on kernel interface",
            "version": 5,
            "mbox": "http://patches.dpdk.org/series/1983/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/47056/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/47056/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 693EF7D4E;\n\tFri, 19 Oct 2018 02:24:23 +0200 (CEST)",
            "from mail-qt1-f196.google.com (mail-qt1-f196.google.com\n\t[209.85.160.196]) by dpdk.org (Postfix) with ESMTP id 5F3877D4E\n\tfor <dev@dpdk.org>; Fri, 19 Oct 2018 02:24:22 +0200 (CEST)",
            "by mail-qt1-f196.google.com with SMTP id x24-v6so4931697qtx.11\n\tfor <dev@dpdk.org>; Thu, 18 Oct 2018 17:24:22 -0700 (PDT)",
            "from snappy.local.lan ([191.205.43.134])\n\tby smtp.gmail.com with ESMTPSA id\n\ty124-v6sm12963926qke.22.2018.10.18.17.24.18\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128);\n\tThu, 18 Oct 2018 17:24:20 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=sender:from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=GU+Ae+jbMqhbgYDk08eZMjAQViAixUhJ/KkiUwuLcxA=;\n\tb=gJrWcIAkkYyW3UD4P5e8qin3gPse5M0IQFa0IE2EGaHgS32oOslwSls/MxaUNaH1xh\n\tsMFniZ9/PKGdRegmHLO3jF/DTelbM64cstG26fPXMXgRMIf5q1tNLqebVktgwAIvj19O\n\ta6JgW9h0XX7ICDlZYV/R4oC8BwROUgddwtUXUYPHShjXev8uIFWpdEMQt4lZspYgC6hY\n\tS3BlrvK3wmpCKjxpUymIeP8TKCfH+6OnNkQNaGsdLjKrjJmW46Th7XMK8MOCNcQrDsMQ\n\t++SoYhAwaJO06a2Zwbgu9XOwgbNvORRMDddHjzSAuUDW4ixyKj9+bKvhx6nW1OdXET2R\n\tTPHg==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:sender:from:to:cc:subject:date:message-id\n\t:in-reply-to:references:mime-version:content-transfer-encoding;\n\tbh=GU+Ae+jbMqhbgYDk08eZMjAQViAixUhJ/KkiUwuLcxA=;\n\tb=sDn2UN0VthylQkY81AbwWGbUzt0OtA6TzdDjmgwjsxJkoQJyqtEsY5rnlR8DxN89Pf\n\tXU+Ykc5gZ51QiQkH9aozGe9v0uJJSqVC3uiqTWxQ18sc++AdfUdTHD+DxU0VE6cop/Cz\n\tx9M0TwNr0jsojD9QmQ2yIu8cI9M9S5U7EE+uOKnn9rB/zuRTLUW111vE/avain0BiUEl\n\t3rpC7TgMggHvTntyiZxmW6xzd0h7pQE8PVx3hYmi2Y7X8F14ISNCYjUyujZm3j3gntnL\n\t+Hs3tghzGbKwsDhIeuSQIkq/sc+lvOdxXdsJG2prkAqHZLZfkvmVvddRTNnsqXaWQ1bw\n\tDyJQ==",
        "X-Gm-Message-State": "ABuFfogg38deSu2swcxyr88E6HHTXnQdMsMIIWGiIdgQK0NBK8eGalg9\n\tjNqyvaKjGU0dpIuvWw/Bbxto0nyT",
        "X-Google-Smtp-Source": "ACcGV631DQ9HsE5g6E9Tfe2Kyxm/X99RhH+69S1MpZ4mrUlWlfWfuCFpPGFrzmo/zw2P7HqnCKFTVQ==",
        "X-Received": "by 2002:a0c:d023:: with SMTP id\n\tu32mr12450572qvg.187.1539908661416; \n\tThu, 18 Oct 2018 17:24:21 -0700 (PDT)",
        "From": "Dan Gora <dg@adax.com>",
        "To": "dev@dpdk.org",
        "Cc": "Igor Ryzhov <iryzhov@nfware.com>,\n\tStephen Hemminger <stephen@networkplumber.org>,\n\tFerruh Yigit <ferruh.yigit@intel.com>, Dan Gora <dg@adax.com>",
        "Date": "Thu, 18 Oct 2018 21:23:54 -0300",
        "Message-Id": "<20181019002358.17132-2-dg@adax.com>",
        "X-Mailer": "git-send-email 2.19.0",
        "In-Reply-To": "<20181019002358.17132-1-dg@adax.com>",
        "References": "<20180911232906.18352-1-dg@adax.com>\n\t<20181019002358.17132-1-dg@adax.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [PATCH v5 1/5] kni: add API to set link status on kernel\n\tinterface",
        "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://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Add a new API function to KNI, rte_kni_update_link() to allow DPDK\napplications to update the link status for KNI network interfaces in\nthe linux kernel.\n\nSigned-off-by: Dan Gora <dg@adax.com>\n---\n lib/librte_kni/rte_kni.c           | 41 ++++++++++++++++\n lib/librte_kni/rte_kni.h           | 20 ++++++++\n lib/librte_kni/rte_kni_version.map |  6 +++\n test/test/test_kni.c               | 77 ++++++++++++++++++++++++++++++\n 4 files changed, 144 insertions(+)",
    "diff": "diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c\nindex b8edd40f4..c9726d4f8 100644\n--- a/lib/librte_kni/rte_kni.c\n+++ b/lib/librte_kni/rte_kni.c\n@@ -717,6 +717,47 @@ rte_kni_unregister_handlers(struct rte_kni *kni)\n \n \treturn 0;\n }\n+\n+int __rte_experimental\n+rte_kni_update_link(struct rte_kni *kni, unsigned int linkup)\n+{\n+\tchar path[64];\n+\tchar old_carrier[2];\n+\tconst char *new_carrier;\n+\tint old_linkup;\n+\tint fd, ret;\n+\n+\tif (kni == NULL)\n+\t\treturn -1;\n+\n+\tsnprintf(path, sizeof(path), \"/sys/devices/virtual/net/%s/carrier\",\n+\t\tkni->name);\n+\n+\tfd = open(path, O_RDWR);\n+\tif (fd == -1) {\n+\t\tRTE_LOG(ERR, KNI, \"Failed to open file: %s.\\n\", path);\n+\t\treturn -1;\n+\t}\n+\n+\tret = read(fd, old_carrier, 2);\n+\tif (ret < 1) {\n+\t\tclose(fd);\n+\t\treturn -1;\n+\t}\n+\told_linkup = (old_carrier[0] == '1');\n+\n+\tnew_carrier = linkup ? \"1\" : \"0\";\n+\tret = write(fd, new_carrier, 1);\n+\tif (ret < 1) {\n+\t\tRTE_LOG(ERR, KNI, \"Failed to write file: %s.\\n\", path);\n+\t\tclose(fd);\n+\t\treturn -1;\n+\t}\n+\n+\tclose(fd);\n+\treturn old_linkup;\n+}\n+\n void\n rte_kni_close(void)\n {\ndiff --git a/lib/librte_kni/rte_kni.h b/lib/librte_kni/rte_kni.h\nindex 601abdfc6..02ca43b4b 100644\n--- a/lib/librte_kni/rte_kni.h\n+++ b/lib/librte_kni/rte_kni.h\n@@ -232,6 +232,26 @@ int rte_kni_register_handlers(struct rte_kni *kni, struct rte_kni_ops *ops);\n  */\n int rte_kni_unregister_handlers(struct rte_kni *kni);\n \n+/**\n+ * Update link carrier state for KNI port.\n+ *\n+ * Update the linkup/linkdown state of a KNI interface in the kernel.\n+ *\n+ * @param kni\n+ *  pointer to struct rte_kni.\n+ * @param linkup\n+ *  New link state:\n+ *  0 for linkdown.\n+ *  > 0 for linkup.\n+ *\n+ * @return\n+ *  On failure: -1\n+ *  Previous link state == linkdown: 0\n+ *  Previous link state == linkup: 1\n+ */\n+int __rte_experimental\n+rte_kni_update_link(struct rte_kni *kni, unsigned int linkup);\n+\n /**\n  *  Close KNI device.\n  */\ndiff --git a/lib/librte_kni/rte_kni_version.map b/lib/librte_kni/rte_kni_version.map\nindex acd515eb0..c877dc6aa 100644\n--- a/lib/librte_kni/rte_kni_version.map\n+++ b/lib/librte_kni/rte_kni_version.map\n@@ -15,3 +15,9 @@ DPDK_2.0 {\n \n \tlocal: *;\n };\n+\n+EXPERIMENTAL {\n+\tglobal:\n+\n+\trte_kni_update_link;\n+};\ndiff --git a/test/test/test_kni.c b/test/test/test_kni.c\nindex cf64c0b27..e38206905 100644\n--- a/test/test/test_kni.c\n+++ b/test/test/test_kni.c\n@@ -118,6 +118,79 @@ kni_change_mtu(uint16_t port_id, unsigned int new_mtu)\n \t\t\t\t\t port_id, kni_pkt_mtu);\n \treturn 0;\n }\n+\n+static int\n+test_kni_link_change(void)\n+{\n+\tint ret;\n+\tint pid;\n+\n+\tpid = fork();\n+\tif (pid < 0) {\n+\t\tprintf(\"Error: Failed to fork a process\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\tif (pid == 0) {\n+\t\tprintf(\"Starting KNI Link status change tests.\\n\");\n+\t\tif (system(IFCONFIG TEST_KNI_PORT\" up\") == -1) {\n+\t\t\tret = -1;\n+\t\t\tgoto error;\n+\t\t}\n+\n+\t\tret = rte_kni_update_link(test_kni_ctx, 1);\n+\t\tif (ret < 0) {\n+\t\t\tprintf(\"Failed to change link state to Up ret=%d.\\n\",\n+\t\t\t\tret);\n+\t\t\tgoto error;\n+\t\t}\n+\t\trte_delay_ms(1000);\n+\t\tprintf(\"KNI: Set LINKUP, previous state=%d\\n\", ret);\n+\n+\t\tret = rte_kni_update_link(test_kni_ctx, 0);\n+\t\tif (ret != 1) {\n+\t\t\tprintf(\n+\t\t\"Failed! Previous link state should be 1, returned %d.\\n\",\n+\t\t\t\tret);\n+\t\t\tgoto error;\n+\t\t}\n+\t\trte_delay_ms(1000);\n+\t\tprintf(\"KNI: Set LINKDOWN, previous state=%d\\n\", ret);\n+\n+\t\tret = rte_kni_update_link(test_kni_ctx, 1);\n+\t\tif (ret != 0) {\n+\t\t\tprintf(\n+\t\t\"Failed! Previous link state should be 0, returned %d.\\n\",\n+\t\t\t\tret);\n+\t\t\tgoto error;\n+\t\t}\n+\t\tprintf(\"KNI: Set LINKUP, previous state=%d\\n\", ret);\n+\n+\t\tret = 0;\n+\t\trte_delay_ms(1000);\n+\n+error:\n+\t\tif (system(IFCONFIG TEST_KNI_PORT\" down\") == -1)\n+\t\t\tret = -1;\n+\n+\t\tprintf(\"KNI: Link status change tests: %s.\\n\",\n+\t\t\t(ret == 0) ? \"Passed\" : \"Failed\");\n+\t\texit(ret);\n+\t} else {\n+\t\tint p_ret, status;\n+\n+\t\twhile (1) {\n+\t\t\tp_ret = waitpid(pid, &status, WNOHANG);\n+\t\t\tif (p_ret != 0) {\n+\t\t\t\tif (WIFEXITED(status))\n+\t\t\t\t\treturn WEXITSTATUS(status);\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\trte_delay_ms(10);\n+\t\t\trte_kni_handle_request(test_kni_ctx);\n+\t\t}\n+\t}\n+}\n /**\n  * This loop fully tests the basic functions of KNI. e.g. transmitting,\n  * receiving to, from kernel space, and kernel requests.\n@@ -401,6 +474,10 @@ test_kni_processing(uint16_t port_id, struct rte_mempool *mp)\n \t\tgoto fail_kni;\n \t}\n \n+\tret = test_kni_link_change();\n+\tif (ret != 0)\n+\t\tgoto fail_kni;\n+\n \trte_eal_mp_remote_launch(test_kni_loop, NULL, CALL_MASTER);\n \tRTE_LCORE_FOREACH_SLAVE(i) {\n \t\tif (rte_eal_wait_lcore(i) < 0) {\n",
    "prefixes": [
        "v5",
        "1/5"
    ]
}