get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 138782,
    "url": "http://patchwork.dpdk.org/api/patches/138782/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20240325205405.669897-13-stephen@networkplumber.org/",
    "project": {
        "id": 1,
        "url": "http://patchwork.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": "<20240325205405.669897-13-stephen@networkplumber.org>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20240325205405.669897-13-stephen@networkplumber.org",
    "date": "2024-03-25T20:47:09",
    "name": "[v12,12/14] log: add support for systemd journal",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "50d0f3361e1a5ff2b05efdaf077ca8a967860db1",
    "submitter": {
        "id": 27,
        "url": "http://patchwork.dpdk.org/api/people/27/?format=api",
        "name": "Stephen Hemminger",
        "email": "stephen@networkplumber.org"
    },
    "delegate": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20240325205405.669897-13-stephen@networkplumber.org/mbox/",
    "series": [
        {
            "id": 31616,
            "url": "http://patchwork.dpdk.org/api/series/31616/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=31616",
            "date": "2024-03-25T20:46:57",
            "name": "Logging unification and enhancements",
            "version": 12,
            "mbox": "http://patchwork.dpdk.org/series/31616/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/138782/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/138782/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id C89D243D49;\n\tMon, 25 Mar 2024 21:55:39 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 90156410D0;\n\tMon, 25 Mar 2024 21:54:35 +0100 (CET)",
            "from mail-pl1-f174.google.com (mail-pl1-f174.google.com\n [209.85.214.174])\n by mails.dpdk.org (Postfix) with ESMTP id 718E640DDE\n for <dev@dpdk.org>; Mon, 25 Mar 2024 21:54:29 +0100 (CET)",
            "by mail-pl1-f174.google.com with SMTP id\n d9443c01a7336-1e0d82c529fso5677215ad.2\n for <dev@dpdk.org>; Mon, 25 Mar 2024 13:54:29 -0700 (PDT)",
            "from hermes.local (204-195-123-203.wavecable.com. [204.195.123.203])\n by smtp.gmail.com with ESMTPSA id\n b18-20020a170903229200b001e0b5eee802sm3164487plh.123.2024.03.25.13.54.27\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Mon, 25 Mar 2024 13:54:28 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1711400068;\n x=1712004868; darn=dpdk.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=d/UE9ipVPe9mD7+Cgp8jISoE1qnPb3z27iLpF4O0SEQ=;\n b=3UGI00PJsmcndQHI1xYJRawSNRvOc9vgLc38sOAyCC7MV6bPm1BhtUyP4FJ2guZvbk\n e53i+0BSdIvPFzZcmk/y4LEgMevL6AbxzZ7khUozkpi0en4BxpJ7zB50I6qAsbAxRlO9\n umptKT2OdSvnuusHCuRYlGbIcRk0en/u1mQiOoe/LnZH2WMRPAlP8CvBaFVx2+AShuMd\n zsxELhy7QvmrG7xJLiwM7Usf/AD/x49S0Dg3HUoWtpG79KVUycCIvO+hPexmB+SuZ9OF\n GeLVUJ4p+kGwIZhvs6Dk/OEBXmOuUVv1M6AjJzPXnd5KLI+v/ynZevtdg9s0vujdT5dD\n z2Vw==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20230601; t=1711400068; x=1712004868;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n :subject:date:message-id:reply-to;\n bh=d/UE9ipVPe9mD7+Cgp8jISoE1qnPb3z27iLpF4O0SEQ=;\n b=dUDzi54aoMKucVc0l4q664rriLc4RWi4ppAf6M252M1VA1teQJs63qwTIjAjCGuTMW\n 6mWJGSrooPBHGJvbLia4duSJL1RULDHNiYObUBBphlPAEF7NGbJL/Bu3Np1gylqPAz0Y\n NvkPRUFYyifDPU97QaA6uR9g8q3yvacdJ7EJ8cpfze3RFIkGA+UfDFO1GpR6yGMaW85l\n nvmXKmLDbC2bAKdRUW7YHJZaVCreAyuOnLTPbq4IJKhmQJfuSMz7UGYWv6Q7YnfxkfRv\n IaCssO6wR78chAIqU9DS2ADCMHyOoVTdbHr545OYFehThYYglbUMDclOXUpQE+XZp6EL\n Q90A==",
        "X-Gm-Message-State": "AOJu0YwVVq4KuKJCIRuKptm7GV2T7WIMjs8aP6f8MB+DgiJOR33v6O76\n Kgt0UTe07TzlnP7FrgnsrMr2uLmT4QCTvyp5AOiff/7s2rKU0ZIIYy0P++wYTsKo5ZPQGlMGwYp\n w",
        "X-Google-Smtp-Source": "\n AGHT+IHphrNR34HwvHP4H5FbYwTt4xi23qv1e20oBqRi7iho0zwL6TYhZP2M3On29ml7TgUaWxmP1A==",
        "X-Received": "by 2002:a17:902:e80d:b0:1e0:afa0:d515 with SMTP id\n u13-20020a170902e80d00b001e0afa0d515mr5797214plg.29.1711400068632;\n Mon, 25 Mar 2024 13:54:28 -0700 (PDT)",
        "From": "Stephen Hemminger <stephen@networkplumber.org>",
        "To": "dev@dpdk.org",
        "Cc": "Stephen Hemminger <stephen@networkplumber.org>",
        "Subject": "[PATCH v12 12/14] log: add support for systemd journal",
        "Date": "Mon, 25 Mar 2024 13:47:09 -0700",
        "Message-ID": "<20240325205405.669897-13-stephen@networkplumber.org>",
        "X-Mailer": "git-send-email 2.43.0",
        "In-Reply-To": "<20240325205405.669897-1-stephen@networkplumber.org>",
        "References": "<20200814173441.23086-1-stephen@networkplumber.org>\n <20240325205405.669897-1-stephen@networkplumber.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <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 <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "If DPDK application is being run as a systemd service, then\nit can use the journal protocol which allows putting more information\nin the log such as priority and other information.\n\nThe use of journal protocol is automatically detected and\nhandled.  Rather than having a dependency on libsystemd,\njust use the protocol directly as defined in:\n\thttps://systemd.io/JOURNAL_NATIVE_PROTOCOL/\n\nSigned-off-by: Stephen Hemminger <stephen@networkplumber.org>\n---\n lib/log/log.c | 128 +++++++++++++++++++++++++++++++++++++++++++++++++-\n 1 file changed, 126 insertions(+), 2 deletions(-)",
    "diff": "diff --git a/lib/log/log.c b/lib/log/log.c\nindex d8974c66db..0f7bdb3f25 100644\n--- a/lib/log/log.c\n+++ b/lib/log/log.c\n@@ -17,6 +17,10 @@\n #include <rte_os_shim.h>\n #else\n #include <syslog.h>\n+#include <sys/uio.h>\n+#include <sys/stat.h>\n+#include <sys/socket.h>\n+#include <sys/un.h>\n #endif\n \n #include <rte_log.h>\n@@ -56,6 +60,7 @@ static struct rte_logs {\n \tFILE *file;     /**< Output file set by rte_openlog_stream, or NULL. */\n #ifndef RTE_EXEC_ENV_WINDOWS\n \tenum eal_log_syslog syslog_opt;\n+\tint journal_fd;\n #endif\n \tlog_print_t print_func;\n \n@@ -758,6 +763,112 @@ static cookie_io_functions_t syslog_log_func = {\n \t.write = syslog_log_write,\n \t.close = syslog_log_close,\n };\n+\n+\n+/*\n+ * send message using journal protocol to journald\n+ */\n+__rte_format_printf(3, 0)\n+static int\n+journal_print(FILE *f __rte_unused, uint32_t level, const char *format, va_list ap)\n+{\n+\tstruct iovec iov[3];\n+\tchar *buf = NULL;\n+\tsize_t len;\n+\tchar msg[] = \"MESSAGE=\";\n+\tchar *prio;\n+\n+\tiov[0].iov_base = msg;\n+\tiov[0].iov_len = strlen(msg);\n+\n+\tlen = vasprintf(&buf, format, ap);\n+\tif (len == 0)\n+\t\treturn 0;\n+\n+\t/* check that message ends with newline, if not add one */\n+\tif (buf[len - 1] != '\\n') {\n+\t\tchar *clone  = alloca(len + 1);\n+\t\tif (clone == NULL)\n+\t\t\treturn 0;\n+\t\tmemcpy(clone, buf, len);\n+\t\tclone[len++] = '\\n';\n+\t\tbuf = clone;\n+\t}\n+\n+\tiov[1].iov_base = buf;\n+\tiov[1].iov_len = len;\n+\n+\t/* priority value between 0 (\"emerg\") and 7 (\"debug\") */\n+\tlen = asprintf(&prio, \"PRIORITY=%i\\n\", level - 1);\n+\tiov[2].iov_base = prio;\n+\tiov[2].iov_len = len;\n+\n+\treturn writev(rte_logs.journal_fd, iov, 3);\n+}\n+\n+/*\n+ * Check if stderr is going to system journal.\n+ * This is the documented way to handle systemd journal\n+ *\n+ * See: https://systemd.io/JOURNAL_NATIVE_PROTOCOL/\n+ *\n+ */\n+static bool\n+using_journal(void)\n+{\n+\tchar *jenv, *endp = NULL;\n+\tstruct stat st;\n+\tunsigned long dev, ino;\n+\n+\tjenv = getenv(\"JOURNAL_STREAM\");\n+\tif (jenv == NULL)\n+\t\treturn false;\n+\n+\tif (fstat(STDERR_FILENO, &st) < 0)\n+\t\treturn false;\n+\n+\t/* systemd sets colon-separated list of device and inode number */\n+\tdev = strtoul(jenv, &endp, 10);\n+\tif (endp == NULL || *endp != ':')\n+\t\treturn false;\t/* missing colon */\n+\n+\tino = strtoul(endp + 1, NULL, 10);\n+\n+\treturn dev == st.st_dev && ino == st.st_ino;\n+}\n+\n+/* Connect to systemd's journal service */\n+static int\n+open_journal(const char *id)\n+{\n+\tchar *syslog_id = NULL;\n+\tstruct sockaddr_un sun = {\n+\t\t.sun_family = AF_UNIX,\n+\t\t.sun_path = \"/run/systemd/journal/socket\",\n+\t};\n+\tssize_t len;\n+\tint s;\n+\n+\ts = socket(AF_UNIX, SOCK_DGRAM, 0);\n+\tif (s < 0)\n+\t\treturn -1;\n+\n+\tif (connect(s, (struct sockaddr *)&sun, sizeof(sun)) < 0)\n+\t\tgoto error;\n+\n+\t/* Send syslog identifier as first message */\n+\tlen = asprintf(&syslog_id, \"SYSLOG_IDENTIFIER=%s\\n\", id);\n+\tif (len == 0)\n+\t\tgoto error;\n+\n+\tif (write(s, syslog_id, len) != len)\n+\t\tgoto error;\n+\n+\treturn s;\n+error:\n+\tclose(s);\n+\treturn -1;\n+}\n #endif\n \n \n@@ -765,11 +876,24 @@ static cookie_io_functions_t syslog_log_func = {\n static void\n log_output_selection(const char *id)\n {\n+#ifdef RTE_EXEC_ENV_WINDOWS\n \tRTE_SET_USED(id);\n-\n-#ifndef RTE_EXEC_ENV_WINDOWS\n+#else\n \tbool is_terminal = isatty(STDERR_FILENO);\n \n+\t/* If stderr is redirected to systemd journal then upgrade */\n+\tif (using_journal()) {\n+\t\tint jfd = open_journal(id);\n+\n+\t\tif (jfd < 0) {\n+\t\t\tRTE_LOG_LINE(NOTICE, EAL, \"Cannot connect to journal: %s\",\n+\t\t\t\t     strerror(errno));\n+\t\t} else {\n+\t\t\trte_logs.print_func = journal_print;\n+\t\t\treturn;\n+\t\t}\n+\t}\n+\n \tif (!(rte_logs.syslog_opt == EAL_LOG_SYSLOG_NONE ||\n \t      (rte_logs.syslog_opt == EAL_LOG_SYSLOG_AUTO && is_terminal))) {\n \t\tint flags = LOG_NDELAY | LOG_PID;\n",
    "prefixes": [
        "v12",
        "12/14"
    ]
}