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 31E8E46130; Fri, 24 Jan 2025 19:17:31 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 87617427AE; Fri, 24 Jan 2025 19:17:22 +0100 (CET) Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by mails.dpdk.org (Postfix) with ESMTP id 0B48540BA4 for ; Fri, 24 Jan 2025 19:17:19 +0100 (CET) Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-2ee67e9287fso4373036a91.0 for ; Fri, 24 Jan 2025 10:17:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737742638; x=1738347438; 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=RW+z7EyI7ZoksgruXkG9PQbcyVUNFBmzE7zmpTm4eo43CovW8Iq0ZPmXtX7sbBr4ZJ pEVq68PGwVigTPZNyZM3s6GsWD48qdWf7XS+AXwe+HqBK6ck4iX6qFgJMiEiVmLTG2sB OFdpqZ5iC9+UcveXznli/VybnjphUMGA+84YvpCWEy5YRf0zKEs7Gr4O3enIqQWKR5DU lDqDbL8F9dA8BcMLMDuy3SAESJpv5+i5mPmCmO3pnyqgbbh6W8zvmSpsa0W9NPlSKaXS KrB+JCFJzcqVr0MkgcRx2uCqvhXh3HpIcIj7CDNqaK5Y4aWKH6InjjQOPWg+WNducLyf EQeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737742638; x=1738347438; 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=SUX5k7dJf3qqXmCLOnGynbjzrcju5rOGAWyTzjPHTnENXKByUFNyncvUJsWMwqHw4c H1ruOJanW0oMcyrwRo+0aibzPJ1YpxYJkNtraNVqpLU0XyG/2BxfW4IBRCKBuK+E3W54 JLhz3rzpMDWcce2BCVvKEyQfVwGDIpphaekOdya2S04waUZB4CQvoen34/DZX+GUNEAG QPLUNmCdhZ+9YLaO3iY4f/fkrSnyvz9RplTCaPggTWVZP19+6A4mgBZsxPsa8SDfnH8a ID7tlC75ygqqk7rLku+dd+eZQ7mM6T5QgtYz1v16ehGXDVV3fywOE4AEvcUACgbyiCCQ biJw== X-Gm-Message-State: AOJu0Yzem0qYa+iyepED+DTZJn4DVxW49Ry2SKW6Ge+k6SJw/DC6z5Ot pxz9ipr4M6hYTh04w5cLuJGQ0DpMkzLDQvkyiQIOBgUbSGpkeHFzG3fWf4JZh5/A1tey7SYAFbc a X-Gm-Gg: ASbGncvrEh2ckI6mAsE5P27rs3p5iNOJdrDFf1skK9GWDBLODHKn6QCyuViquFjm6p/ Zjl4sKwfASS+AFcrIJWPlFP12hK6PiFSrBlXOL7Ihx/UiS95YDxEpDWX3+KYDD+1sGVlj7y+sdl SwQzeF91/4SDvicwyrxI/KAulZYaiuA3JRZ7FCi7IU0R2giUj9z1urhQZDkciFgaaONAZPmjYcl 0w8YqT4DShWRf9sV2Wd/Cu4efMoBys/LfnrivD99xffvAHD5n2bSYEWyFH5MqqIgC30eVcsoKZZ T8wKi4rtZ4KuJW76AY4csTcF9uGx8AQ0h5ITPbYu/5EQ9Gu1Y1v1Zor+auFAJQ/rFMRh X-Google-Smtp-Source: AGHT+IFL+vBhOazYGtThq31vVk2GiGjMwlM9gwK6Nt7ZJriNUOD1h+MAUIAuhWVOmSDvBem7Ptz0pw== X-Received: by 2002:a05:6a00:2a03:b0:725:e499:5b86 with SMTP id d2e1a72fcca58-72dafbb5646mr47497296b3a.20.1737742636785; Fri, 24 Jan 2025 10:17:16 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72f8a6b2ed8sm2184477b3a.41.2025.01.24.10.17.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jan 2025 10:17:16 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Vladimir Medvedkin Subject: [PATCH v4 02/16] rib: annotate rib allocation functions Date: Fri, 24 Jan 2025 10:14:53 -0800 Message-ID: <20250124181704.86567-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250124181704.86567-1-stephen@networkplumber.org> References: <20250110170603.538756-1-stephen@networkplumber.or> <20250124181704.86567-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