[PATCH v4 04/16] lpm: add allocation function attributes
Stephen Hemminger
stephen at networkplumber.org
Fri Jan 24 19:14:55 CET 2025
Use function attributes to catch cases where lpm table is allocated
but not freed correctly.
Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
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
More information about the dev
mailing list