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 113C148A7C for ; Mon, 3 Nov 2025 08:17:41 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E709E40285; Mon, 3 Nov 2025 08:17:40 +0100 (CET) Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) by mails.dpdk.org (Postfix) with ESMTP id 917BE40285 for ; Mon, 3 Nov 2025 08:17:39 +0100 (CET) Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-77f5d497692so5276048b3a.1 for ; Sun, 02 Nov 2025 23:17:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uetpeshawar-edu-pk.20230601.gappssmtp.com; s=20230601; t=1762154258; x=1762759058; darn=dpdk.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=q+OwwaImrwB6S2QesmqfzKRvDY0yhvhcb3q5g7aV4Wo=; b=zof1grmXi6QduIR3ddWVt95EvvUHPSq0f66eW/itH6SpFHKxO0cMKhiDOEW9+fInq0 HicHExOCV13+pRqtYWKsavPkcFY05CFQ+sWJFGDGPB3I4zoMQtUr/S1AoV0mjhSCuwY7 lsfWHtndDIjU76OzXUg03XLS4pm9Iy3nSQrAz/pl0q3KiKn1sOx48KlPVpW5LbHpaIjq Df09G6Oi+j5d8e/zQqvJrOL4I2wDS0rNeA6EgJWFBspmx90e7qbxvv02Jd+MDuJL92xz fZ8N1fKhlkTTqMHFSKug56FnNbzC8JOdriF60U1otXnUgC5T/odPOzPnWh+GvD8iXIGQ wTJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762154258; x=1762759058; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state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z5Tnue/GAOJL0Pz8UKBRskK9 nClmGlyr0elelExy3gbgYU5CnsSIF6GT5po1QK9yCpx X-Google-Smtp-Source: AGHT+IE03jMFau+V6B5xqDispbF8BgzPHCiYOUOB2t/Kn0iOZ27SJNznzp/Gfz/F2hq1uZ87XcsypA== X-Received: by 2002:a17:902:e852:b0:293:33b:a9b0 with SMTP id d9443c01a7336-2951a45a5b9mr134615025ad.32.1762154258351; Sun, 02 Nov 2025 23:17:38 -0800 (PST) Received: from localhost.localdomain (108-92-19-205.lightspeed.sntcca.sbcglobal.net. [108.92.19.205]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-295399cae76sm97060895ad.88.2025.11.02.23.17.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Nov 2025 23:17:38 -0800 (PST) From: Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk> To: stable@dpdk.org Cc: luca.boccassi@gmail.com, Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk>, Stephen Hemminger Subject: [PATCH 22.11] app/testpmd: stop forwarding in secondary process [ upstream commit f96273c8e9d39e472bb07acc05e493b1e712e51b ] Date: Mon, 3 Nov 2025 02:17:17 -0500 Message-ID: <20251103071717.315432-1-14pwcse1224@uetpeshawar.edu.pk> X-Mailer: git-send-email 2.47.3 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 When the secondary process testpmd application running any fwd_engine and after that primary has exited will cause a crash. This patch forces secondary process forwarding lcores in fwd_engine to stop before the primary process exits. Fixes: a550baf24af90f ("app/testpmd: support multi-process") Cc: stable@dpdk.org Signed-off-by: Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk> Signed-off-by: Stephen Hemminger (cherry picked from commit f96273c8e9d39e472bb07acc05e493b1e712e51b) --- app/test-pmd/testpmd.c | 103 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 99 insertions(+), 4 deletions(-) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index a293018341..706e33a2cf 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -3708,6 +3708,83 @@ detach_devargs(char *identifier) rte_devargs_reset(&da); } +#ifndef RTE_EXEC_ENV_WINDOWS + +enum testpmd_req_type { + TESTPMD_REQ_TYPE_EXIT, +}; + +struct testpmd_mp_req { + enum testpmd_req_type t; +}; + +struct testpmd_mp_resp { + int result; +}; + +#define TESTPMD_MP "mp_testpmd" + +/* Send reply to this peer when testpmd exits */ +static const char *primary_name; + +static void +reply_to_primary(const char *peer, int result) +{ + struct rte_mp_msg reply = { }; + struct testpmd_mp_resp *resp = (struct testpmd_mp_resp *) &reply.param; + + strlcpy(reply.name, TESTPMD_MP, RTE_MP_MAX_NAME_LEN); + reply.len_param = sizeof(*resp); + resp->result = result; + + printf("Replying %d to primary\n", result); + fflush(stdout); + + if (rte_mp_reply(&reply, peer) < 0) + printf("Failed to send response to primary:%s", strerror(rte_errno)); +} + +/* Primary process is exiting, stop secondary process */ +static void +pmd_notify_secondary(void) +{ + struct testpmd_mp_req request = { + .t = TESTPMD_REQ_TYPE_EXIT, + }; + struct rte_mp_msg mp_req = { + .name = TESTPMD_MP, + .len_param = sizeof(request), + }; + struct rte_mp_reply reply; + struct timespec ts = {.tv_sec = 5, .tv_nsec = 0}; + + printf("\nPrimary: Sending 'stop_req' request to secondary...\n"); + fflush(stdout); + + memcpy(mp_req.param, &request, sizeof(request)); + rte_mp_request_sync(&mp_req, &reply, &ts); +} + +static int +handle_testpmd_request(const struct rte_mp_msg *request, const void *peer) +{ + const struct testpmd_mp_req *req = (const struct testpmd_mp_req *)request->param; + + if (req->t == TESTPMD_REQ_TYPE_EXIT) { + printf("\nReceived notification of primary exiting\n"); + fflush(stdout); + + /* Response is sent after forwarding loop exits */ + primary_name = peer; + + kill(getpid(), SIGINT); + } else { + reply_to_primary(peer, -EINVAL); + } + return 0; +} +#endif + void pmd_test_exit(void) { @@ -3719,6 +3796,10 @@ pmd_test_exit(void) stop_packet_forwarding(); #ifndef RTE_EXEC_ENV_WINDOWS + /* Tell secondary to exit */ + if (rte_eal_process_type() == RTE_PROC_PRIMARY) + pmd_notify_secondary(); + for (i = 0 ; i < RTE_DIM(mempools) ; i++) { if (mempools[i]) { if (mp_alloc_type == MP_ALLOC_ANON) @@ -4497,9 +4578,12 @@ main(int argc, char** argv) rte_strerror(rte_errno)); #ifndef RTE_EXEC_ENV_WINDOWS - if (rte_eal_process_type() == RTE_PROC_SECONDARY && - enable_primary_monitor() < 0) - rte_exit(EXIT_FAILURE, "Cannot setup primary monitor"); + if (rte_eal_process_type() == RTE_PROC_SECONDARY) { + if (enable_primary_monitor() < 0) + rte_exit(EXIT_FAILURE, "Cannot setup primary monitor"); + if (rte_mp_action_register(TESTPMD_MP, handle_testpmd_request) < 0) + rte_exit(EXIT_FAILURE, "Failed to register message action\n"); + } #endif /* allocate port structures, and init them */ @@ -4700,12 +4784,23 @@ main(int argc, char** argv) } #ifndef RTE_EXEC_ENV_WINDOWS - if (rte_eal_process_type() == RTE_PROC_SECONDARY) + if (rte_eal_process_type() == RTE_PROC_SECONDARY) { disable_primary_monitor(); + rte_mp_action_unregister(TESTPMD_MP); + } #endif pmd_test_exit(); +#ifndef RTE_EXEC_ENV_WINDOWS + if (rte_eal_process_type() == RTE_PROC_SECONDARY) { + const char *peer = primary_name; + primary_name = NULL; + if (peer) + reply_to_primary(peer, 0); + } +#endif + #ifdef RTE_LIB_PDUMP /* uninitialize packet capture framework */ rte_pdump_uninit(); -- 2.47.3