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 A4CEA46104; Sat, 25 Jan 2025 03:13:22 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6F114402E2; Sat, 25 Jan 2025 03:13:18 +0100 (CET) Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by mails.dpdk.org (Postfix) with ESMTP id AC720402B5 for ; Sat, 25 Jan 2025 03:13:16 +0100 (CET) Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-2f42992f608so4031691a91.0 for ; Fri, 24 Jan 2025 18:13:16 -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=9UWIpUmA7BaG4xjWsP3UBGz9fjV+tBn2Ua5MOChAiVc=; b=Xl93SDmuEYYCezdgtD3qstkzLSMF5T90f5pYi9Omfe9UEqmVM4rNUQorWIcLE7hqVU 2BKx0AyCEUF5hMIJRs9vHBDs/yQ7MAohO/ajETXSlRApGDfKDDCYpmy/MNcFgGLH6hfV FqRare6/K4qP9N8S+pDbztBp8bl2Pk4kRH8pDC5qstDUlKj9zvu8J0gejhcd6+2J/Cum eLfdJ0y307vmmHA9uO6Cjp/XTpHrvBf/I8ZDJHtMfQSIINXoRW1m+4OFmEDTCNdWGFI4 GVA44A58WJCXhoCOcUHx8M9VY+MAbgMrY0gZhNeeZcIxtC+MQli5EhGI4ZbC0df9Jfzw THQQ== 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=9UWIpUmA7BaG4xjWsP3UBGz9fjV+tBn2Ua5MOChAiVc=; b=CJbloOiu56wd8AaTyfs4zFER+7ItA+7W96vf4/Uon2Z529zitEk9lXT0ck7+/llvE+ JDxYmgWyCHvEKfqMMuizhF0AkIxOzD49/9EbyE8KoUCu6Qf5EIfpHEqjOg0X5I8Ah7bg 7HwMzrBLW9aR1dT4mLLLWUmah6XYeCojWrks3yW80w+HPcjigyoO5nHEYP4z8+s+iSpV ZgyHTEuQ4GHYWSGLLqknX9QDkGTeBQjWaz3xgg8f51f58JPSS2PjUV5teoTbi0h/j25b ffGFF814zX260fpOODNiuCdOLDmkYVLafRQhIcefGAksyYDGKwyzD6m5w9p4nc2LCZPP j6AA== X-Gm-Message-State: AOJu0Yz4+90i3wuUmSJg3rDkJwo9SP9mYFVfftKnpzlIlaSb17UMSyDx J2Apl5NwtLRk5RTBIoW4n5KbJkIVJZNivCWcx4tJATUAr59bsd7xDFrXjQ1PBNCWYU6OnXIanqV o X-Gm-Gg: ASbGncs0NkodttR6B1dcLvMRCUQd29tchdqCETCl/3Gm+58xbT9GyT5Nn5TB0mEvZAo B3MFI1oGKkfpppSJA8PHU+QUqc0VzCC5qycTp8UfC6i/Qsh2SEQzY5r2cpsdjWYwrJs709ICbxO isus0yT33tZni94znhXyZtAHKQEAa5SsFQj8CE4Fj3UoSct5lGgaz/t4xEkoBKlRVHoqjyQJABg kK1ZcpZYsjWImOkU6P0v1BpgR5dlMqshW2iL93PdzfKN+dCauDYfpEAXNOAOmV7jdW5jF458QPQ Ry7S0IMkZSICpqPbwFoMYJAFFLH3jEstI+6rqiZgOUAu2uKU4cdNJsE81A== X-Google-Smtp-Source: AGHT+IEgonrPkdfWQEW+qQJGpWHx/emUHZ0YhpD9In0RlFvmcZbn8kFIi3WG3oWKS2Ucs7ppdM0Ihg== X-Received: by 2002:a05:6a00:6812:b0:72d:b36a:4497 with SMTP id d2e1a72fcca58-72db36a45eemr40523454b3a.3.1737771195740; Fri, 24 Jan 2025 18:13:15 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jan 2025 18:13:15 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Vladimir Medvedkin Subject: [PATCH v5 01/16] fib: add allocation function attributes Date: Fri, 24 Jan 2025 18:11:14 -0800 Message-ID: <20250125021305.76485-2-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 Use function attributes to catch cases where fib table is allocated but not freed correctly. Signed-off-by: Stephen Hemminger --- lib/fib/rte_fib.h | 26 +++++++++++++++----------- lib/fib/rte_fib6.h | 24 +++++++++++++----------- lib/fib/trie.h | 7 ++++--- 3 files changed, 32 insertions(+), 25 deletions(-) diff --git a/lib/fib/rte_fib.h b/lib/fib/rte_fib.h index 496d137d48..65c24d5459 100644 --- a/lib/fib/rte_fib.h +++ b/lib/fib/rte_fib.h @@ -17,8 +17,10 @@ #include +#include #include + #ifdef __cplusplus extern "C" { #endif @@ -128,6 +130,17 @@ struct rte_fib_rcu_config { uint32_t reclaim_max; }; + +/** + * Free an FIB object. + * + * @param fib + * FIB object handle created by rte_fib_create(). + * If fib is NULL, no operation is performed. + */ +void +rte_fib_free(struct rte_fib *fib); + /** * Create FIB * @@ -142,7 +155,8 @@ struct rte_fib_rcu_config { * NULL otherwise with rte_errno set to an appropriate values. */ struct rte_fib * -rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf); +rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf) + __rte_malloc __rte_dealloc(rte_fib_free, 1); /** * Find an existing FIB object and return a pointer to it. @@ -157,16 +171,6 @@ rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf); struct rte_fib * rte_fib_find_existing(const char *name); -/** - * Free an FIB object. - * - * @param fib - * FIB object handle created by rte_fib_create(). - * If fib is NULL, no operation is performed. - */ -void -rte_fib_free(struct rte_fib *fib); - /** * Add a route to the FIB. * diff --git a/lib/fib/rte_fib6.h b/lib/fib/rte_fib6.h index 21f0492374..b03b24421c 100644 --- a/lib/fib/rte_fib6.h +++ b/lib/fib/rte_fib6.h @@ -82,6 +82,17 @@ struct rte_fib6_conf { }; }; + +/** + * Free an FIB object. + * + * @param fib + * FIB object handle created by rte_fib6_create(). + * If fib is NULL, no operation is performed. + */ +void +rte_fib6_free(struct rte_fib6 *fib); + /** * Create FIB * @@ -96,7 +107,8 @@ struct rte_fib6_conf { * NULL otherwise with rte_errno set to an appropriate values. */ struct rte_fib6 * -rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf); +rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf) + __rte_malloc __rte_dealloc(rte_fib6_free, 1); /** * Find an existing FIB object and return a pointer to it. @@ -111,16 +123,6 @@ rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf); struct rte_fib6 * rte_fib6_find_existing(const char *name); -/** - * Free an FIB object. - * - * @param fib - * FIB object handle created by rte_fib6_create(). - * If fib is NULL, no operation is performed. - */ -void -rte_fib6_free(struct rte_fib6 *fib); - /** * Add a route to the FIB. * diff --git a/lib/fib/trie.h b/lib/fib/trie.h index f87fc0f6d2..bcb161702b 100644 --- a/lib/fib/trie.h +++ b/lib/fib/trie.h @@ -129,12 +129,13 @@ LOOKUP_FUNC(2b, uint16_t, 1) LOOKUP_FUNC(4b, uint32_t, 2) LOOKUP_FUNC(8b, uint64_t, 3) -void * -trie_create(const char *name, int socket_id, struct rte_fib6_conf *conf); - void trie_free(void *p); +void * +trie_create(const char *name, int socket_id, struct rte_fib6_conf *conf) + __rte_malloc __rte_dealloc(trie_free, 1); + rte_fib6_lookup_fn_t trie_get_lookup_fn(void *p, enum rte_fib6_lookup_type type); -- 2.45.2