get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 129119,
    "url": "http://patchwork.dpdk.org/api/patches/129119/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20230629155858.75668-2-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": "<20230629155858.75668-2-stephen@networkplumber.org>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20230629155858.75668-2-stephen@networkplumber.org",
    "date": "2023-06-29T15:58:38",
    "name": "[v6,1/6] eal: unify logging code",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "afd60485f3839d124121ed15bfb269a0b76a62e9",
    "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/20230629155858.75668-2-stephen@networkplumber.org/mbox/",
    "series": [
        {
            "id": 28717,
            "url": "http://patchwork.dpdk.org/api/series/28717/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=28717",
            "date": "2023-06-29T15:58:37",
            "name": "Logging related patches",
            "version": 6,
            "mbox": "http://patchwork.dpdk.org/series/28717/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/129119/comments/",
    "check": "success",
    "checks": "http://patchwork.dpdk.org/api/patches/129119/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 90FF742D8D;\n\tThu, 29 Jun 2023 17:59:22 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 3FCB341104;\n\tThu, 29 Jun 2023 17:59:20 +0200 (CEST)",
            "from mail-pg1-f174.google.com (mail-pg1-f174.google.com\n [209.85.215.174])\n by mails.dpdk.org (Postfix) with ESMTP id 36CD8406B7\n for <dev@dpdk.org>; Thu, 29 Jun 2023 17:59:17 +0200 (CEST)",
            "by mail-pg1-f174.google.com with SMTP id\n 41be03b00d2f7-55b1238a013so598096a12.3\n for <dev@dpdk.org>; Thu, 29 Jun 2023 08:59:17 -0700 (PDT)",
            "from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218])\n by smtp.gmail.com with ESMTPSA id\n c6-20020a63ea06000000b0055b553157a5sm471716pgi.71.2023.06.29.08.59.15\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 29 Jun 2023 08:59:15 -0700 (PDT)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1688054356;\n x=1690646356;\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=qOUhFNDBJzTW/ylgqhJjNMUgMVnNVNu77BRkvSIbP6o=;\n b=3ABgOLbhE0PisNCZcIxifS/mQEbk0SwkQUyXeBnhUFr8P9eilNWzMHUDcmpama+fZI\n rRiA4RS5COfbwcvyz88y6hWCpjDIFODjFD8w3OMqheGa1irOOjxNFQ4tIp77MZN/rSPI\n meUeSs3Dlj1WPDT8Bu6FZ3uIZ26f1KzzsOnOqXDdBcXtLYgRpquA7pcoANNQ9J3HYoHw\n cJ+7jK+cROy7aSO/5A6HrzN7CNvW3s+9oIQK0UhHGHJotdt3r4HhFq7XdB1oyKAWjQWq\n yHST2C8B31Q5GjFd5C6RIGvSyc4rBMpqmclp6ZhkPR7+V99fPSXqGPy2cmwcGYvMnVQF\n B8vA==",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20221208; t=1688054356; x=1690646356;\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=qOUhFNDBJzTW/ylgqhJjNMUgMVnNVNu77BRkvSIbP6o=;\n b=bZlypOI2hQaKTxTod621lUh247xedP/sPJJeCGyEZ+FCGANFNxmFK/2rxjPUVVxhfK\n z9kBYjRypUtfO1ApBchLBG9xTzFMTvqmCuBR1L3ghXeKjHbMgl71ZSUEuh4VHmYWSBAb\n dVYpDu0hdabdXPKODszLqRRt4hAgnDAi9QnGWi0ncpIzgIgYfJ7qIParIX89Io3YqxIH\n 3Baj34bkH6hKPdxrPS695iiwiP7Bw9xYZpK96orpFxAulZiBpHfUZhg4vv1J7Oz4pHI5\n 6gj5AAD2clQv/q4SpXbkjC7tewVvEkVaCZhVcsOpCPs5v/wxf6o/XsQ59KnYPAztvClX\n Z0Cg==",
        "X-Gm-Message-State": "AC+VfDwgodJYPvUn5+8L7xpL2NkIDyMgiQ6CxjuPEa4MZ/y9DpW8NsaC\n bM1Lnb83tH6xotseVgWexx3pZkwNJzyhL/8oFsuhQA==",
        "X-Google-Smtp-Source": "\n ACHHUZ7RR+6WVLs0cnswTZV6Wr49e7AXKvn3D13gPt6F7SfwoNgJykG7NW6E15c43FQBIqr86FAtlA==",
        "X-Received": "by 2002:a05:6a20:72a5:b0:122:92d0:452a with SMTP id\n o37-20020a056a2072a500b0012292d0452amr52349pzk.37.1688054356094;\n Thu, 29 Jun 2023 08:59:16 -0700 (PDT)",
        "From": "Stephen Hemminger <stephen@networkplumber.org>",
        "To": "dev@dpdk.org",
        "Cc": "Stephen Hemminger <stephen@networkplumber.org>,\n Bruce Richardson <bruce.richardson@intel.com>,\n Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>,\n Narcisa Ana Maria Vasile <navasile@linux.microsoft.com>,\n Dmitry Malloy <dmitrym@microsoft.com>,\n Pallavi Kadam <pallavi.kadam@intel.com>",
        "Subject": "[PATCH v6 1/6] eal: unify logging code",
        "Date": "Thu, 29 Jun 2023 08:58:38 -0700",
        "Message-Id": "<20230629155858.75668-2-stephen@networkplumber.org>",
        "X-Mailer": "git-send-email 2.39.2",
        "In-Reply-To": "<20230629155858.75668-1-stephen@networkplumber.org>",
        "References": "<20200814173441.23086-1-stephen@networkplumber.org>\n <20230629155858.75668-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": "FreeBSD logging code was not using syslog and did not have\nthe same options as Linux. Use a common set of functions for that.\n\nPre-parsing for log level is common to all OS's.\n\nNow the pre-scan can return an error.\nA bad argument give to --log-level option was given the\ncode would keep going.\n\nSigned-off-by: Stephen Hemminger <stephen@networkplumber.org>\n\nmake log_parse common to windows\n---\n .../freebsd_gsg/freebsd_eal_parameters.rst    | 27 +++++++++\n lib/eal/common/eal_common_log.c               | 46 ++++++++++++++++\n lib/eal/common/eal_log.h                      |  5 ++\n lib/eal/freebsd/eal.c                         | 55 ++++---------------\n lib/eal/linux/eal.c                           | 46 ++--------------\n lib/eal/linux/meson.build                     |  1 -\n lib/eal/{linux => unix}/eal_log.c             | 11 ++++\n lib/eal/unix/meson.build                      |  1 +\n lib/eal/windows/eal.c                         | 35 ------------\n 9 files changed, 108 insertions(+), 119 deletions(-)\n rename lib/eal/{linux => unix}/eal_log.c (76%)",
    "diff": "diff --git a/doc/guides/freebsd_gsg/freebsd_eal_parameters.rst b/doc/guides/freebsd_gsg/freebsd_eal_parameters.rst\nindex fba467a2ce92..9270d9fa3bfc 100644\n--- a/doc/guides/freebsd_gsg/freebsd_eal_parameters.rst\n+++ b/doc/guides/freebsd_gsg/freebsd_eal_parameters.rst\n@@ -18,3 +18,30 @@ FreeBSD-specific EAL parameters\n -------------------------------\n \n There are currently no FreeBSD-specific EAL command-line parameters available.\n+\n+Other options\n+~~~~~~~~~~~~~\n+\n+*   ``--syslog <syslog facility>``\n+\n+    Set syslog facility. Valid syslog facilities are::\n+\n+        auth\n+        cron\n+        daemon\n+        ftp\n+        kern\n+        lpr\n+        mail\n+        news\n+        syslog\n+        user\n+        uucp\n+        local0\n+        local1\n+        local2\n+        local3\n+        local4\n+        local5\n+        local6\n+        local7\ndiff --git a/lib/eal/common/eal_common_log.c b/lib/eal/common/eal_common_log.c\nindex bd7b188ceb4a..7e2f010fa371 100644\n--- a/lib/eal/common/eal_common_log.c\n+++ b/lib/eal/common/eal_common_log.c\n@@ -2,6 +2,7 @@\n  * Copyright(c) 2010-2014 Intel Corporation\n  */\n \n+#include <getopt.h>\n #include <stdio.h>\n #include <stdint.h>\n #include <stdarg.h>\n@@ -16,6 +17,8 @@\n #include <rte_per_lcore.h>\n \n #include \"eal_log.h\"\n+#include \"eal_internal_cfg.h\"\n+#include \"eal_options.h\"\n #include \"eal_private.h\"\n \n struct rte_log_dynamic_type {\n@@ -223,6 +226,49 @@ log_save_level(uint32_t priority, const char *regex, const char *pattern)\n \treturn -1;\n }\n \n+\n+/* Parse the all arguments looking for --log-level */\n+int\n+eal_log_level_parse(int argc, char *const argv[])\n+{\n+\tstruct internal_config *internal_conf = eal_get_internal_configuration();\n+\tint option_index, opt;\n+\tconst int old_optind = optind;\n+\tconst int old_optopt = optopt;\n+\tchar * const old_optarg = optarg;\n+#ifdef RTE_EXEC_ENV_FREEBSD\n+\tconst int old_optreset = optreset;\n+\toptreset = 1;\n+#endif\n+\n+\toptind = 1;\n+\n+\twhile ((opt = getopt_long(argc, argv, eal_short_options,\n+\t\t\t\t  eal_long_options, &option_index)) != EOF) {\n+\n+\t\tswitch (opt) {\n+\t\tcase OPT_LOG_LEVEL_NUM:\n+\t\t\tif (eal_parse_common_option(opt, optarg, internal_conf) < 0)\n+\t\t\t\treturn -1;\n+\t\t\tbreak;\n+\t\tcase '?':\n+\t\t\t/* getopt is not happy, stop right now */\n+\t\t\tgoto out;\n+\t\tdefault:\n+\t\t\tcontinue;\n+\t\t}\n+\t}\n+out:\n+\t/* restore getopt lib */\n+\toptind = old_optind;\n+\toptopt = old_optopt;\n+\toptarg = old_optarg;\n+#ifdef RTE_EXEC_ENV_FREEBSD\n+\toptreset = old_optreset;\n+#endif\n+\treturn 0;\n+}\n+\n int\n eal_log_save_regexp(const char *regex, uint32_t level)\n {\ndiff --git a/lib/eal/common/eal_log.h b/lib/eal/common/eal_log.h\nindex c784fa604389..31dc489350f6 100644\n--- a/lib/eal/common/eal_log.h\n+++ b/lib/eal/common/eal_log.h\n@@ -13,6 +13,11 @@\n  */\n int eal_log_init(const char *id, int facility);\n \n+/*\n+ * Scan command line args for log settings.\n+ */\n+int eal_log_level_parse(int argc, char * const argv[]);\n+\n /*\n  * Determine where log data is written when no call to rte_openlog_stream.\n  */\ndiff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c\nindex 7008303e112a..bb9a2b1653d9 100644\n--- a/lib/eal/freebsd/eal.c\n+++ b/lib/eal/freebsd/eal.c\n@@ -52,6 +52,7 @@\n #include \"eal_hugepages.h\"\n #include \"eal_options.h\"\n #include \"eal_memcfg.h\"\n+#include \"eal_log.h\"\n #include \"eal_trace.h\"\n \n #define MEMSIZE_IF_NO_HUGE_PAGE (64ULL * 1024ULL * 1024ULL)\n@@ -363,48 +364,6 @@ eal_get_hugepage_mem_size(void)\n \treturn (size < SIZE_MAX) ? (size_t)(size) : SIZE_MAX;\n }\n \n-/* Parse the arguments for --log-level only */\n-static void\n-eal_log_level_parse(int argc, char **argv)\n-{\n-\tint opt;\n-\tchar **argvopt;\n-\tint option_index;\n-\tconst int old_optind = optind;\n-\tconst int old_optopt = optopt;\n-\tconst int old_optreset = optreset;\n-\tchar * const old_optarg = optarg;\n-\tstruct internal_config *internal_conf =\n-\t\teal_get_internal_configuration();\n-\n-\targvopt = argv;\n-\toptind = 1;\n-\toptreset = 1;\n-\n-\twhile ((opt = getopt_long(argc, argvopt, eal_short_options,\n-\t\t\t\t  eal_long_options, &option_index)) != EOF) {\n-\n-\t\tint ret;\n-\n-\t\t/* getopt is not happy, stop right now */\n-\t\tif (opt == '?')\n-\t\t\tbreak;\n-\n-\t\tret = (opt == OPT_LOG_LEVEL_NUM) ?\n-\t\t    eal_parse_common_option(opt, optarg, internal_conf) : 0;\n-\n-\t\t/* common parser is not happy */\n-\t\tif (ret < 0)\n-\t\t\tbreak;\n-\t}\n-\n-\t/* restore getopt lib */\n-\toptind = old_optind;\n-\toptopt = old_optopt;\n-\toptreset = old_optreset;\n-\toptarg = old_optarg;\n-}\n-\n /* Parse the argument given in the command line of the application */\n static int\n eal_parse_args(int argc, char **argv)\n@@ -610,7 +569,11 @@ rte_eal_init(int argc, char **argv)\n \teal_save_args(argc, argv);\n \n \t/* set log level as early as possible */\n-\teal_log_level_parse(argc, argv);\n+\tif (eal_log_level_parse(argc, argv) < 0) {\n+\t\trte_eal_init_alert(\"invalid log option.\");\n+\t\trte_errno = EINVAL;\n+\t\treturn -1;\n+\t}\n \n \tif (rte_eal_cpu_init() < 0) {\n \t\trte_eal_init_alert(\"Cannot detect lcores.\");\n@@ -759,6 +722,12 @@ rte_eal_init(int argc, char **argv)\n #endif\n \t}\n \n+\tif (eal_log_init(getprogname(), internal_conf->syslog_facility) < 0) {\n+\t\trte_eal_init_alert(\"Cannot init logging.\");\n+\t\trte_errno = ENOMEM;\n+\t\treturn -1;\n+\t}\n+\n \t/* in secondary processes, memory init may allocate additional fbarrays\n \t * not present in primary processes, so to avoid any potential issues,\n \t * initialize memzones first.\ndiff --git a/lib/eal/linux/eal.c b/lib/eal/linux/eal.c\nindex 145afafde234..c9475560d986 100644\n--- a/lib/eal/linux/eal.c\n+++ b/lib/eal/linux/eal.c\n@@ -546,45 +546,6 @@ eal_parse_vfio_vf_token(const char *vf_token)\n \treturn -1;\n }\n \n-/* Parse the arguments for --log-level only */\n-static void\n-eal_log_level_parse(int argc, char **argv)\n-{\n-\tint opt;\n-\tchar **argvopt;\n-\tint option_index;\n-\tconst int old_optind = optind;\n-\tconst int old_optopt = optopt;\n-\tchar * const old_optarg = optarg;\n-\tstruct internal_config *internal_conf =\n-\t\teal_get_internal_configuration();\n-\n-\targvopt = argv;\n-\toptind = 1;\n-\n-\twhile ((opt = getopt_long(argc, argvopt, eal_short_options,\n-\t\t\t\t  eal_long_options, &option_index)) != EOF) {\n-\n-\t\tint ret;\n-\n-\t\t/* getopt is not happy, stop right now */\n-\t\tif (opt == '?')\n-\t\t\tbreak;\n-\n-\t\tret = (opt == OPT_LOG_LEVEL_NUM) ?\n-\t\t\teal_parse_common_option(opt, optarg, internal_conf) : 0;\n-\n-\t\t/* common parser is not happy */\n-\t\tif (ret < 0)\n-\t\t\tbreak;\n-\t}\n-\n-\t/* restore getopt lib */\n-\toptind = old_optind;\n-\toptopt = old_optopt;\n-\toptarg = old_optarg;\n-}\n-\n static int\n eal_parse_huge_worker_stack(const char *arg)\n {\n@@ -993,7 +954,12 @@ rte_eal_init(int argc, char **argv)\n \teal_reset_internal_config(internal_conf);\n \n \t/* set log level as early as possible */\n-\teal_log_level_parse(argc, argv);\n+\tif (eal_log_level_parse(argc, argv) < 0) {\n+\t\trte_eal_init_alert(\"invalid log option.\");\n+\t\trte_errno = EINVAL;\n+\t\t__atomic_store_n(&run_once, 0, __ATOMIC_RELAXED);\n+\t\treturn -1;\n+\t}\n \n \t/* clone argv to report out later in telemetry */\n \teal_save_args(argc, argv);\ndiff --git a/lib/eal/linux/meson.build b/lib/eal/linux/meson.build\nindex 5af456db9edb..e99ebed25692 100644\n--- a/lib/eal/linux/meson.build\n+++ b/lib/eal/linux/meson.build\n@@ -11,7 +11,6 @@ sources += files(\n         'eal_hugepage_info.c',\n         'eal_interrupts.c',\n         'eal_lcore.c',\n-        'eal_log.c',\n         'eal_memalloc.c',\n         'eal_memory.c',\n         'eal_thread.c',\ndiff --git a/lib/eal/linux/eal_log.c b/lib/eal/unix/eal_log.c\nsimilarity index 76%\nrename from lib/eal/linux/eal_log.c\nrename to lib/eal/unix/eal_log.c\nindex d44416fd6570..85d817c2d31e 100644\n--- a/lib/eal/linux/eal_log.c\n+++ b/lib/eal/unix/eal_log.c\n@@ -9,6 +9,8 @@\n #include <rte_log.h>\n \n #include \"eal_log.h\"\n+#include \"eal_internal_cfg.h\"\n+#include \"eal_private.h\"\n \n /*\n  * default log function\n@@ -25,6 +27,15 @@ console_log_write(__rte_unused void *c, const char *buf, size_t size)\n \t/* Syslog error levels are from 0 to 7, so subtract 1 to convert */\n \tsyslog(rte_log_cur_msg_loglevel() - 1, \"%.*s\", (int)size, buf);\n \n+#ifdef RTE_EXEC_ENV_LINUX\n+\t/* Handle glibc quirk: write function should return the number of bytes\n+\t * copied from buf, or 0 on error. (The function must not return a negative value.)\n+\t * FreeBSD expects that write function behaves like write(2).\n+\t */\n+\tif (ret < 0)\n+\t\tret = 0;\n+#endif\n+\n \treturn ret;\n }\n \ndiff --git a/lib/eal/unix/meson.build b/lib/eal/unix/meson.build\nindex cc7d67dd321d..37d07594df29 100644\n--- a/lib/eal/unix/meson.build\n+++ b/lib/eal/unix/meson.build\n@@ -6,6 +6,7 @@ sources += files(\n         'eal_file.c',\n         'eal_filesystem.c',\n         'eal_firmware.c',\n+        'eal_log.c',\n         'eal_unix_memory.c',\n         'eal_unix_thread.c',\n         'eal_unix_timer.c',\ndiff --git a/lib/eal/windows/eal.c b/lib/eal/windows/eal.c\nindex 2d7a0e9ab27e..240d5b8ad3e4 100644\n--- a/lib/eal/windows/eal.c\n+++ b/lib/eal/windows/eal.c\n@@ -96,41 +96,6 @@ eal_usage(const char *prgname)\n \t}\n }\n \n-/* Parse the arguments for --log-level only */\n-static void\n-eal_log_level_parse(int argc, char **argv)\n-{\n-\tint opt;\n-\tchar **argvopt;\n-\tint option_index;\n-\tstruct internal_config *internal_conf =\n-\t\teal_get_internal_configuration();\n-\n-\targvopt = argv;\n-\n-\teal_reset_internal_config(internal_conf);\n-\n-\twhile ((opt = getopt_long(argc, argvopt, eal_short_options,\n-\t\teal_long_options, &option_index)) != EOF) {\n-\n-\t\tint ret;\n-\n-\t\t/* getopt is not happy, stop right now */\n-\t\tif (opt == '?')\n-\t\t\tbreak;\n-\n-\t\tret = (opt == OPT_LOG_LEVEL_NUM) ?\n-\t\t\teal_parse_common_option(opt, optarg,\n-\t\t\t\tinternal_conf) : 0;\n-\n-\t\t/* common parser is not happy */\n-\t\tif (ret < 0)\n-\t\t\tbreak;\n-\t}\n-\n-\toptind = 0; /* reset getopt lib */\n-}\n-\n /* Parse the argument given in the command line of the application */\n static int\n eal_parse_args(int argc, char **argv)\n",
    "prefixes": [
        "v6",
        "1/6"
    ]
}