patch 'app/testpmd: fix interactive mode on Windows' has been queued to stable release 20.11.8
luca.boccassi at gmail.com
luca.boccassi at gmail.com
Wed Mar 22 01:41:43 CET 2023
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 <stephen at networkplumber.org>
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 <stephen at networkplumber.org>
Acked-by: Olivier Matz <olivier.matz at 6wind.com>
---
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 at 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);
More information about the stable
mailing list