From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 4C33842800 for ; Wed, 22 Mar 2023 01:42:17 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 47B97410DD; Wed, 22 Mar 2023 01:42:17 +0100 (CET) Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) by mails.dpdk.org (Postfix) with ESMTP id A9D7D427F2 for ; Wed, 22 Mar 2023 01:42:15 +0100 (CET) Received: by mail-wr1-f54.google.com with SMTP id h17so15415418wrt.8 for ; Tue, 21 Mar 2023 17:42:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679445735; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4Y6Ux4KbAG+nLqW+NbSksZmA2xLwOWdXzgfIkglLuQg=; b=lCRvfQ3oPQDHvD0+lcBRb1fD6RmwgkNyhHHUfn/MWEZcP661bNg4xaeF75u6Vz1slW en8L/nVGb7dX2HEmPjgRBEo43YM5pM+Csx/p8oIs8lVS+XFd7mdZEYL4aePieVT4XXgt u/APhJl6GrrNZVhiHcMRvjnhbf4lVB3d78bBfCRjcYFYyj6yCU7ktkIG9OACHS+3Uf/r S/CBS2CyE++KpfobOOEHDeD48TXO340NTQC9+zL+h+FtaRSO9bhWJdUP6tlrQKYc0FKQ NSMOcE4R9ppzr/P+F7DuB0CWSc0ZqyVWCXtaGulDedy8aaDv3EQoKXvcRPueelqs9ZL2 BF0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679445735; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4Y6Ux4KbAG+nLqW+NbSksZmA2xLwOWdXzgfIkglLuQg=; b=TD3BJoLUA39Skp0Se8BOsh2cu3bzjeNF01LXBhldAr0U3jeCSLpFkkPmer8qpYHmqf 0rColxMh+ScCiCZTqhqHUl6p4CdHh9M69rZ6m7YSARR7lNMyg7XX4hiT/m4h/LIKdueY zE12fH/JaRKgzMnhnZCBmZ0HXaet4vZFL9z0+VXjQ60XJ8OWT3VppPO8YvVONlgt/LVO wYrVzMhEicBQbvC93OrgqNnJa7yDfeq9QtHpDWc+s7y1tOR2w8iv3oWP4UWSUYlkK35v eIbKrzSLuS7TLSsDVCdlcYaaBV06+jtmTF8eABcUknGYNMNDV+kYimyaPJ2BddMFEjOj 90BA== X-Gm-Message-State: AO0yUKUnRD0dZFrODzCu4XiDzpwnhTq+XBjV1iYOn0K7vryYzCMvQRzV nIXpac+2qaopltZF0v3Q04M= X-Google-Smtp-Source: AK7set9K4mvK4hw54/E2/B3WsaS4dr7JCLneXRrhBRkhFKqjize4kQEibVxVn7Pq5tT/07EveoZ4gA== X-Received: by 2002:a5d:470c:0:b0:2cf:e6de:c6ab with SMTP id y12-20020a5d470c000000b002cfe6dec6abmr3866775wrq.11.1679445735150; Tue, 21 Mar 2023 17:42:15 -0700 (PDT) Received: from localhost ([2a01:4b00:d307:1000:f1d3:eb5e:11f4:a7d9]) by smtp.gmail.com with ESMTPSA id k2-20020a5d6e82000000b002c55b0e6ef1sm12686577wrz.4.2023.03.21.17.42.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Mar 2023 17:42:14 -0700 (PDT) From: luca.boccassi@gmail.com To: Stephen Hemminger Cc: Olivier Matz , dpdk stable Subject: patch 'app/testpmd: fix interactive mode on Windows' has been queued to stable release 20.11.8 Date: Wed, 22 Mar 2023 00:41:43 +0000 Message-Id: <20230322004155.2333903-7-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230322004155.2333903-1-luca.boccassi@gmail.com> References: <20230315224631.1025649-39-luca.boccassi@gmail.com> <20230322004155.2333903-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 20.11.8 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 03/23/23. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/4451959edc6959c1bfbac4f1aa8195eacdcae649 Thanks. Luca Boccassi --- >From 4451959edc6959c1bfbac4f1aa8195eacdcae649 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Fri, 17 Mar 2023 09:59:41 -0700 Subject: [PATCH] app/testpmd: fix interactive mode on Windows [ upstream commit f1d0993e034e39968a2c80a8561b46c260c27487 ] The cmdline_poll() function is broken and was not fully tested, go back to using cmdline_interact(). Instead, use sigaction() to cancel read character on Unix OS's and a new helper to cancel I/O on Windows. Bugzilla ID: 1180 Fixes: 0fd1386c30c3 ("app/testpmd: cleanup cleanly from signal") Signed-off-by: Stephen Hemminger Acked-by: Olivier Matz --- app/test-pmd/cmdline.c | 26 ++++++++++++------------- app/test-pmd/testpmd.c | 11 +++++++++++ lib/librte_cmdline/cmdline.c | 1 + lib/librte_cmdline/cmdline_os_unix.c | 6 ++++++ lib/librte_cmdline/cmdline_os_windows.c | 14 +++++++++++++ lib/librte_cmdline/cmdline_private.h | 3 +++ 6 files changed, 48 insertions(+), 13 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 8a7300bcf9..422db4f6bc 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -72,6 +72,7 @@ #include "bpf_cmd.h" static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue); +static struct cmdline *testpmd_cl; /* *** Help command with introduction. *** */ struct cmd_help_brief_result { @@ -17193,29 +17194,28 @@ cmdline_read_from_file(const char *filename) printf("Read CLI commands from %s\n", filename); } +void +prompt_exit(void) +{ + cmdline_quit(testpmd_cl); +} + /* prompt function, called from main on MAIN lcore */ void prompt(void) { - struct cmdline *cl; - /* initialize non-constant commands */ cmd_set_fwd_mode_init(); cmd_set_fwd_retry_mode_init(); - cl = cmdline_stdin_new(main_ctx, "testpmd> "); - if (cl == NULL) + testpmd_cl = cmdline_stdin_new(main_ctx, "testpmd> "); + if (testpmd_cl == NULL) { + fprintf(stderr, + "Failed to create stdin based cmdline context\n"); return; - - /* loop until signal or quit command */ - while (f_quit == 0 && cl_quit == 0) { - int status = cmdline_poll(cl); - - if (status < 0 || status == RDLINE_EXITED) - break; } - cmdline_quit(cl); - cmdline_stdin_exit(cl); + cmdline_interact(testpmd_cl); + cmdline_stdin_exit(testpmd_cl); } static void diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index a061e10385..568b9f7390 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -3848,6 +3848,7 @@ static void signal_handler(int signum __rte_unused) { f_quit = 1; + prompt_exit(); } int @@ -3858,8 +3859,18 @@ main(int argc, char** argv) uint16_t count; int ret; +#ifdef RTE_EXEC_ENV_WINDOWS signal(SIGINT, signal_handler); signal(SIGTERM, signal_handler); +#else + /* Want read() not to be restarted on signal */ + struct sigaction action = { + .sa_handler = signal_handler, + }; + + sigaction(SIGINT, &action, NULL); + sigaction(SIGTERM, &action, NULL); +#endif testpmd_logtype = rte_log_register("testpmd"); if (testpmd_logtype < 0) diff --git a/lib/librte_cmdline/cmdline.c b/lib/librte_cmdline/cmdline.c index 478bcfb161..713e39d9c3 100644 --- a/lib/librte_cmdline/cmdline.c +++ b/lib/librte_cmdline/cmdline.c @@ -181,6 +181,7 @@ cmdline_quit(struct cmdline *cl) { if (!cl) return; + cmdline_cancel(cl); rdline_quit(&cl->rdl); } diff --git a/lib/librte_cmdline/cmdline_os_unix.c b/lib/librte_cmdline/cmdline_os_unix.c index 64a945a34f..9a4ec4e334 100644 --- a/lib/librte_cmdline/cmdline_os_unix.c +++ b/lib/librte_cmdline/cmdline_os_unix.c @@ -51,3 +51,9 @@ cmdline_vdprintf(int fd, const char *format, va_list op) { return vdprintf(fd, format, op); } + +/* This function is not needed on Linux, instead use sigaction() */ +void +cmdline_cancel(__rte_unused struct cmdline *cl) +{ +} diff --git a/lib/librte_cmdline/cmdline_os_windows.c b/lib/librte_cmdline/cmdline_os_windows.c index e9585c9eea..80b2cbec98 100644 --- a/lib/librte_cmdline/cmdline_os_windows.c +++ b/lib/librte_cmdline/cmdline_os_windows.c @@ -205,3 +205,17 @@ cmdline_vdprintf(int fd, const char *format, va_list op) return ret; } + +void +cmdline_cancel(struct cmdline *cl) +{ + if (!cl) + return; + + /* force the outstanding read on console to exit */ + if (cl->oldterm.is_console_input) { + HANDLE handle = (HANDLE)_get_osfhandle(cl->s_in); + + CancelIoEx(handle, NULL); + } +} diff --git a/lib/librte_cmdline/cmdline_private.h b/lib/librte_cmdline/cmdline_private.h index a8a6ee9e69..1951286533 100644 --- a/lib/librte_cmdline/cmdline_private.h +++ b/lib/librte_cmdline/cmdline_private.h @@ -46,6 +46,9 @@ int cmdline_poll_char(struct cmdline *cl); /* Read one character from input. */ ssize_t cmdline_read_char(struct cmdline *cl, char *c); +/* Force current cmdline read to unblock. */ +void cmdline_cancel(struct cmdline *cl); + /* vdprintf(3) */ __rte_format_printf(2, 0) int cmdline_vdprintf(int fd, const char *format, va_list op); -- 2.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-03-21 21:56:37.339601531 +0000 +++ 0007-app-testpmd-fix-interactive-mode-on-Windows.patch 2023-03-21 21:56:37.056806715 +0000 @@ -1 +1 @@ -From f1d0993e034e39968a2c80a8561b46c260c27487 Mon Sep 17 00:00:00 2001 +From 4451959edc6959c1bfbac4f1aa8195eacdcae649 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit f1d0993e034e39968a2c80a8561b46c260c27487 ] + @@ -14 +15,0 @@ -Cc: stable@dpdk.org @@ -19,7 +20,7 @@ - app/test-pmd/cmdline.c | 26 +++++++++++++------------- - app/test-pmd/testpmd.c | 11 +++++++++++ - lib/cmdline/cmdline.c | 1 + - lib/cmdline/cmdline_os_unix.c | 6 ++++++ - lib/cmdline/cmdline_os_windows.c | 14 ++++++++++++++ - lib/cmdline/cmdline_private.h | 5 ++++- - 6 files changed, 49 insertions(+), 14 deletions(-) + app/test-pmd/cmdline.c | 26 ++++++++++++------------- + app/test-pmd/testpmd.c | 11 +++++++++++ + lib/librte_cmdline/cmdline.c | 1 + + lib/librte_cmdline/cmdline_os_unix.c | 6 ++++++ + lib/librte_cmdline/cmdline_os_windows.c | 14 +++++++++++++ + lib/librte_cmdline/cmdline_private.h | 3 +++ + 6 files changed, 48 insertions(+), 13 deletions(-) @@ -28 +29 @@ -index 6fa870dc32..7b20bef4e9 100644 +index 8a7300bcf9..422db4f6bc 100644 @@ -31,2 +32 @@ -@@ -66,6 +66,7 @@ - #include "cmdline_tm.h" +@@ -72,6 +72,7 @@ @@ -34,0 +35 @@ + static void cmd_reconfig_device_queue(portid_t id, uint8_t dev, uint8_t queue); @@ -36,4 +37,4 @@ - static cmdline_parse_ctx_t *main_ctx; - static TAILQ_HEAD(, testpmd_driver_commands) driver_commands_head = - TAILQ_HEAD_INITIALIZER(driver_commands_head); -@@ -13028,26 +13029,25 @@ cmdline_read_from_file(const char *filename) + + /* *** Help command with introduction. *** */ + struct cmd_help_brief_result { +@@ -17193,29 +17194,28 @@ cmdline_read_from_file(const char *filename) @@ -54 +55,4 @@ -- +- /* initialize non-constant commands */ + cmd_set_fwd_mode_init(); + cmd_set_fwd_retry_mode_init(); + @@ -77 +81 @@ - void + static void @@ -79 +83 @@ -index 2ce19ed47a..5cb6f92523 100644 +index a061e10385..568b9f7390 100644 @@ -82 +86 @@ -@@ -4469,6 +4469,7 @@ static void +@@ -3848,6 +3848,7 @@ static void @@ -90 +94 @@ -@@ -4479,8 +4480,18 @@ main(int argc, char** argv) +@@ -3858,8 +3859,18 @@ main(int argc, char** argv) @@ -109,5 +113,5 @@ -diff --git a/lib/cmdline/cmdline.c b/lib/cmdline/cmdline.c -index 8ad0690d85..355c7d8ca6 100644 ---- a/lib/cmdline/cmdline.c -+++ b/lib/cmdline/cmdline.c -@@ -173,6 +173,7 @@ cmdline_quit(struct cmdline *cl) +diff --git a/lib/librte_cmdline/cmdline.c b/lib/librte_cmdline/cmdline.c +index 478bcfb161..713e39d9c3 100644 +--- a/lib/librte_cmdline/cmdline.c ++++ b/lib/librte_cmdline/cmdline.c +@@ -181,6 +181,7 @@ cmdline_quit(struct cmdline *cl) @@ -121 +125 @@ -diff --git a/lib/cmdline/cmdline_os_unix.c b/lib/cmdline/cmdline_os_unix.c +diff --git a/lib/librte_cmdline/cmdline_os_unix.c b/lib/librte_cmdline/cmdline_os_unix.c @@ -123,2 +127,2 @@ ---- a/lib/cmdline/cmdline_os_unix.c -+++ b/lib/cmdline/cmdline_os_unix.c +--- a/lib/librte_cmdline/cmdline_os_unix.c ++++ b/lib/librte_cmdline/cmdline_os_unix.c @@ -135,5 +139,5 @@ -diff --git a/lib/cmdline/cmdline_os_windows.c b/lib/cmdline/cmdline_os_windows.c -index 73ed9ba290..80863bfc8a 100644 ---- a/lib/cmdline/cmdline_os_windows.c -+++ b/lib/cmdline/cmdline_os_windows.c -@@ -203,3 +203,17 @@ cmdline_vdprintf(int fd, const char *format, va_list op) +diff --git a/lib/librte_cmdline/cmdline_os_windows.c b/lib/librte_cmdline/cmdline_os_windows.c +index e9585c9eea..80b2cbec98 100644 +--- a/lib/librte_cmdline/cmdline_os_windows.c ++++ b/lib/librte_cmdline/cmdline_os_windows.c +@@ -205,3 +205,17 @@ cmdline_vdprintf(int fd, const char *format, va_list op) @@ -157,14 +161,5 @@ -diff --git a/lib/cmdline/cmdline_private.h b/lib/cmdline/cmdline_private.h -index a3271c7693..86a46cdea6 100644 ---- a/lib/cmdline/cmdline_private.h -+++ b/lib/cmdline/cmdline_private.h -@@ -24,7 +24,7 @@ - #define RDLINE_HISTORY_MAX_LINE 64 - - struct rdline { -- enum rdline_status status; -+ volatile enum rdline_status status; - /* rdline bufs */ - struct cirbuf left; - struct cirbuf right; -@@ -90,6 +90,9 @@ int cmdline_poll_char(struct cmdline *cl); +diff --git a/lib/librte_cmdline/cmdline_private.h b/lib/librte_cmdline/cmdline_private.h +index a8a6ee9e69..1951286533 100644 +--- a/lib/librte_cmdline/cmdline_private.h ++++ b/lib/librte_cmdline/cmdline_private.h +@@ -46,6 +46,9 @@ int cmdline_poll_char(struct cmdline *cl);