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 EE5AFA04FD; Fri, 25 Mar 2022 09:40:53 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DCF3340687; Fri, 25 Mar 2022 09:40:53 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mails.dpdk.org (Postfix) with ESMTP id 8A98240140 for ; Fri, 25 Mar 2022 09:40:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648197652; x=1679733652; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=admQlHnTUBLmcCuxi0Lrxu2KKma+pjHBe2JBbfqc1l8=; b=PtqEbKB+u9vRhlsuxW8jObIm3huplq/k4/IwWWuwxXvMZiycoj9u/uh7 mU6+U8H3yZtf4wphCPgCtl/opxjyzaNBF1bonTsltaVuNH2GvcP9F5GWq 8Inwu8VfuKarxiKHY0nEyttH9GG1CJltEoqFXGHD7RpuNtUKyokeXAkub MM0WVA2E4dzEq3b/lWxktp8twtTtsHPg/0ElzM+stF2hyNzmmUU9D7ieO vgxQ5+dYtnWY+TZxDr/O13XWUHcBLWQJGSd4Mau8VAgsSeVEgLnstbBAS iMlilLGalLCRk0kJEPXTIBid5234fUXudsn9sTNSPXj6cgX6XSG7Jinvy w==; X-IronPort-AV: E=McAfee;i="6200,9189,10296"; a="240744406" X-IronPort-AV: E=Sophos;i="5.90,209,1643702400"; d="scan'208";a="240744406" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2022 01:40:51 -0700 X-IronPort-AV: E=Sophos;i="5.90,209,1643702400"; d="scan'208";a="520128417" Received: from unknown (HELO localhost.localdomain) ([10.239.251.104]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2022 01:40:48 -0700 From: Ke Zhang To: xiaoyun.li@intel.com, aman.deep.singh@intel.com, yuying.zhang@intel.com, dev@dpdk.org Cc: Ke Zhang Subject: [PATCH v3] app/testpmd: fix issue with memory leaks when quit testpmd Date: Fri, 25 Mar 2022 08:35:55 +0000 Message-Id: <20220325083555.422962-1-ke1x.zhang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220314055252.392004-1-ke1x.zhang@intel.com> References: <20220314055252.392004-1-ke1x.zhang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org A multicast address pool is allocated for a port when using mcast_addr testpmd commands. When closing a port or stopping testpmd, this pool was not freed, resulting in a leak.This issue has been caught using ASan. Free this pool when closing the port. Error info as following: ERROR: LeakSanitizer: detected memory leaksDirect leak of 192 byte(s) 0 0x7f6a2e0aeffe in __interceptor_realloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dffe) 1 0x565361eb340f in mcast_addr_pool_extend ../app/test-pmd/config.c:5162 2 0x565361eb3556 in mcast_addr_pool_append ../app/test-pmd/config.c:5180 3 0x565361eb3aae in mcast_addr_add ../app/test-pmd/config.c:5243 Signed-off-by: Ke Zhang --- app/test-pmd/config.c | 19 +++++++++++++++++++ app/test-pmd/testpmd.c | 1 + app/test-pmd/testpmd.h | 1 + 3 files changed, 21 insertions(+) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index cc8e7aa138..a6fa9be3ef 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -5978,6 +5978,25 @@ mcast_addr_pool_remove(struct rte_port *port, uint32_t addr_idx) sizeof(struct rte_ether_addr) * (port->mc_addr_nb - addr_idx)); } +int +mcast_addr_pool_destroy(portid_t port_id) +{ + struct rte_port *port; + + if (port_id_is_invalid(port_id, ENABLED_WARN) || + port_id == (portid_t)RTE_PORT_ALL) + return -EINVAL; + port = &ports[port_id]; + + if (port->mc_addr_nb != 0) { + /* free the pool of multicast addresses. */ + free(port->mc_addr_pool); + port->mc_addr_pool = NULL; + port->mc_addr_nb = 0; + } + return 0; +} + static int eth_port_multicast_addr_list_set(portid_t port_id) { diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index fe2ce19f99..1861a02c2f 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -3137,6 +3137,7 @@ close_port(portid_t pid) } if (is_proc_primary()) { + mcast_addr_pool_destroy(pi); port_flow_flush(pi); port_flex_item_flush(pi); rte_eth_dev_close(pi); diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 31f766c965..daa3c08317 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -965,6 +965,7 @@ int port_flow_create(portid_t port_id, int port_action_handle_query(portid_t port_id, uint32_t id); void update_age_action_context(const struct rte_flow_action *actions, struct port_flow *pf); +int mcast_addr_pool_destroy(portid_t port_id); int port_flow_destroy(portid_t port_id, uint32_t n, const uint32_t *rule); int port_flow_flush(portid_t port_id); int port_flow_dump(portid_t port_id, bool dump_all, -- 2.25.1