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 1B0DE48A25 for ; Wed, 29 Oct 2025 12:38:34 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E11F540288; Wed, 29 Oct 2025 12:38:33 +0100 (CET) Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by mails.dpdk.org (Postfix) with ESMTP id 3E0C340288 for ; Wed, 29 Oct 2025 12:38:32 +0100 (CET) Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-b6cf07258e3so5160370a12.0 for ; Wed, 29 Oct 2025 04:38:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uetpeshawar-edu-pk.20230601.gappssmtp.com; s=20230601; t=1761737911; x=1762342711; 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=fhwte9hpTOCcMNBjeP0vgxirc7+WM67smA+pYrDm54g=; b=E2S2pOx/f+NVnBJ4wOUz3vuiAZUILWZF2MADwiZhux70WFpkNuVOLRSQpEygAgAuVH zrwwbL/wYYHXK2WWYJWkISpkPk9+4NYEG/uToOmZe+eSmG2dZP8cE36XyetV69JCjXZY Qnqsa9YldW4/I9jyiNAH+eeeh1bffZZw8V7CEXYrA9MwJA3qzukf33GcjD06yyLoN6pQ +scGDlNq7Sla+aXYZYrZOnoQLo8LHHCitS5sZ+ESqVAoZnW+v3bi1hxMTy7Q9dQdpq8h GNVgo0LJaVoG2m5WZGZKTzVV90ZtGZAbUG9im2K4S1uOcUazDS7L35TE0XE5WizsokKM x80g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761737911; x=1762342711; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=fhwte9hpTOCcMNBjeP0vgxirc7+WM67smA+pYrDm54g=; b=kW8sIpOFc2bjfpiH7o1Hw1TdHw0PIJJMyDL4O6g89ds/sU9JlM0j1IwjbzK9oqg8H9 d3yRPR5Ysp8qVEOlmD4JUKmoXOhZk0773BL76R78kaKvjMlxNecnm81XbXipBq/WWZeM E5dAEVzemUeLHz5OuZhfOJLQ61ELAoNmMLrsAdKTdAtLSbipAtktzYSJPbbkTNhbI8T4 0aO23Lv/yPlJINj/W/Nzb6QcBqw7Ualz8lU4ykdvZOBWv/SY1shTIPHKa7/2r9I2USYT +rhBDCtoM9Dx2/GPfiiU0JhMzwDvTIus+L5F30cK0gmcJzNIswnuyyVpa8cGuODjJT8D SkwA== X-Gm-Message-State: AOJu0Yz4HjK66J0+dRBtbkiI8WOYUeClPdCXfOnQsqmfY2orbAAbTQY4 Xrtx+GGk1g8/dk9NezMK4h7AFUddGH7qZf1nOyROiazMCs52WWGjU0Wrt2na26rbgD2A83p+uis PS8zJCn4= X-Gm-Gg: ASbGncs/pKsDVSMhxGII2AB06wyaL4sZVBZTOp16QqvZmu/mhr4oxp5sjuuhoIlHRKC mlUsnpHOprfhSs8kOZFzq+nJNbRbhtTJ42j5zrUT0QyU1AYGbRq8frYbRRabsCuOS6GrYBU7Lab iIAL5qBnblvw6ZA2jlBbm9uj60fJJ4OgNQEaC4rYIEBoowM+XFH/z+3JzIUu9X2XlnP8+cXKXYc yQK4EC9Uzel/bcr/TgdrdnIgBq8+uFR9BfoaaMEMqjc9lh9wRGNcaoVUUbD9uNsLjAwlGYTDELV w2zapxJ2kyPGhTwiJzVt4X34EPYyG9QqePS6m79Hs+Y67BxfinJAyKPLinSGCV7swX7hgIAD00H QivI0ZuKHsDaPUD1MFaeu9HJDrOcBddOtIEW6n1xMB5JuVrgM0jJlwBxkTARff2nkW37Vj6u8wM 4tcR1+pJgscP+btL72CkhrfXAU9az/6GquCMnI31howB9tg2HWz1SQvclpOU4ifzTMpFAGDb4AY rsVY4HGZoFf7wX3ak9VUOYaKq/4SxHE3lSBWRyOnTOsQ+gpkrCpiBV45QfzDg7lEx3sfPic37ee HzAoZVskZEmUD28xs4xyx54Sb6Mbvlyd4EFZ9WWmwSEm X-Google-Smtp-Source: AGHT+IHEv3O5iWBAuevo92mwgFBFMo1mjStA5QWt35kQz+fJrOHcaMb5K8kw9NKMtL4llZ+vlUbq1A== X-Received: by 2002:a17:902:e78f:b0:27e:ec72:f62 with SMTP id d9443c01a7336-294dee52d1bmr37001355ad.6.1761737910829; Wed, 29 Oct 2025 04:38:30 -0700 (PDT) Received: from localhost.localdomain (108-92-19-205.lightspeed.sntcca.sbcglobal.net. [108.92.19.205]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29498d44db4sm151585355ad.86.2025.10.29.04.38.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Oct 2025 04:38:30 -0700 (PDT) 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: Wed, 29 Oct 2025 07:38:07 -0400 Message-ID: <20251029113807.256638-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..84d9f7a8bf 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 RTE_ATOMIC(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 */ + rte_atomic_store_explicit(&primary_name, peer, rte_memory_order_relaxed); + + 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 = rte_atomic_exchange_explicit(&primary_name, NULL, + rte_memory_order_relaxed); + if (peer) + reply_to_primary(peer, 0); + } +#endif + #ifdef RTE_LIB_PDUMP /* uninitialize packet capture framework */ rte_pdump_uninit(); -- 2.47.3