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 7D7FB4601A; Mon, 20 Jan 2025 19:06:07 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D937F4111B; Mon, 20 Jan 2025 19:06:02 +0100 (CET) Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by mails.dpdk.org (Postfix) with ESMTP id 57A7640A77 for ; Mon, 20 Jan 2025 19:06:01 +0100 (CET) Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-2ee51f8c47dso6435130a91.1 for ; Mon, 20 Jan 2025 10:06:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737396360; x=1738001160; 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=eJyDnIsfTpMQydOIpREXteiHO4X/TbbRnFf9Gg68lgdoVpHOvvCZtGJV8mtEu27ph4 6jb7L/LB0PKXjE3gPvtWhSh1wzHDMZ3fEqA0JsxtHlc+ycwZG+5L58WingxaBP7d7ZRY RAaMhuBvhT/6Zz1B4Ji/fmwXWzWG+N8QyJ/t2bYeeEGoPbgNrgeBNWLThBCP1S3xIZ2n UWxiwFvWTJ2rUU2V/z9EFF6V/JC4O3yGCZxps8TNtPF9MAUgVvIPErwTjCHFr05Z3VqU saJMWx9FF2ekkrlc/Mjf3ugNSB68+4YzpsY1ZXmQiuR7o2bTitwt0IgPMF2/QeIif/Gg 4VGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737396360; x=1738001160; 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=YWYkdKyrk5jXGpLvDUKW2z+yfkCQ0Q+Ywph9DhojsWHbbN+T65ECIZDPmnCawNqSTD SiOnVtREt/5+EEbnQnjaY2TTm5dIM3oKiZornvHsR6//YlYg3w0hNLbmdiPUA++1x8B4 3SCq/BVrCTEWdD7Ap1ts8rlsMDHE4tRl8z88h1ePgqMrryUcNcDtQCfsxZ2kU/p/DYcv qU3gKhb7/SG524er+emPjnOjK3L34js4iwsbIR/tNo5YCyr4ctPwxOV6GqjlD2WHuVNK jrvxWJdPKTy/Q+Dg6xB9vH8NdxijlN2J9KqM6orOn64GIIwdyV7Mds7L2gzvc/cIUO7/ eWfA== X-Gm-Message-State: AOJu0YwfQ7yG52tf9CnGuhkFxt+3g2557ptVG43WFk4XxlslMKvQLrz5 WK7YTBSwuUVaqK2icrOXfyB/bCnUgBKx99nDFsF56GKAS6sUkehXMK9OkhH7eHNNBkYxUz3mQns / X-Gm-Gg: ASbGnctEdvwy6hBbR4KEJgqlj7lQLvndzCvBQ4yJW81UQxkaD/8dQXEDrR1I6KuO6ZM 8ttbi2djVEk9Tg5H8HO5wnA+CjpAYvviHrXe/4zizVTAgZADRFKkBbmQV8iCG9HRpqdRHdO6npq a/WZAklzkyVTbhfXWAwplrI5sf+pG7eFENr7gzWS8ZPOYFKQD+aEkpsqlL9TUvcsqiSgyCZKfXI D1LUA1/588HqXUJVhlaFqimamIiMDR+CJNIezg8JzF02PQanlwp6dbbg5x4KzJBPJGsrcbDpzOY 8bAh1mzP2XackopvVcMTAoQ/21pq2ePsC47Voa/zsyHu6D0= X-Google-Smtp-Source: AGHT+IH/picgMJJJMtfbix+7Qs1e5raDp3XHEM4f5NZ4akOH3FJ7c/o5kYnAlJPj2Kos6Q45VncD2g== X-Received: by 2002:a05:6a00:2da5:b0:725:f1ca:fd8a with SMTP id d2e1a72fcca58-72dafb5580cmr21498437b3a.19.1737396360404; Mon, 20 Jan 2025 10:06:00 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72dab848b08sm7393982b3a.71.2025.01.20.10.05.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jan 2025 10:06:00 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Vladimir Medvedkin Subject: [PATCH 01/15] fib: add allocation function attributes Date: Mon, 20 Jan 2025 10:03:19 -0800 Message-ID: <20250120180550.198121-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250120180550.198121-1-stephen@networkplumber.org> References: <20250120180550.198121-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