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 65958460FF; Thu, 23 Jan 2025 17:30:45 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7589840DCF; Thu, 23 Jan 2025 17:30:26 +0100 (CET) Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) by mails.dpdk.org (Postfix) with ESMTP id 9C15C40BA0 for ; Thu, 23 Jan 2025 17:30:21 +0100 (CET) Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-2ef70c7efa5so1778928a91.2 for ; Thu, 23 Jan 2025 08:30:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737649821; x=1738254621; 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=LWh/r3qZepRjw1FWLqczaazTQf2EOVsRUTtZ4St3dDA=; b=MGLuPaDBQ84ExpFuHSeXgyaq7bMvW9NEin3NH4ZovyQMTP19eTfZjgNHkGe7pe54LA SUSPEJy5nb2Z01mA0vja/Go2gVWwfQJh15h4INUxHmOPyV85ZGBN1ME38LZxZ+8UWlQz 46HJRrSLrnYRFof0jOAW5nKhDpH3+86shlVhrpoL949SvdnWFcD8W//FEr1tH8BqTWbI GdUj/cqEhwpN+WMPFLD8dYY25xQzx51Rw73W+jGKwwf5ntWaZJEnyzrpe6H+A1sW77E4 qKoR5nLKMK10DHh0hlNwpGIhBYJyw6KN4uRixeUDU7eOiS3KykzzriPrb3Tt6LGjxLu+ vtWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737649821; x=1738254621; 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=LWh/r3qZepRjw1FWLqczaazTQf2EOVsRUTtZ4St3dDA=; b=rr0EaK5vrJlbvaVqKF9VuOsoOFGT8kbh6bv5VR5y871f+jadJMSWz1dwOa+O/+1bGY bRF8WPmck/+WYSxRzO0s3qVcgLZrkqBrgscMfQsjC1M6UCkcnXeqczYG/Eue1fK0H1PV 1KmWCN4Oh+fXRAURDSl3gMB4ZVlVThsZeiIlYbORWhTFDj3sgyHvrm3j8UPpwwAKR2h5 Teo3de+NP5VV9Pu05RenGYkDZA4ur4bWUOgrUNo5VTg0lBFCBjYI2OKrgqhkDP9DFjZK aR72eEKvkkEPoAUnr9TUpSqk0zUSxcolM+UGs8jR+ts/OG2uzhCqvrgZWx3G+RRXRp7h 6ziw== X-Gm-Message-State: AOJu0YxUr6T1vnJRcIwuo5UVqVLLHcu5b4sfRHNpzMsdMiSbmhSyU4Ts 4Gzc8E+Go0s3XHkoKhKY0sTARb+NF4NvlS32BzV89sw68yjhot/Mn/LrjQ60wGtoCEJER3T22M4 U X-Gm-Gg: ASbGncteZHXiV46OkLQgg2phn9pquekHCUR23tmMZRVNIRoRAnrwwqb3Aq9zMmwstL0 AfE5Mz/VnRu73lFLB4taZ1lpeT85t+oEQnhc02ze8Wd5TKWMaVqmkLSG7DE5ohZO921xySciL8y OFoH2O7puNuHIq1MFG6eFSH6QlrbAMaguafoIbg0GPJhJ+U84848jN2l5ZDJELOOxGvTzJSZkDM sZSfwRta4sD657cCElTVfvN5aadY3shcTMSQrO1j6F84r89aa9obvTKMLuoTg8MPzFDjmNhd4qY HC6HexDWPFZhhBqVavj+qZN7PUyQBSYgElcVPJ99SxyF1OrvO4nInvK53g== X-Google-Smtp-Source: AGHT+IEUeSxnScQXKWTYYZwNLULpxB/bQHwelJHCuSmlAeS63oNyG+qSq+QZD1sVHj+I8yFqQ9doGA== X-Received: by 2002:a05:6a00:2444:b0:725:e37d:cd36 with SMTP id d2e1a72fcca58-72daf929e6cmr39239479b3a.2.1737649820807; Thu, 23 Jan 2025 08:30:20 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2025 08:30:20 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Bruce Richardson , Vladimir Medvedkin Subject: [PATCH v3 04/15] lpm: add allocation function attributes Date: Thu, 23 Jan 2025 08:28:04 -0800 Message-ID: <20250123163003.23394-5-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 lpm table is allocated but not freed correctly. Signed-off-by: Stephen Hemminger --- lib/lpm/rte_lpm.h | 23 ++++++++++++----------- lib/lpm/rte_lpm6.h | 23 ++++++++++++----------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/lib/lpm/rte_lpm.h b/lib/lpm/rte_lpm.h index 329dc1aad4..7df64f06b1 100644 --- a/lib/lpm/rte_lpm.h +++ b/lib/lpm/rte_lpm.h @@ -140,6 +140,16 @@ struct rte_lpm_rcu_config { */ }; +/** + * Free an LPM object. + * + * @param lpm + * LPM object handle + * If lpm is NULL, no operation is performed. + */ +void +rte_lpm_free(struct rte_lpm *lpm); + /** * Create an LPM object. * @@ -161,7 +171,8 @@ struct rte_lpm_rcu_config { */ struct rte_lpm * rte_lpm_create(const char *name, int socket_id, - const struct rte_lpm_config *config); + const struct rte_lpm_config *config) + __rte_malloc __rte_dealloc(rte_lpm_free, 1); /** * Find an existing LPM object and return a pointer to it. @@ -176,16 +187,6 @@ rte_lpm_create(const char *name, int socket_id, struct rte_lpm * rte_lpm_find_existing(const char *name); -/** - * Free an LPM object. - * - * @param lpm - * LPM object handle - * If lpm is NULL, no operation is performed. - */ -void -rte_lpm_free(struct rte_lpm *lpm); - /** * Associate RCU QSBR variable with an LPM object. * diff --git a/lib/lpm/rte_lpm6.h b/lib/lpm/rte_lpm6.h index 079187ca56..08b5618613 100644 --- a/lib/lpm/rte_lpm6.h +++ b/lib/lpm/rte_lpm6.h @@ -34,6 +34,16 @@ struct rte_lpm6_config { int flags; /**< This field is currently unused. */ }; +/** + * Free an LPM object. + * + * @param lpm + * LPM object handle + * If lpm is NULL, no operation is performed. + */ +void +rte_lpm6_free(struct rte_lpm6 *lpm); + /** * Create an LPM object. * @@ -55,7 +65,8 @@ struct rte_lpm6_config { */ struct rte_lpm6 * rte_lpm6_create(const char *name, int socket_id, - const struct rte_lpm6_config *config); + const struct rte_lpm6_config *config) + __rte_malloc __rte_dealloc(rte_lpm6_free, 1); /** * Find an existing LPM object and return a pointer to it. @@ -70,16 +81,6 @@ rte_lpm6_create(const char *name, int socket_id, struct rte_lpm6 * rte_lpm6_find_existing(const char *name); -/** - * Free an LPM object. - * - * @param lpm - * LPM object handle - * If lpm is NULL, no operation is performed. - */ -void -rte_lpm6_free(struct rte_lpm6 *lpm); - /** * Add a rule to the LPM table. * -- 2.45.2