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 1848046114; Sat, 25 Jan 2025 19:40:35 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 80EA24042E; Sat, 25 Jan 2025 19:40:26 +0100 (CET) Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) by mails.dpdk.org (Postfix) with ESMTP id 58410402B7 for ; Sat, 25 Jan 2025 19:40:23 +0100 (CET) Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2162c0f6a39so77712945ad.0 for ; Sat, 25 Jan 2025 10:40:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737830422; x=1738435222; 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=roJuDWIjAWnUqQL2MTeOrQedF7lP2LgwXPaigSxFmTw=; b=KiR5hkwaEeG9SuIt+AQLMn5ba/xnE/C4P1a5l/9Y+iP4C30FM2kbEsTidOkldG6epN BojzdNQ2vy5SSqinelkaRZsprHJE0e/oNTky25dKssE3O0q1B8p6zUIwRW4azqauxUX2 uX9k/+DU7tsUMMc5rJQn9sPQ64UYEVQzYJRlXxcJKlLdQ7GqLv5yWSQag6iCDRPxs1n6 n2rHMeaI5JptQdqG+kBfIgTvsNg90X50TBFN3dqO3K11nM6fxKGVzmcrZy1fY2zgOfHE f2OUSbV9lDKVm3N+Lx39Nk501yuQGx1xGUr2VmLs4Oaf3SHoouKRnoWEYUYgrs+MgT57 qjlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737830422; x=1738435222; 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=roJuDWIjAWnUqQL2MTeOrQedF7lP2LgwXPaigSxFmTw=; b=AKYvaK3sEwwt8jhrNRquZGsxiwhXka8Cvtmj+MKuGowh9dr59BOZP8HNcHvNtx2DRU gJpICgzOnELMJAZf7d7qC5uUF0C7tT+nPCJd/rAgVDZ7lebMSjawylOwrsfoORdh3jBC PiCB4B4KjZ+qtts9CNJlXSUl97JdS/uPT+uCwgLWerY6KhjG2nXtkpdsKIwH5Pv4fFjI mqKkxKRmOiF958BMH6MAPuVIiBoDz9F0UgP0eNQj1cIZw/xJf2+iFSAnD1p9zJ0Wa5h1 YgMb2OLRuetbyS2xxUe8swHggdQ8hw/R1Mhk0RfmRTZZG8J5ABhA8STPqx/4W5gEkaAV WHjQ== X-Gm-Message-State: AOJu0Yy0j16+u5uA6XGxqid6yrcPqT3WX/uYJ0LIpY6yFX668VeCxNZe pfqo5+jCOuXfS/v3f2ihW1rRFmlzGgp7h/gTgb8jcknpaW4+jhG7UmUfz5VvqicJG5GojjE1s34 Q X-Gm-Gg: ASbGncvQL8B+VlUCt/GUvIUM+/DfJfBr0Gu5ZRllVoZSVVL5duQjDsBxQb5bNCcRJZn F0ETMI6AUU1MRWqkvO+myIK+EhjcGgYbT2SGfe6L2qdX9Qh9raHC4OAGzWLq+HGjsNqpUOoYiay 6YV4WUpWcEXoDt2ZSFmeUG9iI7MR3A/Lr5df+4P8GTARKnndLVcQ2phMb4cP4s6yE5lL0DEqcXX FIzhDfjRjzMJBNfOr4ma6ds46In+wCkpLJpkwlbapg4UmrRpJSWulqMPfFQndd8Y0ZfRtVAbcis Am4hFkCMwZo1nU2rbjanDCFHr/d7pjklSWkHltrYN1udlrNtWIZQ8SdKrw== X-Google-Smtp-Source: AGHT+IEzsiYawNrJQQVpu6sMJZxCpDvsOhu1wkZjCPrGS8hHUdC1FYFiOrJaE/dLDxJEDIVRPXS1og== X-Received: by 2002:a05:6a20:6706:b0:1eb:4be3:c437 with SMTP id adf61e73a8af0-1eb6977de28mr13828366637.14.1737830422435; Sat, 25 Jan 2025 10:40:22 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72f8a7614f4sm4100547b3a.97.2025.01.25.10.40.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Jan 2025 10:40:22 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v6 02/15] rib: annotate rib allocation functions Date: Sat, 25 Jan 2025 10:36:36 -0800 Message-ID: <20250125184010.782330-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250125184010.782330-1-stephen@networkplumber.org> References: <20250120180550.198121-1-stephen@networkplumber.org> <20250125184010.782330-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 | 26 +++++++++++++++----------- lib/rib/rte_rib6.h | 24 +++++++++++++----------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/lib/rib/rte_rib.h b/lib/rib/rte_rib.h index 2054d3cebd..3fcb702eab 100644 --- a/lib/rib/rte_rib.h +++ b/lib/rib/rte_rib.h @@ -17,6 +17,8 @@ #include #include +#include + #ifdef __cplusplus extern "C" { @@ -230,6 +232,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 +258,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 +273,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