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 02F7D428F8 for ; Sun, 9 Apr 2023 17:34:35 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EDBFE4114A; Sun, 9 Apr 2023 17:34:34 +0200 (CEST) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on2059.outbound.protection.outlook.com [40.107.95.59]) by mails.dpdk.org (Postfix) with ESMTP id 7C47E42BC9 for ; Sun, 9 Apr 2023 17:34:33 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MpAi9eLgJGpbQz5GKMqFH1KWTcUwjOywRyrsBIuxfViXb5yQp+x4N2HrClsJISD3I28h/M/UW5ldQc88qJSczBtH1ITLGqaMVnMyW5bQLZMzLJjf3LP2pRHjJ8wpPW9gS92bSNaQFb+BwXwrOgXd3jufiyABIXXK+B0EP+6cARujkXfQLHlIkiWFV3o6903ufwj0AzGKiuCFTdkQRlIRiuged52mziM92lhTf4niO3FpBIkncZohGad/x3/+8JkJaLt4dMdqDCDJPahNbhsfnzdA5F7jE2lRBrIg8MQvzVLG05miIfP5ixd6EmeDTSV+/YmA50ax5tQ42/1k4NuHMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WK3hCdud6L6DZKNl2Ph44QBOszH1jqNEGCWlXgKiywM=; b=iKK20bYD9hIYMydbjcPuBehWldJs5AkqF/YHW3O+oJdKbx2DXKXj5JSwt7xjNQa99bdtNf7OYd+gK9C2EAUmyA43SFBqJLXC86ulLRf0VFUptAbMeo4vyU+NDKkUHvWKeA/Wk4p8SjaYNaZkHe+i2+0VV6v+1vU6wyPmgmVCuzI+OK5+0qZpMOlLvAhjk/ZahzniaGQZ9YDGyUG+XxOj0J3pvvqT54rrCOJVf/ML7jK7lIbxHXZEYdjGM2DT0+6H0z/++qfio3zloCqqlim5dvqc/5l7zAeBsK8K5D/jxvd7ddOf88VBIb+7D2BpSJPXHxHV1TLC1iN6IPJBwA4+eQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=networkplumber.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WK3hCdud6L6DZKNl2Ph44QBOszH1jqNEGCWlXgKiywM=; b=f/7e/Z46NqiOBy7+uwOTsPaVyzcY/Sp3dEAsn0sgEsGZjf7SY1/pyQXovVFnR/CEOOFKZd4m+JHHyMTbEcbfdeFncCsMT28p4A+R4LkxKONUYHudAJwY+k6IgQpE6mpNz1ygQadH5vW8M8DpUNmWip8LMkNHa+ZIJKEcqRpsm9gxf7+VkPWp6Oyp2syQhS7W4Xgt10Bj79+qoxYKhbCjjKBXUIpdkCpqnw+NH1NhR7CGJMfSZ7DiycqRTd96R74X1a333ZOX9aWm3EHo5r3WrJvtwz+lOeXwY04Zksm+BmX+dcfxfQeGoLF+uFrocqZb0b83qtKV4w6QuQALYu+EIQ== Received: from BN9PR03CA0695.namprd03.prod.outlook.com (2603:10b6:408:ef::10) by MW6PR12MB8836.namprd12.prod.outlook.com (2603:10b6:303:241::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Sun, 9 Apr 2023 15:34:31 +0000 Received: from BN8NAM11FT093.eop-nam11.prod.protection.outlook.com (2603:10b6:408:ef:cafe::81) by BN9PR03CA0695.outlook.office365.com (2603:10b6:408:ef::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38 via Frontend Transport; Sun, 9 Apr 2023 15:34:31 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BN8NAM11FT093.mail.protection.outlook.com (10.13.177.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.20 via Frontend Transport; Sun, 9 Apr 2023 15:34:31 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Sun, 9 Apr 2023 08:34:19 -0700 Received: from nvidia.com (10.126.230.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Sun, 9 Apr 2023 08:34:18 -0700 From: Xueming Li To: Stephen Hemminger CC: Olivier Matz , dpdk stable Subject: patch 'app/testpmd: fix interactive mode on Windows' has been queued to stable release 22.11.2 Date: Sun, 9 Apr 2023 23:24:50 +0800 Message-ID: <20230409152529.5308-103-xuemingl@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230409152529.5308-1-xuemingl@nvidia.com> References: <20230227062349.13764-1-xuemingl@nvidia.com> <20230409152529.5308-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.126.230.37] X-ClientProxiedBy: rnnvmail203.nvidia.com (10.129.68.9) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT093:EE_|MW6PR12MB8836:EE_ X-MS-Office365-Filtering-Correlation-Id: b0e5dfb8-a302-4614-b8c0-08db390fe9ef X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4kmMI/qGtXMibm4WOhmADenSdKNDWAwkSwMHbdKAphiRBOP2qtfbqfrJAhoywLpEfskoHxuSxfvkTw94WcDYCiVbR1svW1om4r1IEJ+boRJqUnEoz6Z2ScoWA5Q2XC6x9cKuySU5ljrnP71+rHx2a9I/mUvbODeDIDHdFzK7QnXibjFrhYX2G/fzScXMZJDERQiH+eLbhuPu2Tmx+PazIbaSwagokZREtoylvVuq+e6nKWFEen8kGIC5zy2sjpeZnb4EENaa7qWjrrezl0fkdxI4ideMefj0AswHUkMFTsDvSjSBpXDE0Mfw3uIQeEBJ1W6VdSVuiSjTmx9epl9gyWSNtFyNzoYUB/uUVzxXN+XOr1eeBkopNBVIqBZfXM22YReGWHagnnpqc4ZHND8kMDOs7RJl3F/FHimoAipXmlSsjqSBuKOOOe38Xwxeg6wT3p9AmO5v6yILRS1BfkEx1qNOIm/8WtZzYeF6YbtQFrUBk/yil1rij1CNgTEfRNLDM+lor09NVMwoKsWWVBieKCunO/GibzyAAmqUqAsUnObbTnOlLbz68DdjJ0wAAyTwJ5hJJDNs/SW+hFb4Lk0B92TBZCFJQB6lzruFjGlaNL4+n78ADSydQKgOFb+mIrZAnWAUzKqYYEriy/5w2WSVDyTR6q2OQpkHMkYJtdk6iICDtNEAAeYSyzXYiwktb4kkh2a/emg01xf/fsS/+1QS6aF5+RTjL0sR3mUY1Dd0kNVypLp8U4k8POVCC+Uom70IEV6QNJD+ClRQMEegnMiDjJ7hrEhdYHx2P4AA7XZd1dVcOMoMxkCc5IGUy2Ane4e+s2Lhs3mNqyzxWGFrlpOLJA== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(346002)(136003)(39860400002)(376002)(396003)(451199021)(46966006)(36840700001)(40470700004)(86362001)(36756003)(316002)(41300700001)(70586007)(8676002)(4326008)(6916009)(966005)(7696005)(70206006)(54906003)(478600001)(40480700001)(55016003)(82310400005)(5660300002)(2906002)(8936002)(36860700001)(82740400003)(356005)(7636003)(16526019)(6286002)(186003)(6666004)(53546011)(1076003)(26005)(336012)(2616005)(426003)(47076005)(83380400001)(40460700003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2023 15:34:31.3120 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b0e5dfb8-a302-4614-b8c0-08db390fe9ef X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT093.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW6PR12MB8836 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 22.11.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 04/11/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://git.dpdk.org/dpdk-stable/log/?h=22.11-staging This queued commit can be viewed at: https://git.dpdk.org/dpdk-stable/log/?h=22.11-staging/commit/7d3df2701dc90f8f3c4e7f249a368ab684f27bf4 Thanks. Xueming Li --- >From 7d3df2701dc90f8f3c4e7f249a368ab684f27bf4 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 Cc: Xueming Li [ 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/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(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index bd31e16e0f..07432f3e57 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -65,6 +65,7 @@ #include "cmdline_tm.h" #include "bpf_cmd.h" +static struct cmdline *testpmd_cl; static cmdline_parse_ctx_t *main_ctx; static TAILQ_HEAD(, testpmd_driver_commands) driver_commands_head = TAILQ_HEAD_INITIALIZER(driver_commands_head); @@ -12916,26 +12917,25 @@ 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; - - 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); } void diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 1b54698bf6..b69b248e47 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -4414,6 +4414,7 @@ static void signal_handler(int signum __rte_unused) { f_quit = 1; + prompt_exit(); } int @@ -4424,8 +4425,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/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) { if (!cl) return; + cmdline_cancel(cl); rdline_quit(&cl->rdl); } diff --git a/lib/cmdline/cmdline_os_unix.c b/lib/cmdline/cmdline_os_unix.c index 64a945a34f..9a4ec4e334 100644 --- a/lib/cmdline/cmdline_os_unix.c +++ b/lib/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/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) 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/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); /* 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.25.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-04-09 21:45:41.369691600 +0800 +++ 0102-app-testpmd-fix-interactive-mode-on-Windows.patch 2023-04-09 21:45:38.729042200 +0800 @@ -1 +1 @@ -From f1d0993e034e39968a2c80a8561b46c260c27487 Mon Sep 17 00:00:00 2001 +From 7d3df2701dc90f8f3c4e7f249a368ab684f27bf4 Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Xueming Li + +[ upstream commit f1d0993e034e39968a2c80a8561b46c260c27487 ] @@ -14 +16,0 @@ -Cc: stable@dpdk.org @@ -28 +30 @@ -index 6fa870dc32..7b20bef4e9 100644 +index bd31e16e0f..07432f3e57 100644 @@ -31 +33 @@ -@@ -66,6 +66,7 @@ +@@ -65,6 +65,7 @@ @@ -39 +41 @@ -@@ -13028,26 +13029,25 @@ cmdline_read_from_file(const char *filename) +@@ -12916,26 +12917,25 @@ cmdline_read_from_file(const char *filename) @@ -79 +81 @@ -index 2ce19ed47a..5cb6f92523 100644 +index 1b54698bf6..b69b248e47 100644 @@ -82 +84 @@ -@@ -4469,6 +4469,7 @@ static void +@@ -4414,6 +4414,7 @@ static void @@ -90 +92 @@ -@@ -4479,8 +4480,18 @@ main(int argc, char** argv) +@@ -4424,8 +4425,18 @@ main(int argc, char** argv)