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 8887146104; Sat, 25 Jan 2025 03:13:40 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B57D340648; Sat, 25 Jan 2025 03:13:28 +0100 (CET) Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by mails.dpdk.org (Postfix) with ESMTP id 9FE38402EB for ; Sat, 25 Jan 2025 03:13:19 +0100 (CET) Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-218c8aca5f1so64476045ad.0 for ; Fri, 24 Jan 2025 18:13:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1737771199; x=1738375999; 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=a96knsh50yFaW0Zf67LAgvFd0NN0kTRzrE5HBm1ySo3dUUOeNbp3zxEFGi7fY5bU20 bWrmeXdizdlDvRrOovA2wmPGUGhrCUacmqNDB3Cr6/lIrScaV8WZ7k11Zbl0n7l70KIO qLAXeLI+gjsiIYiyWeGmUlGs7wW1W2lP3Y7nNGg5WSGWuFtEN98gelY2UDKPrsvq2+fC 1Igy31xZzBgBFgZrFRTsFzPswBz43XXeGY1WRIkdfa2yvIi7kE9yflEYDIQI9ZaicoXL gO1u8JwJ6vKzRc3VvubLZcrtNLTtotthXAMAbEHrvrA7BJU2gdHKOsXGp3/hIUOpdc3Z OOyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737771199; x=1738375999; 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=FMNsBwvRrOA2h7Uyaj9F+EuZ5mB4nVSYzWyJXhWDLBYjEQv57vRTbpXoG4pxyYSBgP teKpXIGEUePWj79L5IJ76iv4zxcfBAbce2cORvq+gdZ9XRq54vk6zeYt1adeBOjcbraO pvNIIBlDAFVC9PJ2k8g74sd4L5r2OKzZi7Wwiqkv2jn1vIuH2zG8vVM7FBq6/ifAMrQS H+oKvRFbNq703Rvl5wUh0VdIobmfnC3/vkkuAfTCb20shd0Q3XnD68V1C+0jSkCnHq4q uBj61LzKjFKM+kXJqG9SZtAI4TGug5ZE/lHndNvHQ0a9hHyfLknk/mMZKK1i4aKRfyVP VvAg== X-Gm-Message-State: AOJu0Ywjxe074DARBJSDyAlvdHgx6nKizplB5V8QbU6QK9rkbeSTSi9t pyz7Eol3AsP9xuNtPBHHY7MMuMryuB5MzIkZx1FD/ibXJPiAs7xMobCM5xICfm260NhyrT+AKs1 q X-Gm-Gg: ASbGncvFMh0ZoFt6bI9nX6UVFHXe0AaqO1zDPtw2lGhxmcy96cyq0hskhbkhhWp4XYZ q31C4FlG0h+6GfEHHWGFWc6+Vpo62oc/a0+jpeLCZSYy4BWzRU+RobAKvvF3fD/xZtMyH97gyXa W8bzjdBV2+hL/g3e180l+1yu8VO+KYBvVNXoBQhy2q1JV341yiSUG2FGUaGryuSDeH+p+mujuqZ o7HwsxocX5bzthu5PNb9NOk44DZcJPZVnxsaTpgOJ8K+w2vowPVXBL+Ur8XoInIfc95l64SBlv3 8dsKs6kLQ5uqeUt/d5K5v7IBVp7g8Fla56wPlxxcZOEQY/9xRb6b2HSGog== X-Google-Smtp-Source: AGHT+IFDiSEHBBPIS0RN0BtTrzzygZJPU0nUu7m0WoRigSwt+3X0zStUysmn6QnDt5WP074SCQE/iw== X-Received: by 2002:a05:6a20:2447:b0:1e0:d19c:c950 with SMTP id adf61e73a8af0-1eb2147fc5emr49651119637.16.1737771198966; Fri, 24 Jan 2025 18:13:18 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ac48e84e199sm2345256a12.11.2025.01.24.18.13.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jan 2025 18:13:18 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Bruce Richardson , Vladimir Medvedkin Subject: [PATCH v5 04/16] lpm: add allocation function attributes Date: Fri, 24 Jan 2025 18:11:17 -0800 Message-ID: <20250125021305.76485-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250125021305.76485-1-stephen@networkplumber.org> References: <20250110170603.538756-1-stephen@networkplumber.org> <20250125021305.76485-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