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 CFDC1460FF; Thu, 23 Jan 2025 17:30:26 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8455E40B9E; Thu, 23 Jan 2025 17:30:21 +0100 (CET) Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by mails.dpdk.org (Postfix) with ESMTP id A44AF40261 for ; Thu, 23 Jan 2025 17:30:18 +0100 (CET) Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-2eeb4d643a5so2209324a91.3 for ; Thu, 23 Jan 2025 08:30:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737649818; x=1738254618; 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=DexGBJC8QtAH4ZzhY04XyoSiW7bjQ9o7teDzzTzv2adh9vIdkH312gf7AN/GyhVz6L ZHkfFCuXp4IzAiMsq1M69gOUKRzJLCja5hm5PaaHyzUp6jXQQ/xx3emMmQrWwz1jC1+m lqYxV9qRkPUTBvOA9vg45MC58uU24YjvIGggxzgP8aZnSzwjkK8xL/9SB394BNuSJfcl yIavT4/juMvAy5jUyMBpG0n5ucJwMBFu5tmJkCNFgE94V8IKq9OeXZgWErFWgHP3tNxz UUuD6zbJoGkGPP/lnRoeCKjjkiZBF6TtioW3IFMDEBlGmoC8gMynPM0DgdDuCr+7uyqf 0U8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737649818; x=1738254618; 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=r6rI8IgZ25klI3/iJvzi5BgF14xsSnS+UFe2vrJCPwcWbQ2MDz0l4LnCqjQ2AZ9Atz 12fE//hHKZ3CgaH7bDgZRVUX8Co2NIVsFKEBDDxvhDPp0a5CIFtx0QmokugCJ/yyvGzr 3eOjJHVUOzPorNY4f36dD8T0dEu59Pygfa9lNN3yUcasHR4LvY33UiLVhNdO4Uwg5Nx6 aLUuCGSpK3Wu4sheWuNd/MOkoQ00hU9p8O9EirTUpue2QgxeqDdlB4VP4/0y6TkKutKK mT3kqEH+dkO78lAT3fmGQLbLmgha77TFZOUgKiPozSIW2qwE1WAx2BzWDqjW0TH/O6wj ZvGA== X-Gm-Message-State: AOJu0YwoNavpK/oZOYPdwmJDJzcYgDTOYoCrIUVEjJCK/ujk23YMwk8s CI7R7kRYq1CtchvyJzTjPGqyMIj9/TPyLjehqM2zM6DVdSU+AS3N2kc33nH8cVNJ1b5ZjTBM5sa y X-Gm-Gg: ASbGncv+Gyzx6sthaYCYHzM7MZU/Gy5tSCm8K0yCBhSvUAuxMQeB5Fs+EnXmKLihdfL qc/ON7cVj3DrqRt2mma1uZlaiu1ED1kWdLxkm8+7J8/vbj7ZtxHKeoEdxDvvjWMJUhL6bONM/sI 3byc3w/DX8biouZWIliQb1nWFm97Nh+af+CwqRZIPLiPF9zHmvm6kC6zxBvnBhVAnt1/O+WnpdX p5Sn17caEzoTJJC6oDAnxJMrI++jKr8FQOXNCvedDbHBqSFM3TH84+6iap7BXgDROdTjRrCXQiW EXExeMiP0blmi34E6OhNlaup7tORGvIgsaTq7LmuRDCfo9Vam1Dc47OA5g== X-Google-Smtp-Source: AGHT+IEkgPjyM+pKcpvUGbQhBa8J3YFZygx2+rCNbxmdmhu5jlXqsouq4oJTFSgCx+HYCqjWlNGTjQ== X-Received: by 2002:a17:90b:2dcd:b0:2ee:df70:1ff3 with SMTP id 98e67ed59e1d1-2f782b17a01mr48053123a91.0.1737649817793; Thu, 23 Jan 2025 08:30:17 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ac4907f076dsm64601a12.37.2025.01.23.08.30.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2025 08:30:17 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Vladimir Medvedkin Subject: [PATCH v3 01/15] fib: add allocation function attributes Date: Thu, 23 Jan 2025 08:28:01 -0800 Message-ID: <20250123163003.23394-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250123163003.23394-1-stephen@networkplumber.org> References: <20250110170603.538756-1-stephen@networkplumber.or> <20250123163003.23394-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