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 5B97046114; Sat, 25 Jan 2025 19:40:46 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EEE6040616; Sat, 25 Jan 2025 19:40:28 +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 E5E60402E3 for ; Sat, 25 Jan 2025 19:40:24 +0100 (CET) Received: by mail-pj1-f50.google.com with SMTP id 98e67ed59e1d1-2f42992f608so4551010a91.0 for ; Sat, 25 Jan 2025 10:40:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737830424; x=1738435224; 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=Zx2J9A0hC2aDmSEBMozOchP8J+IL0X2kp2LQFqfC9qLgyfQde7PTyUPaprLjBzlqyY 9dH/L+8Jmfqy8j6Vg5ny8UOrH23rz1YNJBVMtAeDkb0GgkaM65gy5kzio8FGZPnUvatS /aG+lTlF8TNgBh/TJEd4R6rrQATLpR7XEz9Yz3Hvcj9dUTYZwouqX9Vk6Z2Ld45xcVUG 7xHpyORlu7lHKqsGimVxTtwcxrBkywTNg89p/GsJR29lPL8A/35HyXT5HyCXRNDOhKV8 Z0x+kwSVQS5agY+2bXL6B3w2WNmJQ7l1Jnz/CFXyN+CK9Iw9SB5/mdSC4c5h6JsJtlO/ OgnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737830424; x=1738435224; 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=uALkibhIbKSzmxaDO1DyIidVd3/tSLbPHPVh2ZmyEwWXKz783aZPNnjgfI4lfc9oaf hzjj4TdlLVj1TDTqSjyAu/X1EE54iYoUg6cNt9oi+5dji2VbD++Ew/WpCSPcIQy7LHwO YfrUOJIyFMBiR/7w9wOf4HUeJwsvU3J35g4/JBqcaBlBLLV1kui7MJRA+i18D539g/Lf 6CPbGKMJO0zIPQ6z59MLFx8456xXYUUw0h8tfNKAia+svQnP/LYRzuwU54s+cIwFSRO0 KRlJNh2lxrt5duMBprJq7gRB9Pr171eSj81rou4N9CgiAANXRnxwNcAZ5KS7n0ZkHBy6 7AuQ== X-Gm-Message-State: AOJu0Yz2NS7tDHKX55/OlyATZujcbmRGDP9KJKOlpwICEWQ5RFqZihLq U0cSclQH8tmRw8Fa7W6qup5B2nJ+ODQdOekCY4d986WsVf6c+Tvgd9LUDp4FuHhAQMenfTBUApw o X-Gm-Gg: ASbGncvYyLlXGx5oKU/tZS3s6ZqZFr1c8TIIpJrmVFqZf1cVfE7FxElITZb5YlIb8D5 S/sto+C0Nya/c25uzV552/bNWua9XlH1Qxr94cFuDxcGyhxAh6Wrnp4jnbMEYf1ZEOId6VWTZhK XyAGXZgEs1FbdYIXUT0SY8HGcUGZuGHWcDcfOFeZrrNxBrq+MD/mdz/c+C+66JJjuTmnK74mIEx TJp7G8KkQLHkbTaovub22fLZRAa/+1uPBPXIJNp/Uzhm0vYZF5RucZtoGKTTr+AUmVUBtzOtoDo 1aFDknBXvhKZL7Cqle/gzRbohLX6fB1FQZ56fyc2DMBSy3EDqnQXeBSA1g== X-Google-Smtp-Source: AGHT+IG0jo2U5nSay+vtPDiirCtCHj5rLrE3MGu6U+cLNZUN496P99ronEXFytWH90vGty61nfIoLg== X-Received: by 2002:a05:6a00:418d:b0:71e:21:d2d8 with SMTP id d2e1a72fcca58-72daf946789mr51147594b3a.7.1737830424105; Sat, 25 Jan 2025 10:40:24 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72f8a7614f4sm4100547b3a.97.2025.01.25.10.40.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Jan 2025 10:40:23 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH v6 04/15] lpm: add allocation function attributes Date: Sat, 25 Jan 2025 10:36:38 -0800 Message-ID: <20250125184010.782330-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250125184010.782330-1-stephen@networkplumber.org> References: <20250120180550.198121-1-stephen@networkplumber.org> <20250125184010.782330-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