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 89419460E8; Wed, 22 Jan 2025 18:36:15 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F2A934065D; Wed, 22 Jan 2025 18:35:58 +0100 (CET) Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) by mails.dpdk.org (Postfix) with ESMTP id D1D8240648 for ; Wed, 22 Jan 2025 18:35:53 +0100 (CET) Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-216401de828so125241635ad.3 for ; Wed, 22 Jan 2025 09:35:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737567353; x=1738172153; 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=MN/dgPjxjDO7ZQXt0egbyheae5WMQ1/zJfCG9pDpYwS2Mt5E5XdJbyhyBMFenAqWCk eIoOArgFJhGg/PAGWyGXVIenbL5sfGVR1I8PcUlD7xoHQBveMREZuw/Zc/PFo2jktp+E 18F9ZpgMfIjD8GZqGPXzMZ9jCmDs6+ngTdlGMSGTo5BwOQjkpo9INH0Ja1erpw+6CTRp PxXvVuGtfkbtUhb+CznFlSQdxbvHS8xg3NpwHpZP29anBnPJq6o2WCdQN2opKM3JXZ8t 25vWVc7qwmmcTKRkmJfs/BxcGNlRPlivKx/cJMOzKrNMirBa4d1p9TsMvOpBFp4oEpoh OawQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737567353; x=1738172153; 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=uj54exC3aX9nbAQYwakKpi8lPoAWyew/0dEnKqRs0KIMNrhZs0+DWFUtmfDDXhw3PP ETmmxQ05bM93LnXOW95syl9mqqjbz00fR3125uQWLxJIko6wk/IfwFth8VcU+rpWbTWe MOk9I2NDtr4sggpTPwkTH8oPkobsnaK5CP5OWY8H5sAjvf+AvvMFRHC2DPSGCCOj/meX mxhQn7IOrmPTHRHsObj7XGbG7UpAbDF6gKsKFbzR7GgHhaI8z+wnyi/FBgHVtus+luij 8NY48Bd1FPwmE4hTQLw8xNrZL+o+6xM9yeA75DSMdrMf3rNk3LLP/e/Tn/n1kqjZIDKt iWuQ== X-Gm-Message-State: AOJu0YzGcxhYjcetdbRAooPrXdyxMkwsrHKGcatcNGhypFGwaCgd7WCY V9U0Nrb+N3fwDQDbSAxo4zF30hZ+/3XHdj+HQkiLOpFTrTVGCNR9uW9XZME2+DXW4jenF+QahtR L X-Gm-Gg: ASbGncsc9ab23IXAS+OeLHx0woUBb8A3ypBu59yo3mCUazbqbn89EXFERAdAo9oDstk quJIrTzG9w/JoH3eFhakiIWIXmfmjfKUbeAdG5+UHT6b0wMolxcc8rMphY6o6pU3w5FU00Bfyq6 VMDwruYJwf9o1/P/7OxS9fWOSKIpxkRHmkNFqPC6SVyxtDu1a+xOu4iqx82cSr9dJzKdI4/YW9Z T51eiXkj3+T1LScL4XDxJ+FeDidc/x/0J4Poi79tQMoCqQdG6LPrzsEQUNt7KoRXHk98wIeI6nV 2NV1tb2SlXdXmhK8HKIRlwsJt39iGoR1/dCxZRhgExxIIn4= X-Google-Smtp-Source: AGHT+IFirB2/TNkk3AoIGCFaTxConLgFJ+cGQkE4gEUb0lteZO4gRuazS3ZHGG2yCKxkxD5c+LVBcQ== X-Received: by 2002:a17:903:1cb:b0:21b:d2b6:ca7f with SMTP id d9443c01a7336-21c35577b18mr270110025ad.32.1737567352824; Wed, 22 Jan 2025 09:35:52 -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.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jan 2025 09:35:52 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Bruce Richardson , Vladimir Medvedkin Subject: [PATCH v2 04/15] lpm: add allocation function attributes Date: Wed, 22 Jan 2025 09:32:48 -0800 Message-ID: <20250122173521.305108-5-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 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