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 38C65460EC; Wed, 22 Jan 2025 18:35:56 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1037F4064C; Wed, 22 Jan 2025 18:35:54 +0100 (CET) Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by mails.dpdk.org (Postfix) with ESMTP id BF81140616 for ; Wed, 22 Jan 2025 18:35:51 +0100 (CET) Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-21675fd60feso153916145ad.2 for ; Wed, 22 Jan 2025 09:35:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737567351; x=1738172151; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=F/2Td6ymN4EIDmZG5UrIJkiV/qYh6KN76vLUNkCXvLI=; b=OsXiMBTLR3Bk5amNDgAipilzJMPuYxQCP0aNjNB4GxMMEhCMq91JHO3IJszEEdlgZ0 ImORRgddOK1LqXgSmbfP02oHbTVvyU25hKtLomrTvdB1yI3A8pbEYC4GWiJYpcux57ml yIILmjW27IELYKzFvB7SR5RRr9XMOqWwfqq5I85Dqe8uQpsc4sDw+AsGG6Ty5kg4oC6u YSAMjHMXkBxH5COBvEkk/TlrlOBHa9AGYoYqJ0gzduDyHehyygcOQpe1Gs2j10XkKgpT dFXPpk8QzVY9G3yuSaSQJt7QB9pot6k0ch440gU7arJaFKt9GVMytrYywRXx2Gko/WuU QE/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737567351; x=1738172151; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F/2Td6ymN4EIDmZG5UrIJkiV/qYh6KN76vLUNkCXvLI=; b=l/38I/xU+xk6eKJCP3zby1otPcl0GeweqvSNLM39VDIFLR6hzmtHoVzIMYTMRzPg8K o0B3IX4JreYyAzRMQtlWdB36CeS03+0BfLMWJsu/OKkZUptgmyIVERnLRcaxUU9BITe9 0TKnzDMvmhYknxAcm2/JxYXD+VmFCSwDeiSI4KpCdspqeUuhbH2eI9vYks0kYj/Sy5qz J2hgiKVwj/sD+XBCVNKY/q9Rngms2Ed5OAriaC5sF7MmCon0ijASdfwx0YLmcxurWXqy 7s0S9iqo1cK1uSa0GKSXO8+6hOXkXYRmou4OtUJjclvCYceieUOIEoqz/s47mIY4IRwr 7Beg== X-Gm-Message-State: AOJu0YxrySEIvH0KiX/lNJQDdfeL7WemKvZ3SJViWesDWR9Y/wG63THU P45LfTHsO9k9AEZwC59zn7znOvnuzgi9VOawEpr+t5gREt9FICJR9biX1ewneNTIz9y3MSgCO7T C X-Gm-Gg: ASbGncuFqY/AZFMvEwf2sYvViy/oRlaCIRRhkm1k1G7TqsMNZ+wTfTa6VNhwb+x9y8z 5bdsdikGqyjSGQlKF7zx4PJ2NDfJFZZZQc7pAJAaRsSqXnNRh5te9wBcxdVVkA4tdHijelhO8e7 USWJt2yHp9kFL+2t6v0tN8fHcNsvupT2QeKSTDdagBKAbr8vkc14g6547lfENVMbpXMJ6nkOGH2 s6FlrgxAWuyYfoj2PTK9j8f7Eg4NUmkd1b2YbvWmF+KJoeZShOUOBZnH4XqtPmDC8jvmKEECcAy lwPlohh8LFeNVYIiqzNagg1HCpbxppNDDmK4W3BpsC+Vuyo= X-Google-Smtp-Source: AGHT+IH34fnRLxOhZXJ2BSEp/t4QW72GZInNC5pyUd7l6jROoozH+AIYR+PgvsU6AIs0J1+FOOxJxA== X-Received: by 2002:a17:903:2306:b0:216:4676:dfaf with SMTP id d9443c01a7336-21c355eeb01mr337628675ad.34.1737567350937; Wed, 22 Jan 2025 09:35:50 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21c2d3bc64dsm97469285ad.122.2025.01.22.09.35.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2025 09:35:50 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Vladimir Medvedkin Subject: [PATCH v2 02/15] rib: annotate rib allocation functions Date: Wed, 22 Jan 2025 09:32:46 -0800 Message-ID: <20250122173521.305108-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250122173521.305108-1-stephen@networkplumber.org> References: <20250120180550.198121-1-stephen@networkplumber.org> <20250122173521.305108-1-stephen@networkplumber.org> 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 Add function attributes to catch cases where rib is allocated and not freed correctly. Signed-off-by: Stephen Hemminger --- lib/rib/rte_rib.h | 24 +++++++++++++----------- lib/rib/rte_rib6.h | 24 +++++++++++++----------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/lib/rib/rte_rib.h b/lib/rib/rte_rib.h index 2054d3cebd..f30b85d79a 100644 --- a/lib/rib/rte_rib.h +++ b/lib/rib/rte_rib.h @@ -230,6 +230,17 @@ rte_rib_get_nh(const struct rte_rib_node *node, uint64_t *nh); int rte_rib_set_nh(struct rte_rib_node *node, uint64_t nh); + +/** + * Free an RIB object. + * + * @param rib + * RIB object handle created with rte_rib_create(). + * If rib is NULL, no operation is performed. + */ +void +rte_rib_free(struct rte_rib *rib); + /** * Create RIB * @@ -245,7 +256,8 @@ rte_rib_set_nh(struct rte_rib_node *node, uint64_t nh); */ struct rte_rib * rte_rib_create(const char *name, int socket_id, - const struct rte_rib_conf *conf); + const struct rte_rib_conf *conf) + __rte_malloc __rte_dealloc(rte_rib_free, 1); /** * Find an existing RIB object and return a pointer to it. @@ -259,16 +271,6 @@ rte_rib_create(const char *name, int socket_id, struct rte_rib * rte_rib_find_existing(const char *name); -/** - * Free an RIB object. - * - * @param rib - * RIB object handle created with rte_rib_create(). - * If rib is NULL, no operation is performed. - */ -void -rte_rib_free(struct rte_rib *rib); - #ifdef __cplusplus } #endif diff --git a/lib/rib/rte_rib6.h b/lib/rib/rte_rib6.h index a60756f798..d9514acf82 100644 --- a/lib/rib/rte_rib6.h +++ b/lib/rib/rte_rib6.h @@ -294,6 +294,17 @@ rte_rib6_get_nh(const struct rte_rib6_node *node, uint64_t *nh); int rte_rib6_set_nh(struct rte_rib6_node *node, uint64_t nh); + +/** + * Free an RIB object. + * + * @param rib + * RIB object handle created with rte_rib6_create(). + * If rib is NULL, no operation is performed. + */ +void +rte_rib6_free(struct rte_rib6 *rib); + /** * Create RIB * @@ -309,7 +320,8 @@ rte_rib6_set_nh(struct rte_rib6_node *node, uint64_t nh); */ struct rte_rib6 * rte_rib6_create(const char *name, int socket_id, - const struct rte_rib6_conf *conf); + const struct rte_rib6_conf *conf) + __rte_malloc __rte_dealloc(rte_rib6_free, 1); /** * Find an existing RIB object and return a pointer to it. @@ -323,16 +335,6 @@ rte_rib6_create(const char *name, int socket_id, struct rte_rib6 * rte_rib6_find_existing(const char *name); -/** - * Free an RIB object. - * - * @param rib - * RIB object handle created with rte_rib6_create(). - * If rib is NULL, no operation is performed. - */ -void -rte_rib6_free(struct rte_rib6 *rib); - #ifdef __cplusplus } #endif -- 2.45.2