Add function attributes to catch cases where rib is allocated
and not freed correctly.

Signed-off-by: Stephen Hemminger <step...@networkplumber.org>
---
 lib/rib/rte_rib.h  | 24 +++++++++++++-----------
 lib/rib/rte_rib6.h | 24 +++++++++++++-----------
 2 files changed, 26 insertions(+), 22 deletions(-)

diff --git a/lib/rib/rte_rib.h b/lib/rib/rte_rib.h
index 2054d3cebd..f30b85d79a 100644
--- a/lib/rib/rte_rib.h
+++ b/lib/rib/rte_rib.h
@@ -230,6 +230,17 @@ rte_rib_get_nh(const struct rte_rib_node *node, uint64_t 
*nh);
 int
 rte_rib_set_nh(struct rte_rib_node *node, uint64_t nh);
 
+
+/**
+ * Free an RIB object.
+ *
+ * @param rib
+ *   RIB object handle created with rte_rib_create().
+ *   If rib is NULL, no operation is performed.
+ */
+void
+rte_rib_free(struct rte_rib *rib);
+
 /**
  * Create RIB
  *
@@ -245,7 +256,8 @@ rte_rib_set_nh(struct rte_rib_node *node, uint64_t nh);
  */
 struct rte_rib *
 rte_rib_create(const char *name, int socket_id,
-              const struct rte_rib_conf *conf);
+              const struct rte_rib_conf *conf)
+       __rte_malloc __rte_dealloc(rte_rib_free, 1);
 
 /**
  * Find an existing RIB object and return a pointer to it.
@@ -259,16 +271,6 @@ rte_rib_create(const char *name, int socket_id,
 struct rte_rib *
 rte_rib_find_existing(const char *name);
 
-/**
- * Free an RIB object.
- *
- * @param rib
- *   RIB object handle created with rte_rib_create().
- *   If rib is NULL, no operation is performed.
- */
-void
-rte_rib_free(struct rte_rib *rib);
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/rib/rte_rib6.h b/lib/rib/rte_rib6.h
index a60756f798..d9514acf82 100644
--- a/lib/rib/rte_rib6.h
+++ b/lib/rib/rte_rib6.h
@@ -294,6 +294,17 @@ rte_rib6_get_nh(const struct rte_rib6_node *node, uint64_t 
*nh);
 int
 rte_rib6_set_nh(struct rte_rib6_node *node, uint64_t nh);
 
+
+/**
+ * Free an RIB object.
+ *
+ * @param rib
+ *   RIB object handle created with rte_rib6_create().
+ *   If rib is NULL, no operation is performed.
+ */
+void
+rte_rib6_free(struct rte_rib6 *rib);
+
 /**
  * Create RIB
  *
@@ -309,7 +320,8 @@ rte_rib6_set_nh(struct rte_rib6_node *node, uint64_t nh);
  */
 struct rte_rib6 *
 rte_rib6_create(const char *name, int socket_id,
-               const struct rte_rib6_conf *conf);
+               const struct rte_rib6_conf *conf)
+       __rte_malloc __rte_dealloc(rte_rib6_free, 1);
 
 /**
  * Find an existing RIB object and return a pointer to it.
@@ -323,16 +335,6 @@ rte_rib6_create(const char *name, int socket_id,
 struct rte_rib6 *
 rte_rib6_find_existing(const char *name);
 
-/**
- * Free an RIB object.
- *
- * @param rib
- *   RIB object handle created with rte_rib6_create().
- *   If rib is NULL, no operation is performed.
- */
-void
-rte_rib6_free(struct rte_rib6 *rib);
-
 #ifdef __cplusplus
 }
 #endif
-- 
2.45.2

Reply via email to