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 0542F4601A; Mon, 20 Jan 2025 19:06:30 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 18A9842791; Mon, 20 Jan 2025 19:06:07 +0100 (CET) Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by mails.dpdk.org (Postfix) with ESMTP id 8B4E34114B for ; Mon, 20 Jan 2025 19:06:03 +0100 (CET) Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-215770613dbso59901795ad.2 for ; Mon, 20 Jan 2025 10:06:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737396363; x=1738001163; 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=M4Nf3j9S20Fz4v4iqODUKpU56b6Wx8B7dXsTAS5QWzvHaoR/18FWHJPDlwT9crX/wf lgZQ4FZNw4siIV8tSpT2bVaPh59f16vA49jj+Wv6dFk1FwJEmu+QAjI82eT3eGzf/tgP IkwOB1tpvxvqMr3yuXiw+VpZmBVljmEz3kojtbIPnoegIkfyLlRd4rJ0owbeq5YIOHzn KznaB0WikZSup78dspNDGEsZzEjx08unr+DSSKJVoor7QqnKuZNojpbh4aX3ztbjdy2R BS5iW19/BkOqcd2LGlz7ThO05eQgSQPwN9TJ5g8XQaCtA/PzlNrVSuFSTKEcG6/liXbw yF/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737396363; x=1738001163; 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=BPsur+ZHMtOyimyRUefhYiktex22D1tVy263hKTNs2Juh3xoQhBzKwmHc53axtqxVB 0V5n2RIiMAG52hMSo0bxA7SMCSPkJnX6loDZfunJkHPkHxOBaSuQgM2K1QOvhDLhmIpy e5hAvsbppgoctWkGe1bEZgfH/eYmNiQlrtNgzf9kGml3ax6ahPlz+Cw9TePZzz52c60V PUtB7bQZ8QY7Z17SQ7VGEL6QSvDmLpWLOZVHRMDdnuaoj+2l6+rpP7QIVfU61kHWKEEf pLCc5q/N0OULtoaxu+0uAST8qKbqoeqgq483zKhzXLgHhCowTdYVzBFNK17ohxhIVCw5 6LtQ== X-Gm-Message-State: AOJu0YwfX84H4AFN9A3pms6YAmCLnD57KRZ7GiSgIUJm9iXElpmgPpWR ZuEvx9JOqO6pOkMyVfpRnnUR90vUNEU+YG7e5m1LpBFT94mSEoBV+7xXQbdrFI2Shy7AQu9iOBy / X-Gm-Gg: ASbGnctDVxj64IIPTGg6olLp7FHDsuOhv0PbiyDnnINiCJ0QDo0WpdbVZFmpyswQm36 4g03H6UrfCpmdsJdzES3xc1ej21VRDW8jrVpfGyPqbZq01fgCbxTNF/MwhwaTQYAZ3ni9Zw/hIR fBhqmXy+8rQdfsRXi0OQCC0jEj8l3W+h1bHgwZy4QfqF9RgOoPg+iaXcw7IwFBZeba85exWJcpn AhHN1y8j91EEn+gCAIy2XO7tTyZ82r7WpmrX0sST74pppTIiPwsycICqPuIM9UbNuavgB9A/YYh +XSUHyyWQbjVZRr2l3RcuueFDixcoEHPgzwSQscMCGqe1zI= X-Google-Smtp-Source: AGHT+IGnMvdWbNoAKlWGpn69LBkJJBkkr2BsXGVrVAmawoWXsggtEN/Eay4qUhN+gPY2HHMm4t90qw== X-Received: by 2002:a05:6a20:7492:b0:1e1:ae4a:1d42 with SMTP id adf61e73a8af0-1eb2159cc48mr24884829637.31.1737396362765; Mon, 20 Jan 2025 10:06:02 -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.06.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jan 2025 10:06:02 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Bruce Richardson , Vladimir Medvedkin Subject: [PATCH 04/15] lpm: add allocation function attributes Date: Mon, 20 Jan 2025 10:03:22 -0800 Message-ID: <20250120180550.198121-5-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 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