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 97CB546104; Sat, 25 Jan 2025 03:13:28 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D58884042F; Sat, 25 Jan 2025 03:13:25 +0100 (CET) Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by mails.dpdk.org (Postfix) with ESMTP id 73D02402BD for ; Sat, 25 Jan 2025 03:13:17 +0100 (CET) Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-216401de828so49181065ad.3 for ; Fri, 24 Jan 2025 18:13:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737771196; x=1738375996; 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=wTc+4/fiT5ylpGB78MqREDxyvYZvU4p7Emd6WsPzrMp4OF3OVJh6MHVZJPA9S1s/Yw fSK+dkf3g5PDQb5I1vwz7xLSMJMN5okGfBL+oNSh57NAFEWE2MoslndTKtvlXTnMeZ2U y1E+vAV9skCVJTT1DTDAUY3G0oWseLZ5v6CcY34rG8Qnog2Pb16V31z/L50t2yL5EOeq NHkf2sk30BYhLSauMe3djLv7SyHPU8Z7kg1YbYVWMPjgq9+D5JmsAf33dl9QcOtgGLn+ ZK8MYqMExAotGJrBj47OeosZMg0Qhl4KRwfV5SUGYWruoyfNJ8hJPPkFMy6pbuZTP3BE KWUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737771196; x=1738375996; 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=g9GsBkzUutgGURNhcmckmuggwEiRL8TiIfgpmiPegxsKVGEBj5xPjGfWEIn4qxUrnb mHYf/TwjP6MBhqPAxLC5sIYkT/bA/hyc9+EZSZcFH1bHrewp1wz2k2Xa+Tx3XODLkM3q EsQMk2pKuZD67cIl9mSP4qMmEZI54mXKA0BVx2zQKTykBE062ok6p6M0gDbSqvRAEw9N 1aY8hK8EiLm210mAaS+BaT0HV0RS0UoUQkYnHL9tq7JFxp88oa48zZNxGGJya56T9NSr aHVHpd/DtxGUBXZzP6btJsHSBKUKpV+fg1OZjsHw5XFXdMulPywbrrPoSoc5SlhOJAKP C5yQ== X-Gm-Message-State: AOJu0Yz6LF7NAnQnW5hbJCp8Sn1UKbhMhI4qJ4yzUjuCqg9Lr9Sm5nZ2 iPvZ1kvhAcFVq4gKCx+Fj599t474tv4GEQZW+WktcRB6gLtLY7PShPyobcqW5Ton57vGEEUv/Re u X-Gm-Gg: ASbGnct7D4ov3KZ2+OI2o9gP+b2y6QKNW4AI6ArE1P0/j0TVvD/Oq6slt4qX5MdtBNJ rrNaVVqb09wls0eOzg8DyO4ryfwzLDmeMZDPTWbr8JaTfbqhBsrS2OQA0oGnO23JkBTTHazNCOu 5NLT7I/1XVSHl5aBjHHliiZ7Y9BOLBB0f7jMmDaq0VWm2pfvJJkcHxUMYeEMYORz5wumjh/N0f8 q2CymlIen7I53fk4LN1Ax0ZdZeOPSqz2lo9y1IQ/nJcLaNrJPBnizvqY2VLebpPPGHc1a8XxMn8 mVsWmAaTpv6NmKvlfpLaZNVF1JLV0HbmsZE9obzqE0hQ4z4f/lN6CU5uQg== X-Google-Smtp-Source: AGHT+IG3cVMSMzlXAkfHdm71kUpQ3QGIwJgMsyEpHT1H6TUyzaPN+UeOt4J3ULeXN7DfB5o60bMT/A== X-Received: by 2002:a05:6a20:7816:b0:1e3:da8c:1f3b with SMTP id adf61e73a8af0-1eb2158d04emr39852964637.28.1737771196644; Fri, 24 Jan 2025 18:13:16 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ac48e84e199sm2345256a12.11.2025.01.24.18.13.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jan 2025 18:13:16 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Vladimir Medvedkin Subject: [PATCH v5 02/16] rib: annotate rib allocation functions Date: Fri, 24 Jan 2025 18:11:15 -0800 Message-ID: <20250125021305.76485-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250125021305.76485-1-stephen@networkplumber.org> References: <20250110170603.538756-1-stephen@networkplumber.org> <20250125021305.76485-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