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 698D0460E8; Wed, 22 Jan 2025 18:36:02 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4C19B4064F; Wed, 22 Jan 2025 18:35:55 +0100 (CET) Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by mails.dpdk.org (Postfix) with ESMTP id 73D5C40648 for ; Wed, 22 Jan 2025 18:35:52 +0100 (CET) Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2166f1e589cso174513865ad.3 for ; Wed, 22 Jan 2025 09:35:52 -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=9UWIpUmA7BaG4xjWsP3UBGz9fjV+tBn2Ua5MOChAiVc=; b=ArG8/K/n0R8zeAfOEdWypw4ciTHbcmEQ1S4wiQS1WahDW+d/Md5GnNL/u+6WKk+rIS ltF/ekcDghQYDmAlnbzZoInCHH4EkAwM8evNJ0hNmVsTt0saDDfjIjlWxctELyxXQ68d kXoQMn8b7GmfKgjc7ViTUnEOiMGdqc37BPg+7BuzYCgQ61Z6yPsmwhDqWj9Dg1YXhOIT xiuZ7Z2mOucNiqg6g8KFTF0ZNrBAjFcAwDFVFgnqJEzW+Flmy/wiSAY9Bq2dFgKUxShG /1Mpj91P/7wyrEz3pazfGsMRZwXxpmB6sHz5JAAntDYUBg3qlnZq5K64D3o6Pckqddg/ dyOA== 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=9UWIpUmA7BaG4xjWsP3UBGz9fjV+tBn2Ua5MOChAiVc=; b=KuptEI8Gby30T+XIdOnXcYgxh7D0KwWIShlMehndgOT9b3xH0eNrR2R16cq+UUabkf u6m8dJCYwTdaimb1QenxN/uehLoicbEa+/qiJVDqLgT7bn5YtVXo0oJe8UYZ9Pu6UibF qEdvoJPviyvp+SdRf6B9+aoRUQpsIg64leQoPSMgQExaciIXRN9FE131B7gwgEs/3Fia JQKlbcqP/SYnZDfk41Y0SbJhDJZZFxmqwa4JE3mYxNsZo/LGE/rkwH9WcTga2hAhos/p kwfSzuv/+GsFhWY7kx+8a/UReE6vlyUTC68BYe1xd8+wHz74EFw5usd2RX5BQnLf+Gg/ yktQ== X-Gm-Message-State: AOJu0YwlYOU8Bb0Q+WDLzkL9Je+xO6J9kZtDczdj0Rt7mm3REV6uPkQJ 0QKROF4gF1Wu4eS9hOLsXZjI/pUaFquD76YqtCmGF2L6y39XlpM4c+AXTWtrJvjqIcpgagZKVRQ O X-Gm-Gg: ASbGnctgWY7u42lYioM4MuduvLSrxvv3QQ5cSCJKWBzNYPcFtzPgV+4pNm0kDWUl/7g Q/8ye4qVa3Xkw6HmqMsNZIcquknANyNopA/iuqenZ6rs3bZFpYZnTV6We5Ji41FL68HejzknGeU r5p1jKPFfqhu35exk4GFYJG0d4ziLq6DmAkLW9NRhXpVrfAdDJPkzJIz6MJdS57hCpLOM1eSzED MzN3HoeBrK8Nl45xfVhn2CkM6yytsu3MLfwSQX2c2nuS8vvUaKnjOokjTrILMwKrnOigS96JGut uYFtBAnkJqaeoVq0jXGn45D4STVEQpEe2CIwfJHb3Yy3pAM= X-Google-Smtp-Source: AGHT+IHywi/NOL8XZzso2jtw+5jHzCh9x4CQgGFXKb/k/DcCgruMvfWPA9Ys3jzImo0HsILkXPimog== X-Received: by 2002:a17:902:e747:b0:216:4b1f:499 with SMTP id d9443c01a7336-21c35623dc0mr269219315ad.31.1737567349964; Wed, 22 Jan 2025 09:35:49 -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.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2025 09:35:49 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Vladimir Medvedkin Subject: [PATCH v2 01/15] fib: add allocation function attributes Date: Wed, 22 Jan 2025 09:32:45 -0800 Message-ID: <20250122173521.305108-2-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 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