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 C925746130; Fri, 24 Jan 2025 19:17:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A0121427DD; Fri, 24 Jan 2025 19:17:23 +0100 (CET) Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by mails.dpdk.org (Postfix) with ESMTP id 630E640ED8 for ; Fri, 24 Jan 2025 19:17:19 +0100 (CET) Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-21c2f1b610dso54141715ad.0 for ; Fri, 24 Jan 2025 10:17:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737742639; x=1738347439; 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=UJB6XW/D3EixgxyyLUCjDzWfFzPgBVwF7Iy3DxU7NvGyDLX91gGDDQg90/eN5Y9S3Z fgIMWPuWXgmxj7rFVZuRMds8iMTQ5NIIboXQjWk+WlAHNB4IOt8c4vrQKP3KDf5g0F41 h6xh5VQfRoYHYl5IWnWdVYdm1HrOas8Qdgz2l5WjBBZVtKVBhW+y/birv09ePByyzKh2 4xiKTbxiUEJ1f50+fGSPEUVdSZukI0LC6gbsHUCYpuZ2B91QNHUWL4liFR0NwpYRL4MS VWYQ46eA/+Oz+5/6TU4LtDlPu0G6zMT6ooiJgXl3uQi6I5XAuPJupvcXvIw7Gk69OYQi qfHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737742639; x=1738347439; 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=wiPag3d58JErtGUjB1Tk288q9nWzxdKbZp1lPzovhaEeVSMR0V4u0kS+dYWGWcv3WS tTMtKSgMyJS9aO52GPJ190/442cg5TdDFJWK1GG7HGumeHV3cfMDuHArC/j6gVzAyGDF haaQQ92VSCX5y1dwEVw8DZjj3kQFIO4EVcPP3XfrVBsHrBKI/CbppppmGGhBiwfu514D RFKUq6akCq32i9RpHN4XTOIK6BBQLXOLBnh81sHxpWTzysKN96Yb30khIp8WDFJApgCL hGQAjKLD18IDTg9iIcyT9SPk/Z7q8ar7dqfFi3BYg64V4wNNbA+sbFfNKJzIq8DB1ip5 qo5w== X-Gm-Message-State: AOJu0YyJEQWxVxunP02uZEHwiYWigNsanxjqsDkAVIyqW1O+z9ksDR6Z eGGh7WBbKAHj8rTG7+WIJBVZ6AhAj8b/rZLgDk5vg/yay8k3FY5jzK3Ip0x4EOJYmd3QaGlWxp+ I X-Gm-Gg: ASbGncu8YwfyF//wg1MYalepYvUJnC3RFM3d7JlnMdtvUkyBZRO11a/MBxVpm1YkJjg UvR/zpUb3WAxC2bakDuX6LDv6I6ZzaXUSQk0QXG9dj8nh2Rw/NJ4BHWFICb654bqfGJh9Gmi9YJ nbj7p/9oKfa/S/TJxYaFXI4DTz9qgBZWVb6hNDDnjsY+hR1gqYzhjkNH9pZR3bI7HuzRWU+A86j 5KYYijflffPL1gXyq9lhcBw1qhSbXgRHdk8jhqW3IsjXD9hRAQTdxTa8XfgJC9YhAqXlCXCOCUt kQUZ1CIsC5LxqslIcx3pXpLehW3FuoeGThN+OCrrngN51+EbhjrAQ8TyEg== X-Google-Smtp-Source: AGHT+IHn+TnLCj3nbtahji6RTtxXqnbIrH+HWZ1oI3dJW1iJyAl3byrL3wYsIkMR5ciL+GlQYYXrbQ== X-Received: by 2002:a05:6a20:748f:b0:1e1:a06b:375a with SMTP id adf61e73a8af0-1eb2160f41fmr55432767637.35.1737742638664; Fri, 24 Jan 2025 10:17:18 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72f8a6b2ed8sm2184477b3a.41.2025.01.24.10.17.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jan 2025 10:17:18 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Bruce Richardson , Vladimir Medvedkin Subject: [PATCH v4 04/16] lpm: add allocation function attributes Date: Fri, 24 Jan 2025 10:14:55 -0800 Message-ID: <20250124181704.86567-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250124181704.86567-1-stephen@networkplumber.org> References: <20250110170603.538756-1-stephen@networkplumber.or> <20250124181704.86567-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